/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f4f8; color: #1a2332; min-height: 100vh; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a3a5c 0%, #2d6a9f 100%);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px 36px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); text-align: center;
}
.login-logo { margin-bottom: 16px; display: flex; justify-content: center; }
.logo-box-lg {
  width: 72px; height: 72px; background: #1a3a5c; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.logo-box-lg span { font-size: 22px; font-weight: 700; color: #fff; line-height: 1; }
.logo-box-lg small { font-size: 7px; color: rgba(255,255,255,0.8); letter-spacing: 1px; margin-top: 2px; }
.login-card h2 { font-size: 18px; font-weight: 600; color: #1a3a5c; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: #666; margin-bottom: 24px; }
.form-group { margin-bottom: 14px; text-align: left; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: #555; margin-bottom: 5px; }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; outline: none; transition: border 0.2s; }
.form-group input:focus { border-color: #1a3a5c; }
.error-msg { color: #e74c3c; font-size: 12px; margin-bottom: 10px; }
.btn-full { width: 100%; padding: 11px; font-size: 14px; }
.login-hint { font-size: 11px; color: #aaa; margin-top: 12px; }

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 230px;
  background: #1a3a5c; z-index: 100; display: flex; flex-direction: column;
  transition: transform 0.25s; overflow-y: auto;
}
.sidebar.hidden { transform: translateX(-230px); }
.sidebar-logo {
  padding: 16px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo-box-sm {
  width: 36px; height: 36px; background: #fff; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-box-sm span { font-size: 12px; font-weight: 700; color: #1a3a5c; }
.sidebar-company { flex: 1; min-width: 0; }
.sc-name { font-size: 12px; font-weight: 600; color: #fff; line-height: 1.3; }
.sc-sub { font-size: 10px; color: rgba(255,255,255,0.6); margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-group-label {
  font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.4);
  text-transform: uppercase; letter-spacing: 1px; padding: 12px 14px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  color: rgba(255,255,255,0.75); text-decoration: none; font-size: 13px;
  transition: all 0.15s; cursor: pointer; border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: #5dade2; }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: space-between;
}
.offline-badge { font-size: 11px; color: #2ecc71; }
.offline-badge.offline { color: #e74c3c; }
.btn-logout { background: transparent; border: 1px solid rgba(255,255,255,0.3); color: rgba(255,255,255,0.7); padding: 5px 10px; border-radius: 5px; font-size: 11px; cursor: pointer; }
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

.topbar {
  position: fixed; top: 0; left: 230px; right: 0; height: 52px;
  background: #fff; border-bottom: 1px solid #e0e6ed;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 99; transition: left 0.25s;
}
.topbar.expanded { left: 0; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.hamburger { background: none; border: none; font-size: 18px; cursor: pointer; color: #555; padding: 4px; }
.page-title { font-size: 15px; font-weight: 600; color: #1a3a5c; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: 12px; color: #666; background: #f0f4f8; padding: 4px 10px; border-radius: 20px; }

.content {
  margin-left: 230px; padding-top: 52px; min-height: 100vh;
  padding: 72px 20px 20px; transition: margin-left 0.25s;
}
.content.expanded { margin-left: 0; }

/* ===== BUTTONS ===== */
.btn { padding: 8px 16px; border-radius: 6px; border: none; font-size: 13px; cursor: pointer; font-weight: 500; transition: all 0.15s; }
.btn-primary { background: #1a3a5c; color: #fff; }
.btn-primary:hover { background: #15304d; }
.btn-success { background: #1e8449; color: #fff; }
.btn-success:hover { background: #196a3c; }
.btn-warning { background: #d35400; color: #fff; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-outline { background: transparent; border: 1px solid #1a3a5c; color: #1a3a5c; }
.btn-outline:hover { background: #1a3a5c; color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-xs { padding: 3px 7px; font-size: 10px; border-radius: 4px; border: none; cursor: pointer; font-weight: 500; }

/* ===== CARDS & SECTIONS ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 20px; font-weight: 600; color: #1a3a5c; }
.card { background: #fff; border-radius: 10px; border: 1px solid #e0e6ed; padding: 18px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; color: #1a3a5c; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-box { background: #fff; border-radius: 10px; border: 1px solid #e0e6ed; padding: 16px; text-align: center; }
.stat-val { font-size: 22px; font-weight: 600; color: #1a3a5c; }
.stat-lbl { font-size: 11px; color: #888; margin-top: 3px; }
.stat-box.green .stat-val { color: #1e8449; }
.stat-box.orange .stat-val { color: #d35400; }
.stat-box.red .stat-val { color: #c0392b; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
table th { background: #f5f7fa; padding: 9px 10px; text-align: left; font-size: 11px; font-weight: 600; color: #555; border-bottom: 1px solid #e0e6ed; white-space: nowrap; }
table td { padding: 8px 10px; border-bottom: 1px solid #f0f4f8; vertical-align: middle; }
table tr:hover td { background: #fafbfc; }
.badge { padding: 2px 9px; border-radius: 12px; font-size: 10px; font-weight: 600; display: inline-block; }
.badge-paid, .badge-approved { background: #d5f5e3; color: #1e8449; }
.badge-pending { background: #fdebd0; color: #d35400; }
.badge-draft { background: #eaecee; color: #555; }
.badge-fbr { background: #d6eaf8; color: #1a5276; }
.badge-overdue { background: #fadbd8; color: #c0392b; }

/* ===== FORMS ===== */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.form-col { flex: 1; min-width: 130px; }
.form-col label { display: block; font-size: 11px; font-weight: 500; color: #555; margin-bottom: 4px; }
.form-col input, .form-col select, .form-col textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 12px; outline: none; transition: border 0.2s; background: #fff; color: #1a2332;
}
.form-col input:focus, .form-col select:focus, .form-col textarea:focus { border-color: #1a3a5c; }
.form-col textarea { resize: vertical; min-height: 60px; }
.section-divider { font-size: 12px; font-weight: 600; color: #1a3a5c; margin: 14px 0 8px; padding-bottom: 5px; border-bottom: 1px solid #e0e6ed; }

/* ===== ITEM ROWS ===== */
.item-header { display: flex; gap: 8px; font-size: 10px; font-weight: 600; color: #888; margin-bottom: 4px; padding: 0 4px; }
.item-header span { flex: 1; }
.item-header .ih-qty { flex: 0.4; min-width: 50px; }
.item-header .ih-rate { flex: 0.8; min-width: 80px; }
.item-header .ih-tax { flex: 0.4; min-width: 50px; }
.item-header .ih-amt { flex: 0.8; min-width: 80px; }
.item-header .ih-del { width: 28px; flex-shrink: 0; }
.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.item-row input { flex: 1; min-width: 80px; padding: 6px 8px; border: 1px solid #ddd; border-radius: 5px; font-size: 12px; }
.item-row .i-desc { flex: 3; min-width: 150px; }
.item-row .i-qty { flex: 0.4; min-width: 50px; }
.item-row .i-rate { flex: 0.8; min-width: 80px; }
.item-row .i-tax { flex: 0.4; min-width: 50px; }
.item-row .i-amt { flex: 0.8; min-width: 80px; background: #f8f9fa; }
.del-btn { width: 26px; height: 26px; background: #fadbd8; color: #c0392b; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.totals-box { display: flex; justify-content: flex-end; margin-top: 10px; }
.totals-inner { min-width: 240px; }
.total-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.grand-total { display: flex; justify-content: space-between; font-size: 15px; font-weight: 600; color: #1a3a5c; border-top: 2px solid #1a3a5c; padding-top: 6px; margin-top: 4px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}
.modal-lg { max-width: 900px; }
.modal-md { max-width: 560px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #e0e6ed; position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: #1a3a5c; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #888; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: #f0f4f8; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #e0e6ed; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ===== INVOICE PRINT ===== */
.inv-doc { background: #fff; padding: 30px; color: #000; font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; }
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; border-bottom: 3px solid #1a3a5c; padding-bottom: 16px; }
.inv-logo-area { display: flex; flex-direction: column; }
.inv-logo-box { width: 60px; height: 60px; background: #1a3a5c; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.inv-logo-box span { font-size: 18px; font-weight: 700; color: #fff; line-height: 1; }
.inv-logo-box small { font-size: 7px; color: rgba(255,255,255,0.8); letter-spacing: 1px; }
.inv-comp-name { font-size: 14px; font-weight: 700; color: #1a3a5c; margin-top: 6px; }
.inv-comp-addr { font-size: 9px; color: #555; line-height: 1.6; max-width: 210px; margin-top: 2px; }
.inv-right { text-align: right; }
.inv-doc-type { font-size: 26px; font-weight: 700; color: #1a3a5c; }
.inv-doc-badge { background: #1a3a5c; color: #fff; padding: 3px 14px; border-radius: 4px; font-size: 12px; display: inline-block; margin-top: 4px; }
.inv-doc-date { font-size: 11px; color: #555; margin-top: 6px; }
.inv-parties { display: flex; gap: 12px; margin-bottom: 16px; }
.inv-party-box { flex: 1; background: #f0f4f8; border-radius: 6px; padding: 10px 12px; border-left: 3px solid #1a3a5c; font-size: 11px; }
.inv-party-box strong { display: block; font-size: 10px; color: #1a3a5c; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
table.inv-items { width: 100%; border-collapse: collapse; font-size: 11px; margin-bottom: 14px; }
table.inv-items th { background: #1a3a5c; color: #fff; padding: 7px 8px; text-align: left; }
table.inv-items td { padding: 6px 8px; border-bottom: 1px solid #eee; }
table.inv-items tr:nth-child(even) td { background: #f8f9fa; }
.inv-totals-wrap { display: flex; justify-content: flex-end; }
.inv-totals-table { min-width: 220px; font-size: 12px; }
.inv-totals-table .itr { display: flex; justify-content: space-between; padding: 3px 0; }
.inv-totals-table .itr-grand { display: flex; justify-content: space-between; padding: 6px 0 0; font-size: 14px; font-weight: 700; color: #1a3a5c; border-top: 2px solid #1a3a5c; margin-top: 4px; }
.inv-fbr { background: #1a3a5c; color: #fff; border-radius: 6px; padding: 10px 14px; display: flex; align-items: center; gap: 14px; margin-top: 14px; font-size: 10px; }
.inv-qr { width: 64px; height: 64px; background: #fff; border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.inv-fbr-info { flex: 1; }
.inv-fbr-info strong { font-size: 12px; display: block; margin-bottom: 3px; }
.inv-footer-bar { margin-top: 12px; padding-top: 8px; border-top: 1px solid #ddd; font-size: 9px; color: #888; text-align: center; line-height: 1.6; }

/* ===== FBR PAGE ===== */
.fbr-status-card { background: #1a3a5c; color: #fff; border-radius: 10px; padding: 18px; margin-bottom: 14px; }
.fbr-status-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.fbr-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.fbr-stat { text-align: center; }
.fbr-stat-val { font-size: 20px; font-weight: 600; }
.fbr-stat-lbl { font-size: 10px; opacity: 0.8; margin-top: 2px; }

/* ===== UTILS ===== */
.flex-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.text-right { text-align: right; }
.text-muted { color: #888; font-size: 11px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.green { color: #1e8449; }
.red { color: #c0392b; }
.search-bar { padding: 7px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 12px; outline: none; width: 180px; }
.search-bar:focus { border-color: #1a3a5c; }
.alert { padding: 10px 14px; border-radius: 6px; font-size: 12px; margin-bottom: 12px; }
.alert-success { background: #d5f5e3; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-error { background: #fadbd8; color: #c0392b; border: 1px solid #f1948a; }
.alert-info { background: #d6eaf8; color: #1a5276; border: 1px solid #7fb3d3; }
.empty-state { text-align: center; padding: 40px 20px; color: #888; }
.empty-state .es-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-230px); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .content { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .fbr-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== PRINT ===== */
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .inv-doc { padding: 15px; }
}
