:root {
  --sidebar-bg: #0f1c2e;
  --sidebar-hover: #1e3a5f;
  --sidebar-active: #1e5799;
  --sidebar-text: #c8d8ea;
  --sidebar-muted: #7a9bb5;
  --sidebar-width: 250px;
  --topbar-h: 58px;
  --accent: #1e5799;
  --accent-light: #2980d9;
  --content-bg: #f0f4f8;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--content-bg); color: var(--text-primary); font-size: 13.5px; }

/* ── SIDEBAR ── */
#sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width);
  height: 100vh; background: var(--sidebar-bg); overflow-y: auto;
  z-index: 1000; display: flex; flex-direction: column;
  transition: width .25s;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: #2d4a6e; border-radius: 4px; }

.sidebar-brand {
  padding: 16px 18px 14px; border-bottom: 1px solid #1a3050;
  display: flex; align-items: center; gap: 10px;
}
.brand-icon {
  width: 36px; height: 36px; background: var(--accent-light);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
}
.brand-text { color: #fff; }
.brand-text .name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.brand-text .sub { font-size: 10px; color: var(--sidebar-muted); letter-spacing: .5px; }

.nav-section { padding: 10px 0 4px; }
.nav-label {
  padding: 6px 18px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--sidebar-muted);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; color: var(--sidebar-text); text-decoration: none;
  cursor: pointer; border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; border-left-color: #5aabff; font-weight: 600; }
.nav-item i { width: 18px; font-size: 13px; text-align: center; opacity: .85; }
.nav-item span { font-size: 13px; }

.sidebar-footer {
  margin-top: auto; padding: 12px 18px;
  border-top: 1px solid #1a3050; color: var(--sidebar-muted); font-size: 12px;
}

/* ── TOPBAR ── */
#topbar {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0;
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  gap: 16px; z-index: 999; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
#page-title { font-size: 16px; font-weight: 700; color: var(--text-primary); flex: 1; }
.topbar-btn {
  padding: 6px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 6px; font-size: 12.5px; cursor: pointer; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px; transition: all .15s;
}
.topbar-btn:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--text-primary); }
.topbar-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.topbar-btn.primary:hover { background: var(--accent-light); }
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; cursor: pointer;
}

/* ── MAIN CONTENT ── */
#main {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.content-inner { padding: 22px 24px; }

/* ── CARDS ── */
.card {
  background: var(--card-bg); border-radius: 10px;
  border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13.5px; display: flex; align-items: center;
  gap: 8px; color: var(--text-primary);
}
.card-body { padding: 18px; }

/* ── KPI CARDS ── */
.kpi-card {
  background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border);
  padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  position: relative; overflow: hidden;
}
.kpi-card .kpi-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
}
.kpi-card .kpi-value { font-size: 22px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.kpi-card .kpi-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.kpi-card .kpi-change { font-size: 11px; margin-top: 6px; }
.kpi-card .kpi-change.up { color: var(--success); }
.kpi-card .kpi-change.down { color: var(--danger); }
.kpi-blue .kpi-icon { background: #dbeafe; color: #1d4ed8; }
.kpi-green .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-orange .kpi-icon { background: #fef3c7; color: #d97706; }
.kpi-red .kpi-icon { background: #fee2e2; color: #dc2626; }
.kpi-purple .kpi-icon { background: #ede9fe; color: #7c3aed; }
.kpi-cyan .kpi-icon { background: #cffafe; color: #0891b2; }

/* ── TABLES ── */
.tbl-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table thead th {
  background: #f8fafc; padding: 10px 12px; font-weight: 600;
  border-bottom: 2px solid var(--border); color: var(--text-secondary);
  text-transform: uppercase; font-size: 11px; letter-spacing: .4px;
  white-space: nowrap;
}
table.data-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ── BADGES / STATUS ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-posted { background: #dcfce7; color: #15803d; }
.badge-fbr-ok { background: #d1fae5; color: #065f46; }
.badge-fbr-fail { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-cancelled { background: #fce7f3; color: #9d174d; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-info { background: #cffafe; color: #0e7490; }

/* ── TOOLBAR ── */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 18px; background: #fff; border-radius: 10px;
  border: 1px solid var(--border); margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.toolbar-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.btn {
  padding: 6px 14px; border-radius: 6px; font-size: 12.5px;
  font-weight: 500; cursor: pointer; border: 1px solid transparent;
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: #fff; color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }
.search-box {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 10px; background: #fff; min-width: 220px;
}
.search-box input { border: none; outline: none; font-size: 12.5px; width: 100%; }
.search-box i { color: var(--text-secondary); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .3px; }
.form-control {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; color: var(--text-primary);
  transition: border .15s; outline: none; background: #fff;
}
.form-control:focus { border-color: var(--accent-light); box-shadow: 0 0 0 3px rgba(41,128,217,.1); }
.form-control[readonly] { background: #f8fafc; color: var(--text-secondary); }
select.form-control { cursor: pointer; }
.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-row.cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ── INVOICE FORM SPECIFIC ── */
.inv-header { background: #fff; border-radius: 10px; border: 1px solid var(--border); padding: 18px; margin-bottom: 14px; }
.inv-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.inv-section-title::after { content: ''; flex: 1; height: 1px; background: #e8f0fb; }
.line-items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.line-items-table th { background: #f0f6ff; padding: 8px 8px; border: 1px solid #dde5f0; font-weight: 600; text-align: center; font-size: 11px; color: #374151; white-space: nowrap; }
.line-items-table td { border: 1px solid #e8eef5; padding: 4px; }
.line-items-table td input, .line-items-table td select { width: 100%; border: none; padding: 5px 6px; font-size: 12px; background: transparent; outline: none; }
.line-items-table td input:focus, .line-items-table td select:focus { background: #eff6ff; border-radius: 3px; }
.line-items-table .line-no { text-align: center; color: var(--text-secondary); width: 36px; }
.totals-box { background: #f0f6ff; border: 1px solid #c7dcf8; border-radius: 8px; padding: 16px; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.total-row.grand { border-top: 2px solid var(--accent); margin-top: 8px; padding-top: 10px; font-size: 15px; font-weight: 700; color: var(--accent); }
.total-row label { color: var(--text-secondary); }
.total-row span { font-weight: 600; font-family: 'Courier New', monospace; }

/* ── STATUS TRACKER ── */
.status-steps { display: flex; align-items: center; gap: 0; flex-wrap: wrap; margin-bottom: 14px; }
.step { display: flex; align-items: center; gap: 6px; padding: 6px 14px; background: #f1f5f9; font-size: 11.5px; color: #64748b; border: 1px solid #e2e8f0; }
.step:first-child { border-radius: 6px 0 0 6px; }
.step:last-child { border-radius: 0 6px 6px 0; }
.step.done { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.step.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.step.fail { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.step i { font-size: 12px; }

/* ── TABS ── */
.tab-bar { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab-btn {
  padding: 9px 18px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s;
}
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 2000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-height: 90vh; overflow-y: auto; width: 95%; max-width: 700px;
}
.modal-box.modal-lg { max-width: 980px; }
.modal-box.modal-xl { max-width: 1200px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 14.5px; position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-secondary); line-height: 1; border: none; background: none; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── FBR STATUS ── */
.fbr-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.fbr-submitted { background: #d1fae5; color: #065f46; }
.fbr-pending { background: #fef3c7; color: #92400e; }
.fbr-failed { background: #fee2e2; color: #991b1b; }
.fbr-none { background: #f1f5f9; color: #475569; }

/* ── CHART CONTAINERS ── */
.chart-container { position: relative; height: 240px; }

/* ── PAGINATION ── */
.pager { display: flex; align-items: center; gap: 4px; }
.page-btn { padding: 5px 10px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; font-size: 12px; color: var(--text-secondary); transition: all .15s; }
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── MISC ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 11.5px; }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 20px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
.grid-6 { grid-template-columns: repeat(6, 1fr); gap: 16px; }
.full-span { grid-column: 1 / -1; }
.color-success { color: var(--success); }
.color-danger { color: var(--danger); }
.color-warning { color: var(--warning); }
.color-accent { color: var(--accent); }
.bg-light { background: #f8fafc; }
.rounded { border-radius: 8px; }
.p-3 { padding: 12px; }
.border { border: 1px solid var(--border); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 40px; margin-bottom: 10px; display: block; opacity: .35; }
.empty-state p { font-size: 13px; }
.action-btns { display: flex; gap: 4px; justify-content: center; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh; background: linear-gradient(135deg, #0f1c2e 0%, #1a3a6e 60%, #1e5799 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.35);
  width: 100%; max-width: 420px; padding: 40px;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 64px; height: 64px; background: var(--accent); border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff; margin-bottom: 12px;
}
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text-primary); margin: 0 0 4px; }
.login-logo p { font-size: 12px; color: var(--text-secondary); margin: 0; }
.login-hint {
  background: #f0f6ff; border: 1px solid #c7dcf8; border-radius: 8px;
  padding: 10px 14px; font-size: 12px; color: #1e40af; margin-top: 18px;
}
.login-hint strong { display: block; margin-bottom: 2px; }

/* ── ALERT ── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  :root { --sidebar-width: 200px; }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  :root { --sidebar-width: 0px; }
  #sidebar { transform: translateX(-100%); }
  .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
  .grid-6, .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ── COMPANY SETTINGS TABS ── */
.settings-tab-content { display: none; }
.settings-tab-content.active { display: block; }

/* ── CHART OF ACCOUNTS ── */
.account-type-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.at-asset { background: #dbeafe; color: #1d4ed8; }
.at-liability { background: #fce7f3; color: #9d174d; }
.at-equity { background: #ede9fe; color: #7c3aed; }
.at-income { background: #dcfce7; color: #15803d; }
.at-expense { background: #fef3c7; color: #92400e; }

/* ── NOTIFICATION DOT ── */
.notif-dot {
  display: inline-block; width: 18px; height: 18px; background: #ef4444;
  color: #fff; border-radius: 50%; font-size: 10px; font-weight: 700;
  text-align: center; line-height: 18px; margin-left: auto;
}

/* ── PROGRESS BAR ── */
.prog-bar { height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.prog-fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* FBR connection indicator */
.conn-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.conn-ok { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.conn-err { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.2); }
.conn-idle { background: #94a3b8; }
