*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#F8FAFC;--surface:#fff;--border:#E2E8F0;--text:#0F172A;--muted:#64748B;
  --primary:#2563EB;--primary-h:#1D4ED8;--primary-light:#EFF6FF;
  --success:#16A34A;--warn:#D97706;--danger:#DC2626;
  --radius:10px;--shadow:0 1px 3px rgba(0,0,0,.07),0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:0 10px 30px rgba(0,0,0,.1);
}
body{font-family:'DM Sans',sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.6;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
#app{display:flex;min-height:100vh}

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar{width:228px;background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;padding:16px 0 20px;flex-shrink:0;overflow-y:auto}
.logo{display:flex;align-items:center;gap:10px;padding:0 16px 20px;font-weight:700;font-size:15px;letter-spacing:-.2px}
.sidebar nav{display:flex;flex-direction:column;gap:1px;padding:0 8px}
.sidebar nav a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;text-decoration:none;color:var(--muted);font-weight:500;font-size:13.5px;transition:all .12s}
.sidebar nav a:hover{background:#F1F5F9;color:var(--text)}
.sidebar nav a.active{background:var(--primary-light);color:var(--primary);font-weight:600}
.nav-section{font-size:10px;font-weight:700;letter-spacing:.08em;color:#CBD5E1;padding:10px 10px 4px;text-transform:uppercase}
.icon{font-size:15px;width:20px;text-align:center;flex-shrink:0}

/* ── CONTENT ─────────────────────────────────── */
.content{flex:1;overflow-y:auto;min-width:0}
.page{display:none;padding:28px 32px}
.page.active{display:block;animation:dash-fade-up 300ms cubic-bezier(.16,1,.3,1) forwards}

/* ── PAGE HEADER ─────────────────────────────── */
.page-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:24px;gap:12px}
.page-header h1{font-size:22px;font-weight:600;letter-spacing:-.35px}

/* ── BUTTONS ─────────────────────────────────── */
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 16px;border-radius:8px;border:none;cursor:pointer;font-size:13px;font-weight:500;font-family:inherit;transition:all .12s;white-space:nowrap}
.btn-primary{background:var(--primary);color:#fff}.btn-primary:hover{background:var(--primary-h)}
.btn-secondary{background:var(--surface);color:var(--text);border:1px solid var(--border)}.btn-secondary:hover{background:var(--bg)}
.btn-success{background:var(--success);color:#fff}.btn-success:hover{filter:brightness(.92)}
.btn-danger{background:var(--danger);color:#fff}.btn-danger:hover{filter:brightness(.92)}
.btn-sm{padding:5px 10px;font-size:12px;border-radius:6px}
.btn-icon{background:none;border:none;cursor:pointer;padding:4px 6px;font-size:17px;color:var(--muted);line-height:1;border-radius:4px}
.btn-icon:hover{background:var(--bg)}
.actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}

/* ── CARDS ───────────────────────────────────── */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px;box-shadow:var(--shadow);transition:box-shadow .15s,transform .15s}
.card:hover{box-shadow:var(--shadow-lg);transform:translateY(-1px)}
.stat-card{transition:box-shadow .15s,transform .15s}
.stat-card:hover{box-shadow:var(--shadow-lg);transform:translateY(-1px)}
.settings-grid{display:flex;flex-direction:column;gap:20px;max-width:700px}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:24px}
.stat-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px;box-shadow:var(--shadow);position:relative;overflow:hidden}
.stat-card::before{content:'';position:absolute;left:0;top:0;bottom:0;width:4px}
.stat-card.green::before{background:var(--success)}.stat-card.green .value{color:var(--success)}
.stat-card.amber::before{background:var(--warn)}.stat-card.amber .value{color:var(--warn)}
.stat-card.red::before{background:var(--danger)}.stat-card.red .value{color:var(--danger)}
.stat-card.blue::before{background:var(--primary)}.stat-card.blue .value{color:var(--primary)}
.stat-card .label{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.stat-card .value{font-size:26px;font-weight:700;margin-top:6px;font-family:'DM Mono',monospace;letter-spacing:-.5px}
.stat-card .sub{font-size:12px;color:var(--muted);margin-top:4px}

/* ── TABLE ───────────────────────────────────── */
.table-wrap{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:auto;box-shadow:var(--shadow);-webkit-overflow-scrolling:touch}
table{width:100%;border-collapse:collapse}
th{background:#F8FAFC;padding:10px 14px;text-align:left;font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--border);position:sticky;top:0;z-index:1}
td{padding:11px 14px;border-bottom:1px solid #F1F5F9;vertical-align:middle;font-size:13.5px}
tr:last-child td{border-bottom:none}
tr:hover td{background:#FAFBFC}

/* Form validation */
input:invalid:not(:placeholder-shown), select:invalid:not(:placeholder-shown){border-color:#fca5a5}
input:invalid:not(:placeholder-shown):focus, select:invalid:not(:placeholder-shown):focus{box-shadow:0 0 0 3px rgba(220,38,38,.08)}
.field-error{font-size:12px;color:#dc2626;margin-top:4px}

/* ── BADGES ──────────────────────────────────── */
.badge{display:inline-flex;align-items:center;padding:3px 9px;border-radius:20px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em}
.badge-paid{background:#DCFCE7;color:#15803D}
.badge-unpaid{background:#FEF3C7;color:#92400E}
.badge-overdue{background:#FEE2E2;color:#991B1B}
.badge-converted{background:#E0E7FF;color:#3730A3}
.badge-pending{background:#F1F5F9;color:var(--muted)}
.badge-received{background:#DCFCE7;color:#15803D}
.badge-active{background:#DCFCE7;color:#15803D}
.badge-inactive{background:#FEE2E2;color:#991B1B}
.badge-draft{background:#F1F5F9;color:#475569}
.badge-sent{background:#E0E7FF;color:#3730A3}
.badge-partial{background:#FEF3C7;color:#92400E}
.badge-void{background:#FEE2E2;color:#991B1B}
.badge-cancelled{background:#F1F5F9;color:#64748B}
.badge-archived{background:#F1F5F9;color:#64748B}
.badge-discontinued{background:#F1F5F9;color:#64748B}
.badge-approved{background:#DCFCE7;color:#15803D}
.badge-expired{background:#FEE2E2;color:#991B1B}

/* ── VOID & FADED ROWS ───────────────────────── */
tr.row-void td{opacity:.55}
tr.row-void:hover td{background:transparent}
.void-watermark{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) rotate(-30deg);font-size:96px;font-weight:900;color:rgba(220,38,38,.15);pointer-events:none;z-index:10;letter-spacing:8px;text-transform:uppercase;user-select:none}

/* ── FORMS ───────────────────────────────────── */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-group{display:flex;flex-direction:column;gap:5px}
.form-group.full{grid-column:1/-1}
label{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
input,select,textarea{padding:8px 11px;border:1px solid var(--border);border-radius:7px;font-family:inherit;font-size:13.5px;color:var(--text);background:var(--surface);width:100%;outline:none;transition:border .12s}
input:focus,select:focus,textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.1)}
textarea{resize:vertical;min-height:72px}
.input-action{display:flex;gap:6px;align-items:center}
.input-action input{flex:1}
.field-help{font-size:11px;color:var(--muted);margin-top:3px}

/* ── ITEMS TABLE ─────────────────────────────── */
.items-section{margin-top:22px}
.items-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;flex-wrap:wrap;gap:8px}
.items-header h4{font-size:12px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:0}
.gst-toggle{display:flex;gap:18px}
.gst-toggle label{text-transform:none;font-size:13px;font-weight:400;display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--text)}
.table-scroll{overflow-x:auto}
.items-table{width:100%;border-collapse:collapse;margin-bottom:8px;min-width:960px;table-layout:fixed}
.items-table th{background:#F8FAFC;padding:8px 8px;font-size:11px;text-align:left;border:1px solid var(--border);color:var(--muted);font-weight:700;text-transform:uppercase;white-space:nowrap}
.items-table td{padding:5px 6px;border:1px solid var(--border);vertical-align:middle}
.items-table input,.items-table select{border:none;background:transparent;padding:7px 8px;font-size:13px;border-radius:4px}
.items-table input:focus,.items-table select:focus{background:#EFF6FF;outline:none;box-shadow:inset 0 0 0 1px var(--primary)}
.discount-field{display:grid;grid-template-columns:minmax(0,1fr) 46px;align-items:center;gap:6px;width:100%}
.discount-field input,.discount-field select{width:100%;min-width:0}
.discount-field input{min-width:0;padding:7px 8px;font-size:13px}
.discount-field .discount-type{font-weight:700;text-align:center;cursor:pointer;padding:7px 4px}
.items-table .line-serial{text-align:center;color:var(--muted);font-family:'DM Mono',monospace;font-size:12px}
.items-table th:nth-child(1),.items-table td:nth-child(1){text-align:center}
.items-table th:nth-child(5),.items-table td:nth-child(5),
.items-table th:nth-child(6),.items-table td:nth-child(6),
.items-table th:nth-child(7),.items-table td:nth-child(7),
.items-table th:nth-child(8),.items-table td:nth-child(8),
.items-table th:nth-child(10),.items-table td:nth-child(10){text-align:right}
.totals-box{display:flex;justify-content:flex-end;margin-top:12px}
.totals-inner{min-width:260px;background:#F8FAFC;border:1px solid var(--border);border-radius:8px;overflow:hidden}
.totals-inner .row{display:flex;justify-content:space-between;padding:8px 14px;border-bottom:1px solid var(--border);font-size:13px}
.totals-inner .row:last-child{border-bottom:none;font-weight:700;font-size:15px;background:var(--primary-light);color:var(--primary)}

/* ── AUTOCOMPLETE ────────────────────────────── */
.ac-drop{position:absolute;top:100%;left:0;right:0;background:#fff;border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow-lg);z-index:200;max-height:240px;overflow-y:auto}
.ac-item{padding:9px 12px;cursor:pointer;border-bottom:1px solid #F1F5F9}
.ac-item:last-child{border-bottom:none}
.ac-item:hover{background:var(--primary-light)}
.ac-name{font-size:13px;font-weight:600;color:var(--text)}
.ac-sub{font-size:11px;color:var(--muted);margin-top:2px}

/* ── MODAL ───────────────────────────────────── */
#modal-overlay{
  position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:100;
  display:flex;align-items:center;justify-content:center;padding:20px;
  opacity:0;visibility:hidden;transition:opacity .2s ease,visibility .2s ease;
  backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);
}
#modal-overlay.hidden{opacity:0;visibility:hidden}
#modal-overlay:not(.hidden){opacity:1;visibility:visible}
.modal{
  background:var(--surface);border-radius:16px;width:100%;max-width:860px;max-height:92vh;
  overflow-y:auto;box-shadow:0 25px 80px rgba(0,0,0,.15);
  transform:scale(.96) translateY(10px);transition:transform .25s cubic-bezier(.16,1,.3,1);
}
.modal.visible{transform:scale(1) translateY(0)}
.modal-header{display:flex;justify-content:space-between;align-items:center;padding:18px 24px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:1}
.modal-header h3{font-size:17px;font-weight:700}
#modal-body{padding:24px}
.modal-footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 0 0;border-top:1px solid var(--border);margin-top:16px}

/* ── SAVE SUCCESS ────────────────────────────── */
.save-success{display:flex;align-items:center;gap:16px;padding:16px 0}
.save-icon{width:52px;height:52px;background:#DCFCE7;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:24px;color:var(--success);flex-shrink:0}
.save-success h3{font-size:16px;font-weight:600;margin-bottom:4px}
.save-success p{font-size:13px;color:var(--muted)}

/* ── SETTINGS ────────────────────────────────── */
.logo-settings{display:flex;align-items:flex-start;gap:20px;padding:16px 0}
.logo-preview{width:90px;height:70px;border:2px dashed var(--border);border-radius:8px;display:flex;align-items:center;justify-content:center;background:var(--bg);color:var(--muted);font-size:11px;flex-shrink:0;overflow:hidden}
.logo-preview img{max-width:100%;max-height:100%;object-fit:contain}

/* ── PRINT / INVOICE DOC ─────────────────────── */
#print-area{display:none}

.invoice-doc{position:relative;max-width:880px;margin:0 auto;padding:42px 46px;background:#fff;color:#0F172A;font-family:'Inter','Roboto','DM Sans',Arial,sans-serif;font-size:12.5px;line-height:1.5;border-radius:12px;box-shadow:0 18px 48px rgba(15,23,42,.14)}
.invoice-doc .inv-header{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:34px;align-items:start;padding-bottom:22px;margin-bottom:20px;border-bottom:3px solid var(--primary)}
.invoice-doc .brand-block{display:flex;align-items:center;gap:16px;min-width:0}
.invoice-doc .invoice-logo{display:block;height:75px;max-height:80px;max-width:210px;width:auto;object-fit:contain;object-position:left center;padding:3px 0;flex-shrink:0}
.invoice-doc .logo-fallback{max-width:220px;padding:14px 18px;background:var(--primary);color:#fff;border-radius:10px;font-size:18px;font-weight:800;line-height:1.2}
.invoice-doc .company-block{min-width:0}
.invoice-doc .company-name{font-size:22px;font-weight:800;color:var(--primary);line-height:1.18}
.invoice-doc .company-details{max-width:430px;margin-top:8px;color:#475569;font-size:11.5px;line-height:1.65}
.invoice-doc .inv-meta{text-align:right;min-width:230px}
.invoice-doc .doc-label{display:inline-block;margin-bottom:8px;padding:6px 11px;border-radius:999px;background:var(--primary-light);color:var(--primary);font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.invoice-doc .inv-no{font-family:'DM Mono',monospace;font-size:25px;font-weight:800;color:#1D4ED8;line-height:1.2}
.invoice-doc .hero-total{margin:12px 0 10px;padding:13px 15px;border-radius:10px;background:linear-gradient(135deg,#2563EB,#1E40AF);color:#fff;box-shadow:0 10px 22px rgba(37,99,235,.22)}
.invoice-doc .hero-total span{display:block;margin-bottom:2px;font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;opacity:.85}
.invoice-doc .hero-total strong{display:block;font-family:'DM Mono',monospace;font-size:20px;font-weight:800;line-height:1.25}
.invoice-doc .meta-grid{display:grid;grid-template-columns:auto auto;gap:4px 12px;justify-content:end;margin-top:8px;color:#64748B;font-size:11.5px}
.invoice-doc .meta-grid strong{color:#0F172A;font-weight:700}
.invoice-doc .invoice-badges{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:20px}
.invoice-doc .invoice-badges span{display:inline-flex;gap:8px;align-items:center;padding:8px 12px;background:#fff;border:1px solid #E5E7EB;border-radius:999px;color:#334155;font-size:11.5px;box-shadow:0 4px 12px rgba(15,23,42,.04)}
.invoice-doc .invoice-badges strong{color:#64748B;font-size:10px;text-transform:uppercase;letter-spacing:.05em}
.invoice-doc .parties{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-bottom:20px}
.invoice-doc .party-box{padding:16px 18px;background:#fff;border:1px solid #E5E7EB;border-radius:10px;min-height:118px;box-shadow:0 7px 18px rgba(15,23,42,.05)}
.invoice-doc .party-box h4{margin-bottom:8px;color:#64748B;font-size:10px;font-weight:800;letter-spacing:.08em}
.invoice-doc .party-box strong{display:block;margin-bottom:4px;color:#0F172A;font-size:14px;font-weight:800}
.invoice-doc .party-box span{display:block;color:#475569;font-size:11.5px;line-height:1.7}
.invoice-doc .inv-table{width:100%;border-collapse:collapse;border-spacing:0;margin-bottom:20px;border:1px solid #000;table-layout:fixed}
.invoice-doc .inv-table th{padding:10px;background:var(--primary);color:#fff;border:1px solid #000;font-size:10px;font-weight:800;text-align:left;text-transform:uppercase;letter-spacing:.05em;white-space:nowrap}
.invoice-doc .inv-table td{padding:10px;border:1px solid #000;color:#1F2937;font-size:12px;vertical-align:top}
.invoice-doc .inv-table tr:nth-child(even) td{background:#FAFBFC}
.invoice-doc .item-desc{min-width:210px;font-weight:600;color:#111827}
.invoice-doc .text-right{text-align:right}
.invoice-doc .text-center{text-align:center}
.invoice-doc .invoice-bottom{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:24px;align-items:start;margin-bottom:24px}
.invoice-doc .invoice-notes{color:#475569;font-size:12px}
.invoice-doc .amount-words,.invoice-doc .bank-box,.invoice-doc .notes-block{margin-bottom:12px;padding:16px 18px;background:#fff;border:1px solid #E5E7EB;border-radius:10px;box-shadow:0 7px 18px rgba(15,23,42,.05)}
.invoice-doc .amount-words strong,.invoice-doc .bank-box strong{display:block;margin-bottom:4px;color:#0F172A;font-size:11px;text-transform:uppercase;letter-spacing:.05em}
.invoice-doc .amount-words span,.invoice-doc .bank-box span{display:block}
.invoice-doc .inv-summary{overflow:hidden;background:#fff;border:1px solid #E5E7EB;border-radius:10px;box-shadow:0 8px 22px rgba(15,23,42,.07)}
.invoice-doc .summary-row{display:flex;justify-content:space-between;gap:14px;padding:11px 16px;border-bottom:1px solid #E5E7EB;font-size:12.5px}
.invoice-doc .summary-row span{color:#64748B}
.invoice-doc .summary-row strong{font-family:'DM Mono',monospace;color:#0F172A}
.invoice-doc .summary-total{display:flex;justify-content:space-between;gap:14px;padding:15px 16px;background:linear-gradient(135deg,#2563EB,#1E40AF);color:#fff;font-size:18px;font-weight:800}
.invoice-doc .summary-total strong{font-family:'DM Mono',monospace;color:#fff}
.invoice-doc .signature-row{display:flex;justify-content:space-between;align-items:flex-end;margin:18px 0 16px;padding-top:6px}
.invoice-doc .signature-box{min-width:210px;text-align:center;color:#475569;font-size:12px}
.invoice-doc .sig-line{width:170px;margin:42px auto 7px;border-top:1px solid #94A3B8}
.invoice-doc .footer-note{padding-top:14px;border-top:1px solid #E2E8F0;text-align:center;color:#94A3B8;font-size:11px}
.invoice-doc .status-stamp{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) rotate(-30deg);font-size:72px;font-weight:900;opacity:.06;pointer-events:none;color:#16A34A;white-space:nowrap;letter-spacing:.1em}

@page{size:A4;margin:20mm}
@media print {
  html,body{background:#fff!important}
  body > *{display:none!important}
  #print-area{display:block!important}
  #print-area .invoice-doc{display:block!important}
  .no-print,.modal,.modal-footer,#modal-overlay{display:none!important}
  .invoice-doc{max-width:none;width:100%;margin:0;padding:0;border-radius:0;box-shadow:none;print-color-adjust:exact;-webkit-print-color-adjust:exact}
  .invoice-doc .inv-table tr,.invoice-doc .party-box,.invoice-doc .inv-summary,.invoice-doc .amount-words,.invoice-doc .bank-box,.invoice-doc .signature-row{break-inside:avoid;page-break-inside:avoid}
  .invoice-doc .inv-table thead{display:table-header-group}
  .invoice-doc .inv-table tfoot{display:table-footer-group}
}

/* GST Invoice — shared base + multi-template */
#modal-body > div[style]:has(.gst-invoice){padding:0!important;background:#fff!important;border-radius:0!important;overflow:auto!important}
.modal:has(.gst-invoice){max-width:960px;border-radius:8px}
.modal:has(.gst-invoice) .modal-header{padding:12px 16px}
.modal:has(.gst-invoice) .modal-header h3{font-size:13px}
.modal:has(.gst-invoice) #modal-body{padding:12px 24px 14px}
.modal:has(.gst-invoice) .modal-footer{padding:12px 0 0;margin-top:16px}
.invoice-doc.gst-invoice{
  width:100%;max-width:100%;margin:0 auto;padding:0;
  background:#fff;color:#1e293b;
  font-family:'Inter',Arial,Helvetica,sans-serif;
  font-size:11px;line-height:1.4;
  border:1px solid #cbd5e1;border-radius:0;
  box-shadow:none;overflow:hidden;
}
.invoice-doc.gst-invoice,.invoice-doc.gst-invoice *{box-shadow:none;text-shadow:none}

/* ── Header (shared across all templates) ── */
.gst-invoice .invoice-header{display:flex;justify-content:space-between;align-items:center;width:100%;min-height:142px;border-bottom:1px solid #e2e8f0;padding:14px 18px;gap:0;page-break-inside:avoid;break-inside:avoid}
.gst-invoice .header-left,.gst-invoice .header-center,.gst-invoice .header-right{display:flex;align-items:center;min-height:120px;min-width:0;overflow:hidden}
.gst-invoice .header-left,.gst-invoice .header-right{width:20%;justify-content:center;text-align:center}
.gst-invoice .header-right{flex-direction:column;gap:4px}
.gst-invoice .header-center{width:60%;justify-content:center;text-align:center;flex-direction:column;padding:0 12px;word-wrap:break-word;overflow-wrap:anywhere}
.gst-invoice .gst-logo{display:block;width:auto;max-width:100%;height:auto;max-height:118px;object-fit:contain;object-position:center;margin:0 auto}
.gst-invoice .gst-logo-fallback{width:120px;height:86px;border:1px solid #e2e8f0;border-radius:8px;display:flex;align-items:center;justify-content:center;margin:0 auto;font-size:18px;font-weight:700;color:#334155}
.gst-invoice .gst-title{font-size:11px;font-weight:700;text-transform:uppercase;margin:0 0 8px;color:#64748b;letter-spacing:.08em}
.gst-invoice .gst-company-name{max-width:100%;font-size:20px;font-weight:800;text-transform:uppercase;line-height:1.1;margin:0 0 6px;overflow-wrap:anywhere;color:#0f172a}
.gst-invoice .header-center p{margin:2px 0;font-size:12px;line-height:1.25;color:#334155}
.gst-invoice .qr-code{position:relative;width:96px;height:96px;max-width:100%;margin:0 auto;display:flex;align-items:center;justify-content:center}
.gst-invoice .qr-code img,.gst-invoice .qr-code canvas{display:block;width:96px;max-width:100%;height:auto;aspect-ratio:1/1}

/* ── Shared helpers ── */
.gst-invoice .center{text-align:center}
.gst-invoice .right{text-align:right}
.gst-invoice strong{font-weight:700}
.gst-invoice .inv-section{padding:0 20px;margin-bottom:0;page-break-inside:avoid;break-inside:avoid}
.gst-invoice .inv-section-head{font-size:9.5px;font-weight:800;text-transform:uppercase;letter-spacing:.1em;color:#2563eb;margin:0 0 8px;padding-bottom:5px;border-bottom:2px solid #2563eb;display:inline-block}
.gst-invoice .inv-party-name{font-size:13px;font-weight:800;color:#0f172a;margin-bottom:4px;letter-spacing:-.01em}
.gst-invoice .inv-party-detail{font-size:10.5px;color:#475569;line-height:1.5;margin-bottom:2px}
.gst-invoice .inv-label{font-weight:700;color:#64748b}
.gst-invoice .inv-info-row{display:flex;justify-content:space-between;align-items:baseline;padding:3px 0;font-size:10.5px}
.gst-invoice .inv-info-row .inv-label{font-weight:700;color:#94a3b8;text-transform:uppercase;font-size:9px;letter-spacing:.06em}
.gst-invoice .inv-info-row .inv-value{font-weight:700;color:#0f172a}
.gst-invoice .inv-total-row{display:flex;justify-content:space-between;align-items:baseline;padding:4px 0;font-size:10.5px;color:#475569}
.gst-invoice .inv-total-row span:last-child{font-weight:700;font-family:'DM Mono','Inter Mono',monospace;color:#1e293b}
.gst-invoice .inv-sign-label{font-size:10px;font-weight:800;color:#1e293b}
.gst-invoice .inv-sign-space{height:42px}
.gst-invoice .gst-note{text-align:center;border-top:1px solid #e2e8f0;padding:6px;font-size:8px;color:#94a3b8;letter-spacing:.04em;text-transform:uppercase}
.gst-invoice .inv-notes{margin-top:10px;font-size:10px;color:#475569}

/* ── Items table (shared base, templates override) ── */
.gst-invoice .gst-items-table{width:100%;border-collapse:collapse;border-spacing:0;table-layout:fixed}
.gst-invoice .gst-items-table th{text-align:center;font-weight:700;text-transform:uppercase;padding:9px 6px}
.gst-invoice .gst-items-table td{font-size:10px;padding:7px 6px;color:#1e293b;vertical-align:middle}

/* ================================================================
   MODERN TEMPLATE
   ================================================================ */
.gst-invoice.tpl-modern .inv-accent-bar{height:4px;background:linear-gradient(90deg,#2563eb,#7c3aed,#2563eb);background-size:200% 100%}
.gst-invoice.tpl-modern .inv-parties{display:flex;gap:0;padding:16px 20px;background:#f8fafc;border-bottom:1px solid #e2e8f0}
.gst-invoice.tpl-modern .inv-party-card{flex:1;padding:0 16px 0 0}
.gst-invoice.tpl-modern .inv-party-card + .inv-party-card{padding:0 16px;border-left:1px solid #e2e8f0}
.gst-invoice.tpl-modern .inv-info-card{flex:0 0 210px;padding-left:16px;border-left:1px solid #e2e8f0}
.gst-invoice.tpl-modern .inv-info-number{font-size:18px;font-weight:900;color:#2563eb;letter-spacing:-.02em;margin-bottom:8px;font-family:'DM Mono','Inter Mono',monospace}
.gst-invoice.tpl-modern .inv-items-wrap{padding:16px 20px}
.gst-invoice.tpl-modern .gst-items-table{border:1px solid #e2e8f0;border-radius:8px;overflow:hidden}
.gst-invoice.tpl-modern .gst-items-table th{background:#1e293b;font-size:8.5px;color:#fff;letter-spacing:.06em;border-right:1px solid #334155}
.gst-invoice.tpl-modern .gst-items-table th:last-child{border-right:0}
.gst-invoice.tpl-modern .gst-items-table td{border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9}
.gst-invoice.tpl-modern .gst-items-table td:last-child{border-right:0}
.gst-invoice.tpl-modern .gst-items-table tbody tr:nth-child(even){background:#f8fafc}
.gst-invoice.tpl-modern .gst-items-table tr:last-child td{border-bottom:0}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(1){width:5%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(2){width:24%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(3){width:9%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(4){width:7%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(5){width:6%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(6){width:10%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(7){width:10%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(8){width:12%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(9){width:7%}
.gst-invoice.tpl-modern .gst-items-table th:nth-child(10){width:10%}
.gst-invoice.tpl-modern .inv-summary{display:flex;gap:0;border-top:1px solid #e2e8f0;padding:16px 20px}
.gst-invoice.tpl-modern .inv-words{flex:1;padding-right:20px}
.gst-invoice.tpl-modern .inv-words-text{font-size:10.5px;color:#334155;font-weight:600;margin-top:2px}
.gst-invoice.tpl-modern .inv-totals{flex:0 0 240px;border-left:1px solid #e2e8f0;padding-left:20px}
.gst-invoice.tpl-modern .inv-grand-row{margin-top:6px;padding:8px 10px;background:#1e293b;border-radius:6px;font-size:12px;font-weight:900;color:#fff}
.gst-invoice.tpl-modern .inv-grand-row span{color:#fff!important}
.gst-invoice.tpl-modern .inv-grand-row span:last-child{font-size:15px}
.gst-invoice.tpl-modern .inv-footer{display:flex;gap:0;border-top:1px solid #e2e8f0;padding:16px 20px;background:#f8fafc}
.gst-invoice.tpl-modern .inv-footer-col{flex:1}
.gst-invoice.tpl-modern .inv-footer-center{text-align:center;padding:0 16px;border-left:1px solid #e2e8f0;border-right:1px solid #e2e8f0}
.gst-invoice.tpl-modern .inv-footer-right{text-align:center;display:flex;flex-direction:column;justify-content:flex-end;align-items:center}

/* ================================================================
   CLASSIC TEMPLATE
   ================================================================ */
.gst-invoice.tpl-classic{color:#000;font-family:Arial,'Times New Roman',serif;border:1px solid #000}
.gst-invoice.tpl-classic .invoice-header{border-bottom:1px solid #000}
.gst-invoice.tpl-classic .gst-logo-fallback{border:1px solid #000;border-radius:0}
.gst-invoice.tpl-classic .section-head{font-size:10px;font-weight:700;text-transform:uppercase;margin:0 0 4px;text-decoration:underline;color:#000}
.gst-invoice.tpl-classic table{width:100%;border-collapse:collapse;border-spacing:0;table-layout:fixed;border:1px solid #000;border-top:0}
.gst-invoice.tpl-classic th,.gst-invoice.tpl-classic td{border:1px solid #000;padding:4px 5px;color:#000;vertical-align:middle;background:#fff}
.gst-invoice.tpl-classic th{font-weight:700;text-align:left}
.gst-invoice.tpl-classic .gst-party-table{border-top:1px solid #000}
.gst-invoice.tpl-classic .gst-party-table + table,.gst-invoice.tpl-classic .gst-items-table + table,.gst-invoice.tpl-classic .gst-total-table + table{margin-top:-1px}
.gst-invoice.tpl-classic .gst-party-table .party-col{width:32%;height:170px}
.gst-invoice.tpl-classic .gst-party-table .terms-col{width:35%;height:170px}
.gst-invoice.tpl-classic .gst-party-table .invoice-info-col{padding:0}
.gst-invoice.tpl-classic .header-invoice-meta{height:100%;font-size:11px;table-layout:fixed}
.gst-invoice.tpl-classic .header-invoice-meta th,.gst-invoice.tpl-classic .header-invoice-meta td{font-size:11px;padding:4px 8px;line-height:1.1;vertical-align:middle}
.gst-invoice.tpl-classic .header-invoice-meta th{width:52%;background:#fff;text-transform:uppercase}
.gst-invoice.tpl-classic .gst-items-table{border:1px solid #000}
.gst-invoice.tpl-classic .gst-items-table th{background:#fff;text-align:center;font-size:9px;line-height:1.12;color:#000}
.gst-invoice.tpl-classic .gst-items-table td{font-size:9.5px;height:22px}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(1){width:6%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(2){width:25%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(3){width:10%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(4){width:8%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(5){width:6%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(6){width:10%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(7){width:9%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(8){width:12%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(9){width:6%}
.gst-invoice.tpl-classic .gst-items-table th:nth-child(10){width:8%}
.gst-invoice.tpl-classic .gst-total-table .words-cell{width:66%;font-weight:600;height:100px}
.gst-invoice.tpl-classic .gst-total-table .totals-cell{width:35%;padding:0}
.gst-invoice.tpl-classic .gst-total-table .totals-cell table{height:100%}
.gst-invoice.tpl-classic .gst-total-table .totals-cell table td:first-child{width:48%}
.gst-invoice.tpl-classic .gst-total-table .totals-cell table td:last-child{width:52%}
.gst-invoice.tpl-classic .gst-total-table .totals-cell table td{padding:4px 7px;vertical-align:middle}
.gst-invoice.tpl-classic .grand-row td{background:#fff;font-size:11px;font-weight:700}
.gst-invoice.tpl-classic .notes-line{margin-top:7px;font-weight:400}
.gst-invoice.tpl-classic .gst-footer-table td{width:37%;height:86px}
.gst-invoice.tpl-classic .sign-cell{text-align:center;vertical-align:bottom;padding-top:10px}
.gst-invoice.tpl-classic .sign-space{height:38px}
.gst-invoice.tpl-classic .gst-note{border-top:1px solid #000;color:#000;font-size:8px;text-transform:none;letter-spacing:0}
.gst-invoice.tpl-classic table table{border:0}
.gst-invoice.tpl-classic table table th,.gst-invoice.tpl-classic table table td{border:1px solid #000}
.gst-invoice.tpl-classic table table tr:first-child > th,.gst-invoice.tpl-classic table table tr:first-child > td{border-top:0}
.gst-invoice.tpl-classic table table tr:last-child > th,.gst-invoice.tpl-classic table table tr:last-child > td{border-bottom:0}
.gst-invoice.tpl-classic table table th:first-child,.gst-invoice.tpl-classic table table td:first-child{border-left:0}
.gst-invoice.tpl-classic table table th:last-child,.gst-invoice.tpl-classic table table td:last-child{border-right:0}

/* ================================================================
   MINIMAL TEMPLATE
   ================================================================ */
.gst-invoice.tpl-minimal .inv-section-head{color:#64748b;border-bottom:1px solid #e2e8f0;font-size:9px;letter-spacing:.08em}
.gst-invoice.tpl-minimal .inv-parties-min{display:flex;gap:0;padding:14px 20px;border-bottom:1px solid #e2e8f0}
.gst-invoice.tpl-minimal .inv-party-min{flex:1;padding-right:16px}
.gst-invoice.tpl-minimal .inv-party-min + .inv-party-min{padding:0 16px;border-left:1px solid #e2e8f0}
.gst-invoice.tpl-minimal .inv-info-min{flex:0 0 160px;padding-left:16px;border-left:1px solid #e2e8f0}
.gst-invoice.tpl-minimal .inv-items-wrap{padding:12px 20px}
.gst-invoice.tpl-minimal .gst-items-table{border:0}
.gst-invoice.tpl-minimal .gst-items-table th{background:transparent;font-size:8px;color:#94a3b8;letter-spacing:.08em;padding:6px 4px;border-bottom:1px solid #e2e8f0;font-weight:600}
.gst-invoice.tpl-minimal .gst-items-table td{border-bottom:1px solid #f1f5f9;padding:6px 4px;font-size:10px;color:#334155}
.gst-invoice.tpl-minimal .gst-items-table tr:last-child td{border-bottom:0}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(1){width:4%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(2){width:24%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(3){width:8%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(4){width:7%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(5){width:6%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(6){width:9%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(7){width:9%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(8){width:11%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(9){width:7%}
.gst-invoice.tpl-minimal .gst-items-table th:nth-child(10){width:15%}
.gst-invoice.tpl-minimal .inv-summary-min{display:flex;gap:0;border-top:1px solid #e2e8f0;padding:14px 20px}
.gst-invoice.tpl-minimal .inv-words-min{flex:1;padding-right:20px;font-size:10px;color:#64748b;font-style:italic}
.gst-invoice.tpl-minimal .inv-totals-min{flex:0 0 200px;border-left:1px solid #e2e8f0;padding-left:20px}
.gst-invoice.tpl-minimal .inv-grand-row{border-top:2px solid #0f172a;margin-top:4px;padding-top:6px;font-size:13px;font-weight:900;color:#0f172a}
.gst-invoice.tpl-minimal .inv-grand-row span:last-child{font-size:14px}
.gst-invoice.tpl-minimal .inv-footer-min{display:flex;justify-content:space-between;align-items:flex-end;border-top:1px solid #e2e8f0;padding:14px 20px}
.gst-invoice.tpl-minimal .inv-footer-min-left{font-size:9px;color:#94a3b8}
.gst-invoice.tpl-minimal .inv-footer-min-right{text-align:center}
.gst-invoice.tpl-minimal .gst-note{color:#cbd5e1}

/* ================================================================
   SPECIAL TEMPLATE
   ================================================================ */
.gst-invoice.tpl-special{background:#fff;border:1px solid #e2e8f0}
.gst-invoice.tpl-special .inv-accent-bar{height:6px;background:linear-gradient(90deg,#0f172a,#334155,#0f172a)}
.gst-invoice.tpl-special .inv-parties{display:flex;gap:0;padding:18px 22px;border-bottom:1px solid #e2e8f0;background:#f8fafc}
.gst-invoice.tpl-special .inv-party-card{flex:1;padding-right:18px}
.gst-invoice.tpl-special .inv-party-card + .inv-party-card{padding:0 18px;border-left:1px solid #cbd5e1}
.gst-invoice.tpl-special .inv-info-card{flex:0 0 220px;padding-left:18px;border-left:1px solid #cbd5e1}
.gst-invoice.tpl-special .inv-info-number{font-size:20px;font-weight:900;color:#0f172a;letter-spacing:-.02em;margin-bottom:10px;font-family:'DM Mono','Inter Mono',monospace}
.gst-invoice.tpl-special .inv-items-wrap{padding:16px 22px}
.gst-invoice.tpl-special .gst-items-table{border:1px solid #e2e8f0;border-radius:8px;overflow:hidden}
.gst-invoice.tpl-special .gst-items-table th{background:#0f172a;font-size:8.5px;color:#fff;letter-spacing:.06em;border-right:1px solid #334155;padding:10px 6px}
.gst-invoice.tpl-special .gst-items-table th:last-child{border-right:0}
.gst-invoice.tpl-special .gst-items-table td{border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9;padding:8px 6px;font-size:10.5px;color:#1e293b;vertical-align:middle}
.gst-invoice.tpl-special .gst-items-table td:last-child{border-right:0}
.gst-invoice.tpl-special .gst-items-table tbody tr:nth-child(even){background:#f8fafc}
.gst-invoice.tpl-special .gst-items-table tr:last-child td{border-bottom:0}
.gst-invoice.tpl-special .gst-items-table th:nth-child(1){width:5%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(2){width:24%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(3){width:9%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(4){width:7%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(5){width:6%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(6){width:10%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(7){width:10%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(8){width:12%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(9){width:7%}
.gst-invoice.tpl-special .gst-items-table th:nth-child(10){width:10%}
.gst-invoice.tpl-special .inv-summary{display:flex;gap:0;border-top:1px solid #e2e8f0;padding:18px 22px;background:#f8fafc}
.gst-invoice.tpl-special .inv-words{flex:1;padding-right:20px}
.gst-invoice.tpl-special .inv-words-text{font-size:11px;color:#334155;font-weight:600;margin-top:2px;line-height:1.5}
.gst-invoice.tpl-special .inv-totals{flex:0 0 240px}
.gst-invoice.tpl-special .inv-total-row{display:flex;justify-content:space-between;padding:3px 0;font-size:11px;color:#475569}
.gst-invoice.tpl-special .inv-grand-row{border-top:2px solid #0f172a;margin-top:6px;padding-top:8px;font-size:14px;font-weight:900;color:#0f172a}
.gst-invoice.tpl-special .inv-grand-row span:last-child{font-size:15px;font-family:'DM Mono','Inter Mono',monospace}
.gst-invoice.tpl-special .inv-footer{display:flex;gap:0;border-top:1px solid #e2e8f0;padding:18px 22px}
.gst-invoice.tpl-special .inv-footer-col{flex:1;padding-right:16px}
.gst-invoice.tpl-special .inv-footer-col + .inv-footer-col{padding:0 16px;border-left:1px solid #e2e8f0}
.gst-invoice.tpl-special .inv-footer-right{text-align:right;display:flex;flex-direction:column;align-items:flex-end;justify-content:flex-end}
.gst-invoice.tpl-special .inv-sign-space{height:40px;border-bottom:1px solid #94a3b8;margin-bottom:4px;width:140px}
.gst-invoice.tpl-special .gst-note{color:#94a3b8;border-top:1px solid #e2e8f0;padding:8px 22px;font-size:9px;text-align:center;letter-spacing:.02em;background:#f8fafc}

/* ── Print (shared + template-specific) ── */
@page{size:A4;margin:12mm}
@media print {
  html,body,#print-area{transform:none!important;zoom:1!important}
  .invoice-doc.gst-invoice{width:100%;max-width:none;font-size:11px}
  button,.btn,.btn-icon,.no-print{display:none!important}
  .invoice-doc.gst-invoice,.invoice-doc.gst-invoice *{box-shadow:none!important;text-shadow:none!important}
  .gst-invoice .invoice-header{display:flex!important;justify-content:space-between!important;align-items:center!important;min-height:130px;padding:10px 14px!important;page-break-inside:avoid!important;break-inside:avoid!important}
  .gst-invoice .header-left{width:20%!important}
  .gst-invoice .header-center{width:60%!important}
  .gst-invoice .header-right{width:20%!important}
  .gst-invoice .header-left,.gst-invoice .header-center,.gst-invoice .header-right{min-height:112px}
  .gst-invoice .gst-company-name{font-size:18px;white-space:normal}
  .gst-invoice .gst-logo{max-width:100%;max-height:108px;height:auto}
  .gst-invoice .qr-code,.gst-invoice .qr-code img,.gst-invoice .qr-code canvas{width:82px;height:82px;overflow:visible}
  .gst-invoice .inv-section,.gst-invoice .inv-parties,.gst-invoice .inv-summary,.gst-invoice .inv-footer,
  .gst-invoice .inv-parties-min,.gst-invoice .inv-summary-min,.gst-invoice .inv-footer-min{break-inside:avoid;page-break-inside:avoid}
  .gst-invoice .gst-items-table thead{display:table-header-group}
  .gst-invoice .gst-items-table tr{break-inside:avoid;page-break-inside:avoid}
  /* Modern print */
  .gst-invoice.tpl-modern{border:1px solid #cbd5e1!important}
  .gst-invoice.tpl-modern .inv-accent-bar{background:#2563eb!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .gst-invoice.tpl-modern .gst-items-table th{background:#1e293b!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .gst-invoice.tpl-modern .gst-items-table th,.gst-invoice.tpl-modern .gst-items-table td{border-color:#e2e8f0!important}
  .gst-invoice.tpl-modern .inv-grand-row{background:#1e293b!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  /* Classic print */
  .gst-invoice.tpl-classic{border:1px solid #000!important}
  .gst-invoice.tpl-classic th,.gst-invoice.tpl-classic td{border-color:#000!important;border-style:solid!important;border-width:1px!important}
  .gst-invoice.tpl-classic .gst-items-table th{background:#fff!important;color:#000!important}
  .gst-invoice.tpl-classic table{border-color:#000!important}
  /* Minimal print */
  .gst-invoice.tpl-minimal{border:1px solid #e2e8f0!important}
  .gst-invoice.tpl-minimal .gst-items-table th{background:transparent!important;color:#94a3b8!important}
  /* Special print */
  .gst-invoice.tpl-special{border:1px solid #cbd5e1!important}
  .gst-invoice.tpl-special .inv-accent-bar{background:linear-gradient(90deg,#0f172a,#334155,#0f172a)!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .gst-invoice.tpl-special .gst-items-table th{background:#0f172a!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .gst-invoice.tpl-special .gst-items-table th,.gst-invoice.tpl-special .gst-items-table td{border-color:#e2e8f0!important}
  .gst-invoice.tpl-special .inv-grand-row{border-top-color:#0f172a!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  /* Preserve background colors for inline-styled templates */
  .gst-invoice div[style*="background:#"]{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .gst-invoice div[style*="background:#000"],.gst-invoice div[style*="background:#0f172a"],.gst-invoice div[style*="background:#059669"]{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}

/* Template preview cards */
.template-card:hover{border-color:#2563eb!important;transform:translateY(-2px);box-shadow:0 4px 12px rgba(0,0,0,.08)}
.template-card.selected{border-color:#2563eb!important;box-shadow:0 0 0 2px #2563eb33}

/* ── MISC ────────────────────────────────────── */
.empty{text-align:center;padding:60px 20px;color:var(--muted)}
.empty .icon{font-size:44px;margin-bottom:14px;display:block}
.actions{display:flex;gap:5px;flex-wrap:wrap}
.section-title{font-size:13px;font-weight:700;margin-bottom:14px;padding-bottom:8px;border-bottom:1px solid var(--border);color:var(--text)}

/* ── RESPONSIVE ──────────────────────────────── */
@media(max-width:900px){
  .sidebar{width:56px}
  .nav-label,.logo span,.nav-section{display:none}
  .page{padding:20px 16px}
  .form-grid{grid-template-columns:1fr}
  .stats-grid{grid-template-columns:1fr 1fr}
}
@media(max-width:600px){
  .stats-grid{grid-template-columns:1fr}
  .parties{grid-template-columns:1fr!important}
  .invoice-doc{padding:20px}
}

/* ── SECTION / CARD TITLES ──────────────────── */
.section-title{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:16px}
.card-title{font-size:15px;font-weight:700;color:var(--text);margin-bottom:14px}

/* ── SALES DASHBOARD ────────────────────────── */
.dashboard-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:24px;margin-bottom:24px}
.dashboard-card{background:#fff;border:1px solid var(--border);border-radius:16px;padding:24px;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.kpi-card{display:flex;align-items:center;gap:16px}
.kpi-icon{width:56px;height:56px;border-radius:14px;display:flex;align-items:center;justify-content:center;font-size:24px}
.kpi-icon.sales{background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff}
.kpi-icon.clients{background:linear-gradient(135deg,#10b981,#14b8a6);color:#fff}
.kpi-icon.invoices{background:linear-gradient(135deg,#f59e0b,#f97316);color:#fff}
.kpi-icon.pending{background:linear-gradient(135deg,#ef4444,#f43f5e);color:#fff}
.kpi-content{flex:1}
.kpi-label{font-size:13px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:4px}
.kpi-value{font-size:28px;font-weight:700;color:var(--text);line-height:1}
.kpi-change{font-size:12px;color:var(--success);margin-top:4px}
.chart-container{position:relative;height:300px}
.chart-row{display:grid;grid-template-columns:2fr 1fr;gap:24px;margin-bottom:24px}
.goal-card{background:linear-gradient(135deg,#f8fafc,#e2e8f0);padding:20px;border-radius:12px}
.goal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.goal-label{font-size:14px;font-weight:600;color:var(--muted)}
.goal-value{font-size:24px;font-weight:700;color:var(--text)}
.goal-progress{height:8px;background:#e2e8f0;border-radius:4px;overflow:hidden}
.goal-progress-bar{height:100%;background:linear-gradient(90deg,#6366f1,#8b5cf6);border-radius:4px;transition:width .3s ease}
.prediction-card{background:linear-gradient(135deg,#eff6ff,#dbeafe);padding:20px;border-radius:12px;border-left:4px solid #3b82f6}
.prediction-title{font-size:12px;font-weight:600;color:#3b82f6;text-transform:uppercase;letter-spacing:.05em;margin-bottom:8px}
.prediction-value{font-size:22px;font-weight:700;color:#1e40af}
.prediction-desc{font-size:13px;color:#64748b;margin-top:4px}
.dashboard-filter-bar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:24px;padding:16px 20px;background:#fff;border:1px solid var(--border);border-radius:12px;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.dashboard-filter-bar label{font-size:12px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-right:4px}
.dashboard-filter-bar select,.dashboard-filter-bar input[type="date"]{padding:8px 12px;border:1px solid var(--border);border-radius:8px;font-size:13px;background:#fff;color:var(--text);min-width:140px}
.dashboard-filter-bar select:focus,.dashboard-filter-bar input:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 2px #2563eb22}
.dashboard-filter-bar .filter-group{display:flex;align-items:center;gap:6px}
.dashboard-filter-bar .btn-sm{padding:8px 14px;font-size:13px}
.dashboard-empty{text-align:center;padding:80px 20px;color:var(--muted)}
.dashboard-empty .icon{font-size:48px;margin-bottom:16px;display:block}
.dashboard-empty h3{font-size:18px;margin-bottom:8px;color:var(--text)}
.dashboard-empty p{font-size:14px;color:var(--muted)}
.insight-card{background:linear-gradient(135deg,#f5f7ff,#eef2ff);padding:10px 14px;margin:6px 0;border-left:4px solid #4f46e5;border-radius:6px;font-size:13px;color:#312e81;line-height:1.5;box-shadow:0 1px 2px rgba(0,0,0,.04)}
.insight-card:first-child{margin-top:0}
.insight-card:last-child{margin-bottom:0}
.live-indicator{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);padding:8px 12px;background:#f1f5f9;border-radius:20px}
.live-dot{width:8px;height:8px;background:#22c55e;border-radius:50%;animation:pulse 1.5s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
@media(max-width:900px){
  .chart-row{grid-template-columns:1fr}
  .dashboard-grid{grid-template-columns:repeat(2,1fr)}
  .dashboard-filter-bar{flex-direction:column;align-items:stretch}
  .dashboard-filter-bar .filter-group{justify-content:space-between}
}
@media(max-width:600px){
  .dashboard-grid{grid-template-columns:1fr}
}

/* ── SIDEBAR TRANSITIONS ───────────────────────── */
.sidebar {
  transition: width .25s ease, transform .3s cubic-bezier(.4,0,.2,1);
}

/* ── SIDEBAR TOGGLE ───────────────────────────── */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
  border-radius: 6px;
  transition: background .15s;
}
.sidebar-toggle:hover {
  background: var(--bg);
}

/* ── SIDEBAR OVERLAY ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
  display: block;
}

/* ── FLOATING TOGGLE ───────────────────────────── */
.sidebar-toggle-floating {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 55;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: background .15s, box-shadow .15s;
}
.sidebar-toggle-floating:hover {
  background: var(--bg);
  box-shadow: var(--shadow-lg);
}
.sidebar-toggle-floating.visible {
  display: flex;
}

/* ── DESKTOP COLLAPSED (ICON-ONLY) ───────────── */
@media (min-width: 769px) {
  .sidebar {
    transition: width .25s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.collapsed {
    width: 72px;
    padding-left: 0;
    padding-right: 0;
  }
  .sidebar.collapsed .logo {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
  }
  .sidebar.collapsed .logo .sidebar-toggle {
    margin: 0;
    padding: 6px;
  }
  .sidebar.collapsed .logo span,
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .nav-label {
    display: none;
  }
  .sidebar.collapsed nav a {
    justify-content: center;
    padding: 10px 0;
    margin: 0 10px;
    border-radius: 10px;
  }
  .sidebar.collapsed nav a .icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    margin: 0;
  }
  .sidebar.collapsed nav a.active {
    position: relative;
  }
  .sidebar.collapsed nav a.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
  }
  /* Tooltip */
  .sidebar.collapsed nav a {
    position: relative;
  }
  .sidebar.collapsed nav a::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s, visibility .18s, transform .18s;
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
  }
  .sidebar.collapsed nav a:hover::after {
    opacity: 1;
    visibility: visible;
  }
}

/* ── MOBILE SIDEBAR DRAWER ─────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    width: 260px;
    box-shadow: none;
    border-right: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
  }
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .logo span,
  .sidebar.mobile-open .nav-section {
    display: block;
  }
  .sidebar.mobile-open nav a {
    justify-content: flex-start;
  }
  .sidebar-overlay.active {
    display: block;
  }
  body.drawer-open {
    overflow: hidden;
  }
}

/* ── TEAM MANAGEMENT ─────────────────────────── */

/* Header */
.tm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.tm-header-text h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
  color: #0f172a;
  margin: 0 0 4px;
}
.tm-header-text p {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

/* Stats */
.tm-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.tm-stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .2s, transform .2s;
}
.tm-stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.tm-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tm-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  font-family: 'DM Mono', monospace;
}
.tm-stat-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}

/* Card */
.tm-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  overflow: hidden;
}

/* Action bar */
.tm-actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  gap: 12px;
  flex-wrap: wrap;
}
.tm-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.tm-search-wrap input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.tm-search-wrap input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.tm-search-wrap input::placeholder {
  color: #94a3b8;
}
.tm-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}
.tm-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tm-filters select {
  padding: 8px 28px 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: #334155;
  background: #fff;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 130px;
}
.tm-filters select:focus {
  border-color: #2563eb;
}

/* Table */
.tm-table-wrap {
  overflow-x: auto;
}
.tm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tm-table thead th {
  text-align: left;
  padding: 12px 20px;
  color: #64748b;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  white-space: nowrap;
}
.tm-table tbody td {
  padding: 14px 20px;
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}
.tm-table tbody tr {
  transition: background .15s;
}
.tm-table tbody tr:hover {
  background: #fafbfc;
}
.tm-table tbody tr:last-child td {
  border-bottom: none;
}

/* User cell */
.tm-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tm-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: .5px;
}
.tm-user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tm-user-name {
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
}
.tm-user-email {
  font-size: 12.5px;
  color: #64748b;
}

/* Role badges */
.tm-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .02em;
}
.tm-role-admin {
  background: #dbeafe;
  color: #1e40af;
}
.tm-role-accountant {
  background: #d1fae5;
  color: #065f46;
}
.tm-role-sales {
  background: #fce7f3;
  color: #9d174d;
}
.tm-role-viewer {
  background: #f3f4f6;
  color: #4b5563;
}
.tm-role-default {
  background: #e2e8f0;
  color: #334155;
}

/* Status */
.tm-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}
.tm-status.active {
  background: #f0fdf4;
  color: #15803d;
}
.tm-status.inactive {
  background: #fef2f2;
  color: #b91c1c;
}
.tm-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.tm-status.active .tm-status-dot {
  box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}
.tm-status.inactive .tm-status-dot {
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

/* Department / Phone / Last Login */
.tm-dept, .tm-phone, .tm-last-login {
  font-size: 13px;
  color: #475569;
}
.tm-last-login {
  color: #64748b;
  font-size: 12.5px;
}

/* Actions dropdown */
.tm-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
}
.tm-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.tm-action-btn:hover {
  background: #f1f5f9;
  color: #475569;
}
.tm-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.1);
  padding: 6px;
  min-width: 160px;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px) scale(.97);
  transition: opacity .15s, visibility .15s, transform .15s;
  pointer-events: none;
}
.tm-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.tm-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #334155;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .1s;
}
.tm-dropdown button:hover {
  background: #f8fafc;
}
.tm-dropdown button.danger {
  color: #dc2626;
}
.tm-dropdown button.danger:hover {
  background: #fef2f2;
}
.tm-dropdown button.success {
  color: #16a34a;
}
.tm-dropdown button.success:hover {
  background: #f0fdf4;
}

/* Empty state */
.tm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}
.tm-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .5;
}
.tm-empty h3 {
  font-size: 16px;
  font-weight: 600;
  color: #334155;
  margin: 0 0 6px;
}
.tm-empty p {
  font-size: 13.5px;
  color: #94a3b8;
  margin: 0 0 18px;
}

/* ── MODAL ───────────────────────────────────── */
.tm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15,23,42,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.tm-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}
.tm-modal {
  background: #fff;
  border-radius: 18px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 30px 100px rgba(0,0,0,.18);
  transform: scale(.95) translateY(12px);
  transition: transform .28s cubic-bezier(.16,1,.3,1);
  position: relative;
  display: flex;
  flex-direction: column;
}
.tm-modal-overlay.visible .tm-modal {
  transform: scale(1) translateY(0);
}
.tm-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 28px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: #fff;
}
.tm-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}
.tm-modal-subtitle {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: #64748b;
  line-height: 1.4;
}
.tm-modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  margin-top: 2px;
}
.tm-modal-close:hover {
  background: #f1f5f9;
  color: #475569;
}
#tm-modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Two-column modal body */
.tm-modal-body-two-col {
  display: flex;
  gap: 0;
  min-height: 0;
}
.tm-modal-left {
  width: 340px;
  flex-shrink: 0;
  padding: 24px 28px;
  border-right: 1px solid #f1f5f9;
}
.tm-modal-right {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
  overflow-y: auto;
  max-height: 52vh;
}
.tm-panel-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 16px;
}
.tm-field {
  margin-bottom: 16px;
}
.tm-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.tm-field .form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.tm-field .form-control:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.tm-field .form-control:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}
.tm-field select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.tm-hint {
  font-size: 12px;
  color: #94a3b8;
  margin: 5px 0 0;
  line-height: 1.4;
}
.tm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 28px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
  flex-shrink: 0;
}

/* Temp password */
.tm-temp-password {
  text-align: center;
  padding: 40px 24px;
}
.tm-temp-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.tm-temp-password h3 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}
.tm-temp-password p {
  font-size: 14px;
  color: #64748b;
  margin: 0 0 20px;
  line-height: 1.5;
}
.tm-password-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 28px;
  border-radius: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 18px;
  letter-spacing: 2px;
  margin-bottom: 20px;
  display: inline-block;
}
.tm-temp-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── PERMISSION ACCORDION ────────────────────── */
.tm-perm-accordion {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tm-perm-group {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.tm-perm-group.open {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.tm-perm-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: #fafbfc;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  text-align: left;
  transition: background .12s;
}
.tm-perm-group-header:hover {
  background: #f1f5f9;
}
.tm-perm-chevron {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: transform .2s, color .15s;
  flex-shrink: 0;
}
.tm-perm-group.open .tm-perm-chevron {
  transform: rotate(90deg);
  color: #475569;
}
.tm-perm-group-name {
  flex: 1;
  min-width: 0;
}
.tm-perm-group-count {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}
.tm-perm-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  padding: 2px 0;
}
.tm-perm-group-toggle input {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
}
.tm-perm-group-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s cubic-bezier(.4,0,.2,1), padding .25s;
}
.tm-perm-group.open .tm-perm-group-body {
  max-height: 500px;
  padding: 0 14px 14px;
}
.tm-perm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}
.tm-perm-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  user-select: none;
  transition: background .1s, border-color .1s;
}
.tm-perm-action:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.tm-perm-action input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── EMPTY (legacy pages) ────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty .icon {
  font-size: 48px;
  margin-bottom: 18px;
  opacity: .45;
  display: block;
  transition: opacity .3s, transform .3s;
}
.empty:hover .icon {
  opacity: .6;
  transform: scale(1.05);
}
.empty p {
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.6;
  color: var(--muted);
  font-weight: 400;
}
.empty small {
  font-size: 12px;
  color: #94a3b8;
}

/* ── EMPTY STATES ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--muted);
}
.empty-state-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 22px;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 4px 12px rgba(15,23,42,0.05);
  transition: transform .3s, box-shadow .3s;
}
.empty-state:hover .empty-state-icon {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(15,23,42,0.08);
}
.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.1px;
}
.empty-state p {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 22px;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
  font-weight: 400;
}

/* ── SKELETON LOADERS ────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { margin-bottom: 0; }
.skeleton-title { height: 18px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.skeleton-table-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}
.skeleton-table-row:last-child { border-bottom: none; }

/* ── RESPONSIVE TABLES ───────────────────────── */
@media (max-width: 768px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 720px; }
  .page { padding: 20px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1, .page-header h2 { font-size: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .btn { padding: 7px 14px; font-size: 12.5px; }
  .actions { flex-wrap: wrap; }
  .modal { max-width: 100%; border-radius: 14px 14px 0 0; margin-top: auto; max-height: 85vh; }
  #modal-overlay { align-items: flex-end; padding: 0; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar { width: 260px; }
  .page { padding: 16px; }
  .page-header { margin-bottom: 16px; }
  .table-wrap { border-radius: 8px; }
  th, td { padding: 8px 10px; font-size: 12.5px; }
}

/* ── RESPONSIVE TEAM ─────────────────────────── */
@media (max-width: 1024px) {
  .tm-stats { grid-template-columns: repeat(2, 1fr); }
  .tm-modal { max-width: 720px; }
  .tm-modal-right { max-height: 45vh; }
}
@media (max-width: 768px) {
  .tm-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tm-stat-card { padding: 14px; gap: 10px; }
  .tm-stat-icon { width: 36px; height: 36px; font-size: 16px; }
  .tm-stat-value { font-size: 18px; }
  .tm-header { flex-direction: column; align-items: flex-start; }
  .tm-actionbar { flex-direction: column; align-items: stretch; }
  .tm-search-wrap { max-width: none; }
  .tm-filters { width: 100%; }
  .tm-filters select { flex: 1; }
  .tm-table thead th:nth-child(4),
  .tm-table tbody td:nth-child(4) { display: none; } /* hide phone */

  /* Modal: stacked layout on tablet */
  .tm-modal { max-width: 100%; border-radius: 14px 14px 0 0; margin-top: auto; max-height: 90vh; }
  .tm-modal-overlay { align-items: flex-end; padding: 0; }
  .tm-modal-body-two-col { flex-direction: column; }
  .tm-modal-left { width: 100%; border-right: none; border-bottom: 1px solid #f1f5f9; padding: 20px 24px; }
  .tm-modal-right { padding: 20px 24px; max-height: 35vh; }
  .tm-modal-header { padding: 18px 24px; }
  .tm-modal-footer { padding: 14px 24px; }
}
@media (max-width: 480px) {
  .tm-stats { grid-template-columns: 1fr 1fr; }
  .tm-table thead th:nth-child(3),
  .tm-table tbody td:nth-child(3) { display: none; } /* hide dept */
  .tm-table thead th:nth-child(6),
  .tm-table tbody td:nth-child(6) { display: none; } /* hide last active */
  .tm-form-grid { grid-template-columns: 1fr; }
  .tm-modal-left, .tm-modal-right { padding: 16px 20px; }
  .tm-modal-header { padding: 16px 20px; }
  .tm-modal-footer { padding: 12px 20px; }
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green {
  background: #d1fae5;
  color: #065f46;
}
.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

/* ── PAGE ERROR BOUNDARY ─────────────────────── */
.page-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  max-width: 480px;
  margin: 0 auto;
  animation: fade-in-up 300ms ease;
}
.page-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
  line-height: 1;
}
.page-error h2 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}
.page-error p {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.5;
}
.page-error-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.page-error-hint {
  margin-top: 12px;
  font-size: 12px;
  color: #94a3b8;
}

/* ── FADE TRANSITIONS ──────────────────────────── */
.page {
  transition: opacity 220ms ease, transform 220ms ease;
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── SPINNER ─────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  display: inline-block;
  animation: spin 1s linear infinite;
}

/* ════════════════════════════════════════════════════════════
   PREMIUM COMMAND CENTER DASHBOARD
   ════════════════════════════════════════════════════════════ */

:root {
  --dash-bg: #f6f8fc;
  --dash-surface: rgba(255,255,255,0.88);
  --dash-surface-solid: #ffffff;
  --dash-border: rgba(226,232,240,0.65);
  --dash-text: #0f172a;
  --dash-text-secondary: #334155;
  --dash-muted: #64748b;
  --dash-muted-light: #94a3b8;
  --dash-primary: #2563eb;
  --dash-primary-light: #eff6ff;
  --dash-success: #10b981;
  --dash-warn: #f59e0b;
  --dash-danger: #ef4444;
  --dash-purple: #8b5cf6;
  --dash-pink: #ec4899;
  --dash-teal: #14b8a6;
  --dash-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.02);
  --dash-shadow-sm: 0 2px 8px rgba(15,23,42,0.04);
  --dash-shadow-md: 0 4px 20px rgba(15,23,42,0.06);
  --dash-shadow-lg: 0 8px 32px rgba(15,23,42,0.08);
  --dash-shadow-xl: 0 20px 60px rgba(15,23,42,0.10);
  --dash-glow-primary: 0 0 0 3px rgba(37,99,235,0.08);
  --dash-radius: 18px;
  --dash-radius-sm: 14px;
  --dash-radius-xs: 10px;
}

@keyframes dash-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dash-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dash-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes dash-pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.15); }
  50%      { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
}

/* ── Top Business Summary Bar ──────────────────────────────── */
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  padding: 16px 22px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 60%, #f1f5f9 100%);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  box-shadow: var(--dash-shadow-sm);
  animation: dash-fade-up 500ms cubic-bezier(.16,1,.3,1) forwards;
}
.dash-topbar-left { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.dash-topbar-date {
  font-size: 11px; font-weight: 500; color: var(--dash-muted-light);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 5px 12px; background: #f1f5f9; border-radius: 20px;
}
.dash-topbar-company {
  font-size: 17px; font-weight: 600; color: var(--dash-text);
  letter-spacing: -0.25px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-topbar-health {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 4px 10px; border-radius: 20px;
  transition: transform .15s;
}
.dash-topbar-health.good { background: linear-gradient(135deg, #d1fae5, #ecfdf5); color: #065f46; }
.dash-topbar-health.warning { background: linear-gradient(135deg, #fef3c7, #fffbeb); color: #92400e; }
.dash-topbar-health.danger { background: linear-gradient(135deg, #fee2e2, #fef2f2); color: #991b1b; }
.dash-topbar-right { display: flex; align-items: center; gap: 10px; }
.dash-topbar-team {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dash-muted); font-weight: 500;
}
.dash-topbar-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--dash-primary), #6366f1);
  color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(37,99,235,0.18);
  transition: transform .2s;
}
.dash-topbar-avatar:hover { transform: scale(1.1); }
.dash-search {
  position: relative;
}
.dash-search input {
  padding: 9px 14px 9px 36px; border: 1px solid var(--dash-border); border-radius: var(--dash-radius-xs);
  font-size: 13px; background: #f8fafc; width: 200px; transition: all .25s cubic-bezier(.4,0,.2,1);
  color: var(--dash-text);
}
.dash-search input:focus { width: 260px; background: #fff; border-color: var(--dash-primary); outline: none; box-shadow: var(--dash-glow-primary); }
.dash-search input::placeholder { color: var(--dash-muted-light); }
.dash-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--dash-muted-light); pointer-events: none;
}
.dash-icon-btn {
  width: 38px; height: 38px; border-radius: var(--dash-radius-xs); border: 1px solid var(--dash-border);
  background: #fff; color: var(--dash-muted); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; transition: all .2s cubic-bezier(.4,0,.2,1); position: relative;
}
.dash-icon-btn:hover { background: var(--dash-primary-light); color: var(--dash-primary); border-color: #bfdbfe; transform: translateY(-2px); box-shadow: var(--dash-shadow-md); }
.dash-icon-btn:active { transform: translateY(0) scale(0.96); }
.dash-icon-btn .badge-dot {
  position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--dash-danger); border: 2px solid #fff;
}

/* ── Quick Action Center ─────────────────────────────────── */
.dash-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.dash-action-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px 12px; background: var(--dash-surface-solid);
  border: 1px solid var(--dash-border); border-radius: var(--dash-radius-sm);
  cursor: pointer; transition: all .25s cubic-bezier(.4,0,.2,1);
  text-decoration: none; color: var(--dash-text); position: relative;
  animation: dash-fade-up 400ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.dash-action-card:hover {
  transform: translateY(-4px); box-shadow: var(--dash-shadow-lg);
  border-color: rgba(37,99,235,0.18); background: #fff;
}
.dash-action-card:active { transform: translateY(-1px) scale(0.97); }
.dash-action-icon {
  width: 44px; height: 44px; border-radius: var(--dash-radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; background: linear-gradient(135deg, #eff6ff, #dbeafe);
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
  transition: transform .25s, box-shadow .25s;
}
.dash-action-card:hover .dash-action-icon {
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(37,99,235,0.14);
}
.dash-action-label { font-size: 12px; font-weight: 500; color: var(--dash-text-secondary); text-align: center; letter-spacing: -0.1px; }
.dash-action-shortcut {
  font-size: 10px; color: var(--dash-muted-light); background: #f1f5f9;
  padding: 3px 7px; border-radius: 5px; font-family: 'DM Mono', monospace; font-weight: 500;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.dash-kpi-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--dash-shadow-sm);
  animation: dash-fade-up 450ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 50ms);
}
.dash-kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--dash-primary), #6366f1); opacity: 0.7;
  transition: opacity .3s;
}
.dash-kpi-card:hover { transform: translateY(-4px); box-shadow: var(--dash-shadow-lg); border-color: rgba(37,99,235,0.18); }
.dash-kpi-card:hover::before { opacity: 1; }
.dash-kpi-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.dash-kpi-icon {
  width: 42px; height: 42px; border-radius: var(--dash-radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  transition: transform .3s, box-shadow .3s;
}
.dash-kpi-card:hover .dash-kpi-icon { transform: scale(1.08); }
.dash-kpi-icon.blue { background: linear-gradient(135deg, #dbeafe, #eff6ff); box-shadow: 0 2px 8px rgba(37,99,235,0.10); }
.dash-kpi-icon.green { background: linear-gradient(135deg, #d1fae5, #ecfdf5); box-shadow: 0 2px 8px rgba(16,185,129,0.10); }
.dash-kpi-icon.amber { background: linear-gradient(135deg, #fef3c7, #fffbeb); box-shadow: 0 2px 8px rgba(245,158,11,0.10); }
.dash-kpi-icon.red { background: linear-gradient(135deg, #fee2e2, #fef2f2); box-shadow: 0 2px 8px rgba(239,68,68,0.10); }
.dash-kpi-icon.purple { background: linear-gradient(135deg, #ede9fe, #f5f3ff); box-shadow: 0 2px 8px rgba(139,92,246,0.10); }
.dash-kpi-icon.teal { background: linear-gradient(135deg, #ccfbf1, #f0fdfa); box-shadow: 0 2px 8px rgba(20,184,166,0.10); }
.dash-kpi-icon.pink { background: linear-gradient(135deg, #fce7f3, #fdf2f8); box-shadow: 0 2px 8px rgba(236,72,153,0.10); }
.dash-kpi-icon.gray { background: linear-gradient(135deg, #f1f5f9, #f8fafc); box-shadow: 0 2px 8px rgba(100,116,139,0.08); }
.dash-kpi-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 3px;
}
.dash-kpi-badge.up { background: linear-gradient(135deg, #d1fae5, #ecfdf5); color: #065f46; }
.dash-kpi-badge.down { background: linear-gradient(135deg, #fee2e2, #fef2f2); color: #991b1b; }
.dash-kpi-badge.neutral { background: linear-gradient(135deg, #f1f5f9, #f8fafc); color: #475569; }
.dash-kpi-label { font-size: 11px; font-weight: 500; color: var(--dash-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dash-kpi-value {
  font-size: 24px; font-weight: 600; color: var(--dash-text); margin-top: 8px;
  font-family: 'DM Mono', monospace; letter-spacing: -0.6px;
}
.dash-kpi-sub { font-size: 12px; color: var(--dash-muted-light); margin-top: 5px; font-weight: 400; }
.dash-kpi-sparkline {
  margin-top: 14px; height: 40px; display: flex; align-items: flex-end; gap: 2px;
}
.dash-kpi-sparkline svg { width: 100%; height: 100%; }

/* ── Section Containers ────────────────────────────────── */
.dash-section { margin-bottom: 32px; }
.dash-section-title {
  font-size: 13px; font-weight: 600; color: var(--dash-text);
  margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.15px;
  animation: dash-fade-up 400ms cubic-bezier(.16,1,.3,1) forwards;
}
.dash-section-title .section-icon {
  width: 30px; height: 30px; border-radius: var(--dash-radius-xs);
  background: linear-gradient(135deg, var(--dash-primary-light), #dbeafe);
  color: var(--dash-primary); display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
}

/* ── AI Insights ─────────────────────────────────────────── */
.dash-insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.dash-insight-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  padding: 20px;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--dash-shadow-sm);
  position: relative; overflow: hidden;
  animation: dash-fade-up 450ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-insight-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.dash-insight-card.alert::before { background: linear-gradient(180deg, var(--dash-danger), #f87171); }
.dash-insight-card.warning::before { background: linear-gradient(180deg, var(--dash-warn), #fbbf24); }
.dash-insight-card.info::before { background: linear-gradient(180deg, var(--dash-primary), #60a5fa); }
.dash-insight-card.success::before { background: linear-gradient(180deg, var(--dash-success), #34d399); }
.dash-insight-card:hover { transform: translateY(-3px); box-shadow: var(--dash-shadow-lg); border-color: rgba(37,99,235,0.15); }
.dash-insight-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.dash-insight-title { font-size: 13px; font-weight: 600; color: var(--dash-text); letter-spacing: -0.1px; }
.dash-insight-metric {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: #f1f5f9; color: var(--dash-muted);
}
.dash-insight-message { font-size: 13px; color: var(--dash-text-secondary); line-height: 1.6; margin-bottom: 12px; font-weight: 400; }
.dash-insight-action {
  font-size: 12px; color: var(--dash-primary); font-weight: 500; background: var(--dash-primary-light);
  padding: 6px 12px; border-radius: 8px; display: inline-block;
  transition: all .15s;
}
.dash-insight-action:hover { background: #dbeafe; }

/* ── Health Score Ring ───────────────────────────────────── */
.dash-health-ring {
  display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
}
.dash-health-ring svg { transform: rotate(-90deg); }
.dash-health-ring .score-label { font-size: 11px; font-weight: 600; color: var(--dash-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.dash-health-ring .score-value { font-size: 20px; font-weight: 700; font-family: 'DM Mono', monospace; }

/* ── Charts ──────────────────────────────────────────────── */
.dash-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.dash-chart-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  padding: 22px;
  box-shadow: var(--dash-shadow-sm);
  transition: all .3s cubic-bezier(.4,0,.2,1);
  animation: dash-fade-up 450ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-chart-card:hover { box-shadow: var(--dash-shadow-lg); border-color: rgba(37,99,235,0.15); transform: translateY(-2px); }
.dash-chart-title { font-size: 13px; font-weight: 600; color: var(--dash-text); margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; letter-spacing: -0.1px; }
.dash-chart-container { position: relative; height: 260px; }
.dash-chart-container.small { height: 200px; }

/* ── Smart Tables ────────────────────────────────────────── */
.dash-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 18px; margin-bottom: 28px;
}
.dash-table-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius);
  padding: 0;
  box-shadow: var(--dash-shadow-sm);
  overflow: hidden;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  animation: dash-fade-up 450ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-table-card:hover { box-shadow: var(--dash-shadow-lg); border-color: rgba(37,99,235,0.12); }
.dash-table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--dash-border);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}
.dash-table-header h4 { font-size: 13px; font-weight: 600; color: var(--dash-text); margin: 0; letter-spacing: -0.1px; }
.dash-table-header .table-actions { display: flex; gap: 8px; }
.dash-table-header .table-actions button {
  font-size: 11px; font-weight: 500; padding: 5px 11px; border-radius: 8px;
  border: 1px solid var(--dash-border); background: #fff; color: var(--dash-muted); cursor: pointer;
  transition: all .15s;
}
.dash-table-header .table-actions button:hover { background: var(--dash-primary-light); color: var(--dash-primary); border-color: #bfdbfe; transform: translateY(-1px); }
.dash-table-body { padding: 0; max-height: 320px; overflow: auto; }
.dash-table-body table { width: 100%; border-collapse: collapse; }
.dash-table-body th {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9); padding: 11px 16px; text-align: left; font-size: 10px;
  font-weight: 600; color: var(--dash-muted); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--dash-border); position: sticky; top: 0; z-index: 1;
}
.dash-table-body td { padding: 11px 16px; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: var(--dash-text-secondary); vertical-align: middle; transition: background .12s; }
.dash-table-body tr { transition: background .12s; }
.dash-table-body tr:hover td { background: #f8fafc; }
.dash-table-body tr:last-child td { border-bottom: none; }
.dash-table-body .cell-amount { font-family: 'DM Mono', monospace; font-weight: 600; color: var(--dash-text); letter-spacing: -0.3px; }
.dash-table-body .cell-client { font-weight: 500; color: var(--dash-text); }
.dash-table-body .cell-muted { color: var(--dash-muted); font-size: 12px; }
.dash-table-body .cell-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.dash-table-body .cell-badge.paid { background: linear-gradient(135deg, #d1fae5, #ecfdf5); color: #065f46; }
.dash-table-body .cell-badge.unpaid { background: linear-gradient(135deg, #fef3c7, #fffbeb); color: #92400e; }
.dash-table-body .cell-badge.overdue { background: linear-gradient(135deg, #fee2e2, #fef2f2); color: #991b1b; }
.dash-table-body .cell-badge.pending { background: linear-gradient(135deg, #f1f5f9, #f8fafc); color: #475569; }

/* ── Alert Center ──────────────────────────────────────────── */
.dash-alerts-list {
  display: flex; flex-direction: column; gap: 12px;
}
.dash-alert-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px; background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border); border-radius: var(--dash-radius-sm);
  box-shadow: var(--dash-shadow-sm); transition: all .25s cubic-bezier(.4,0,.2,1);
  animation: dash-fade-up 400ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-alert-item:hover { transform: translateX(6px); box-shadow: var(--dash-shadow-md); border-color: rgba(37,99,235,0.12); }
.dash-alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.dash-alert-content { flex: 1; min-width: 0; }
.dash-alert-title { font-size: 13px; font-weight: 600; color: var(--dash-text); margin-bottom: 3px; letter-spacing: -0.1px; }
.dash-alert-message { font-size: 12px; color: var(--dash-text-secondary); line-height: 1.5; font-weight: 400; }
.dash-alert-priority {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 3px 9px; border-radius: 20px; flex-shrink: 0;
}
.dash-alert-priority.high { background: linear-gradient(135deg, #fee2e2, #fef2f2); color: #991b1b; }
.dash-alert-priority.medium { background: linear-gradient(135deg, #fef3c7, #fffbeb); color: #92400e; }
.dash-alert-priority.low { background: linear-gradient(135deg, #e0e7ff, #eef2ff); color: #3730a3; }

/* ── AI Assistant Panel ──────────────────────────────────── */
.dash-ai-float {
  position: fixed; bottom: 24px; right: 24px; z-index: 90;
}
.dash-ai-toggle {
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--dash-primary), #6366f1);
  color: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 6px 22px rgba(37,99,235,0.30);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .3s cubic-bezier(.4,0,.2,1); animation: dash-pulse-soft 3s infinite;
}
.dash-ai-toggle:hover { transform: scale(1.1); box-shadow: 0 10px 32px rgba(37,99,235,0.40); }
.dash-ai-panel {
  position: absolute; bottom: 68px; right: 0; width: 360px; max-height: 500px;
  background: var(--dash-surface-solid); border: 1px solid var(--dash-border);
  border-radius: var(--dash-radius); box-shadow: var(--dash-shadow-xl);
  display: none; flex-direction: column; overflow: hidden;
  animation: dash-scale-in 250ms cubic-bezier(.16,1,.3,1) forwards;
}
.dash-ai-panel.open { display: flex; }
.dash-ai-header {
  padding: 16px 20px; border-bottom: 1px solid var(--dash-border);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, var(--dash-primary-light), #dbeafe);
}
.dash-ai-header h4 { font-size: 14px; font-weight: 600; color: var(--dash-primary); margin: 0; letter-spacing: -0.1px; }
.dash-ai-close { background: none; border: none; color: var(--dash-muted); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; transition: all .15s; }
.dash-ai-close:hover { background: rgba(37,99,235,0.08); color: var(--dash-primary); }
.dash-ai-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dash-ai-message {
  padding: 11px 15px; border-radius: 14px; font-size: 13px; line-height: 1.55; max-width: 90%; font-weight: 400;
  animation: dash-fade-up 200ms ease forwards;
}
.dash-ai-message.bot { background: #f8fafc; color: var(--dash-text-secondary); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 1px 3px rgba(15,23,42,0.04); }
.dash-ai-message.user { background: linear-gradient(135deg, var(--dash-primary), #6366f1); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: 0 4px 12px rgba(37,99,235,0.20); }
.dash-ai-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.dash-ai-suggestion {
  font-size: 11px; font-weight: 500; padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--dash-border); background: #fff; color: var(--dash-primary); cursor: pointer;
  transition: all .15s;
}
.dash-ai-suggestion:hover { background: var(--dash-primary-light); border-color: #bfdbfe; transform: translateY(-1px); }
.dash-ai-input-row {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--dash-border); background: #f8fafc;
}
.dash-ai-input-row input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--dash-border); border-radius: var(--dash-radius-xs); font-size: 13px; background: #fff; color: var(--dash-text);
  transition: all .2s;
}
.dash-ai-input-row input:focus { border-color: var(--dash-primary); outline: none; box-shadow: var(--dash-glow-primary); }
.dash-ai-input-row button {
  padding: 9px 16px; border: none; border-radius: var(--dash-radius-xs); background: var(--dash-primary); color: #fff;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.dash-ai-input-row button:hover { background: var(--dash-primary-h, #1d4ed8); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.20); }

/* ── Predictions Panel ───────────────────────────────────── */
.dash-predictions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.dash-prediction-card {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--dash-border); border-radius: var(--dash-radius-sm);
  padding: 20px; text-align: center; box-shadow: var(--dash-shadow-sm);
  transition: all .3s cubic-bezier(.4,0,.2,1);
  animation: dash-fade-up 450ms cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.dash-prediction-card:hover { transform: translateY(-3px); box-shadow: var(--dash-shadow-lg); border-color: rgba(37,99,235,0.15); }
.dash-prediction-icon { font-size: 26px; margin-bottom: 10px; transition: transform .3s; }
.dash-prediction-card:hover .dash-prediction-icon { transform: scale(1.1); }
.dash-prediction-label { font-size: 11px; font-weight: 500; color: var(--dash-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dash-prediction-value { font-size: 19px; font-weight: 600; color: var(--dash-text); margin-top: 6px; font-family: 'DM Mono', monospace; letter-spacing: -0.4px; }
.dash-prediction-sub { font-size: 11px; color: var(--dash-muted-light); margin-top: 5px; font-weight: 400; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-chart-grid { grid-template-columns: 1fr; }
  .dash-table-grid { grid-template-columns: 1fr; }
  .dash-insights-grid { grid-template-columns: 1fr; }
  .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-actions { grid-template-columns: repeat(3, 1fr); }
  .dash-ai-panel { width: 320px; right: -20px; }
}

/* ── CLIENT FILTER TOOLBAR ───────────────────── */
.filter-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 20px;margin-bottom:20px;box-shadow:var(--shadow)}
.filter-toolbar{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.filter-search{position:relative;flex:1;min-width:260px}
.filter-search-icon{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--muted);pointer-events:none}
.filter-search-input{width:100%;padding:8px 12px 8px 34px;border:1px solid var(--border);border-radius:8px;font-size:13px;outline:none;transition:border .12s,box-shadow .12s;background:var(--surface)}
.filter-search-input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.1)}
.filter-group{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.filter-select{padding:8px 28px 8px 10px;border:1px solid var(--border);border-radius:8px;font-size:13px;outline:none;transition:border .12s,box-shadow .12s;background:var(--surface);cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center}
.filter-select:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.1)}
.filter-clear{display:inline-flex;align-items:center;gap:4px}
.filter-meta{font-size:12px;color:var(--muted);margin-top:10px;padding-top:10px;border-top:1px solid #F1F5F9}

/* ── CLIENT TYPE BADGES ──────────────────────── */
.badge-client-retail{background:#E0F2FE;color:#0369A1}
.badge-client-wholesale{background:#F3E8FF;color:#7E22CE}
.badge-client-distributor{background:#FEF3C7;color:#92400E}
.badge-client-corporate{background:#DCFCE7;color:#15803D}
.badge-client-government{background:#FEE2E2;color:#991B1B}
.badge-client-export{background:#E0E7FF;color:#3730A3}
.badge-client-service{background:#F1F5F9;color:#475569}

/* ── PARTY TABLE ───────────────────────────────── */
.party-name-wrap{display:flex;flex-direction:column;gap:4px;align-items:flex-start}
.party-name{font-size:13.5px}
.party-location{color:var(--muted);font-size:12.5px}
.party-actions .btn-icon{color:var(--muted);padding:6px;border-radius:6px;transition:all .12s}
.party-actions .btn-icon:hover{background:var(--primary-light);color:var(--primary)}
.party-table tbody tr{transition:background .12s}
.party-table tbody tr:hover td{background:#F1F5F9}

/* ── PAGINATION ────────────────────────────────── */
.pagination-bar{display:flex;justify-content:center;align-items:center;gap:12px;margin-top:16px;padding:12px 0}
.pagination-info{font-size:12px;color:var(--muted);font-weight:500}
.pagination-bar .btn:disabled{opacity:.45;cursor:not-allowed}

@media (max-width: 768px) {
  .dash-topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .dash-topbar-right { justify-content: space-between; }
  .dash-kpi-grid { grid-template-columns: 1fr; }
  .dash-actions { grid-template-columns: repeat(2, 1fr); }
  .dash-chart-grid { grid-template-columns: 1fr; }
  .dash-table-grid { grid-template-columns: 1fr; }
  .dash-predictions-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-ai-panel { width: calc(100vw - 48px); right: 0; max-height: 60vh; }
  .dash-ai-float { right: 16px; bottom: 16px; }
  .filter-toolbar { flex-direction: column; align-items: stretch; }
  .filter-search { min-width: 100%; }
  .filter-group { width: 100%; }
  .filter-select { flex: 1; min-width: 0; }
}
/* ── WHATSAPP SHARE ────────────────────────────── */
.btn-wa{background:#25D366;color:#fff;border:none;transition:all .12s}
.btn-wa:hover{background:#128C7E;transform:scale(1.05)}
.wa-dropdown{position:absolute;right:0;top:100%;background:#fff;border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow-lg);z-index:50;min-width:180px;display:none;overflow:hidden}
.wa-dropdown.open{display:block}
.wa-dropdown button{display:flex;align-items:center;gap:8px;width:100%;padding:9px 12px;border:none;background:none;font-size:13px;cursor:pointer;color:var(--text);text-align:left;white-space:nowrap}
.wa-dropdown button:hover{background:var(--primary-light);color:var(--primary)}
.actions{position:relative}

@media (max-width: 480px) {
  .dash-actions { grid-template-columns: repeat(2, 1fr); }
  .dash-kpi-grid { grid-template-columns: 1fr; }
  .dash-predictions-grid { grid-template-columns: 1fr; }
  .dash-search input { width: 140px; }
  .dash-search input:focus { width: 180px; }
}

/* ════════════════════════════════════════════════════════════
   PREMIUM EXPENSES PAGE Redesign
   ════════════════════════════════════════════════════════════ */

/* Header & Title */
.expense-header-wrap {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; flex-wrap: wrap; gap: 16px;
}
.expense-title-group h2 { font-size: 24px; font-weight: 700; color: #0f172a; margin: 0 0 4px; letter-spacing: -0.5px; }
.expense-subtitle { font-size: 13px; color: #64748b; margin: 0; font-weight: 400; }
.expense-header-actions { display: flex; gap: 10px; align-items: center; }

/* Premium KPI Cards */
.expense-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 28px; }
.expense-kpi-card {
  background: linear-gradient(145deg, #ffffff, #fafafa);
  border: 1px solid #e2e8f0; border-radius: 16px; padding: 22px 20px;
  position: relative; overflow: hidden; box-shadow: 0 2px 10px rgba(15,23,42,0.03);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.expense-kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; opacity: 0.85; transition: opacity 0.3s;
}
.expense-kpi-card.kpi-total::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.expense-kpi-card.kpi-paid::before { background: linear-gradient(90deg, #10b981, #34d399); }
.expense-kpi-card.kpi-pending::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.expense-kpi-card.kpi-recurring::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.expense-kpi-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(15,23,42,0.06); border-color: rgba(37,99,235,0.15); }

.expense-kpi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.expense-kpi-label { font-size: 12px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.expense-kpi-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: transform 0.3s;
}
.expense-kpi-card:hover .expense-kpi-icon { transform: scale(1.1) rotate(5deg); }
.kpi-total .expense-kpi-icon { background: #eff6ff; color: #2563eb; box-shadow: 0 0 15px rgba(37,99,235,0.15); }
.kpi-paid .expense-kpi-icon { background: #ecfdf5; color: #059669; box-shadow: 0 0 15px rgba(16,185,129,0.15); }
.kpi-pending .expense-kpi-icon { background: #fffbeb; color: #d97706; box-shadow: 0 0 15px rgba(245,158,11,0.15); }
.kpi-recurring .expense-kpi-icon { background: #f5f3ff; color: #7c3aed; box-shadow: 0 0 15px rgba(139,92,246,0.15); }

.expense-kpi-value { font-size: 26px; font-weight: 700; color: #0f172a; font-family: 'DM Mono', monospace; letter-spacing: -0.5px; line-height: 1.1; margin-bottom: 6px; }
.expense-kpi-trend { font-size:12px; font-weight:500; display:inline-flex; align-items:center; gap:4px; }
.trend-up { color:#059669; } .trend-down { color:#dc2626; } .trend-neutral { color:#64748b; }

.expense-filter-toolbar {
  display:flex; gap:12px; flex-wrap:wrap; align-items:center;
  padding:14px 18px; background:rgba(255,255,255,.85); backdrop-filter:blur(8px);
  border:1px solid #e2e8f0; border-radius:14px; margin-bottom:24px;
  box-shadow:0 2px 8px rgba(15,23,42,.02); position:sticky; top:10px; z-index:10;
}
.expense-filter-group { display:flex; align-items:center; position:relative; }
.expense-search-input { padding:9px 14px 9px 36px; border:1px solid #cbd5e1; border-radius:8px; font-size:13px; min-width:240px; background:#fff; transition:all .2s; }
.expense-search-input:focus { border-color:#2563eb; outline:none; box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.expense-search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:#94a3b8; pointer-events:none; }
.expense-select,.expense-date { padding:9px 28px 9px 12px; border:1px solid #cbd5e1; border-radius:8px; font-size:13px; background:#fff; color:#334155; transition:all .2s; outline:none; cursor:pointer; height:38px; }
.expense-select { appearance:none; background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 10px center; }
.expense-select:focus,.expense-date:focus { border-color:#2563eb; box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.expense-filter-toolbar .btn-ghost { height:38px; display:inline-flex; align-items:center; justify-content:center; padding:0 14px; font-size:13px; font-weight:500; color:#64748b; background:transparent; border:1px solid transparent; border-radius:8px; transition:all .2s; cursor:pointer; }
.expense-filter-toolbar .btn-ghost:hover { background:#f1f5f9; color:#0f172a; border-color:#e2e8f0; }

.expense-table-wrap { background:#fff; border:1px solid #e2e8f0; border-radius:16px; overflow:hidden; box-shadow:0 4px 12px rgba(15,23,42,.03); }
.expense-table { width:100%; border-collapse:separate; border-spacing:0; }
.expense-table th { background:#f8fafc; padding:14px 18px; text-align:left; font-size:11px; font-weight:600; color:#64748b; text-transform:uppercase; letter-spacing:.05em; border-bottom:1px solid #e2e8f0; position:sticky; top:0; z-index:5; }
.expense-table th.right,.expense-table td.right { text-align:right; }
.expense-table td { padding:14px 18px; font-size:13px; color:#334155; border-bottom:1px solid #f1f5f9; transition:background .2s; vertical-align:middle; }
.expense-table tr:nth-child(even) td { background:#fafafc; }
.expense-table tr:hover td { background:#f1f5f9; }
.expense-table tr:last-child td { border-bottom:none; }
.expense-id-cell { font-family:'DM Mono',monospace; font-weight:600; color:#0f172a; font-size:12px; }
.expense-vendor-cell { font-weight:500; color:#0f172a; }
.expense-amount-cell { font-family:'DM Mono',monospace; font-weight:700; color:#0f172a; font-size:14px; letter-spacing:-.3px; }
.badge-expense { display:inline-flex; align-items:center; padding:4px 10px; border-radius:20px; font-size:11px; font-weight:600; letter-spacing:.02em; }
.badge-expense.paid { background:#ecfdf5; color:#059669; border:1px solid #a7f3d0; }
.badge-expense.pending { background:#fffbeb; color:#d97706; border:1px solid #fde68a; }
.badge-expense.partial { background:#eff6ff; color:#2563eb; border:1px solid #bfdbfe; }
.badge-expense.overdue { background:#fef2f2; color:#dc2626; border:1px solid #fecaca; }
.badge-expense.cancelled { background:#f1f5f9; color:#64748b; border:1px solid #cbd5e1; }
.badge-expense.low { background:#f8fafc; color:#475569; }
.badge-expense.medium { background:#eff6ff; color:#3b82f6; }
.badge-expense.high { background:#fffbeb; color:#f59e0b; }
.badge-expense.critical { background:#fef2f2; color:#ef4444; }
.expense-action-btn { width:32px; height:32px; border-radius:8px; border:1px solid transparent; background:transparent; color:#64748b; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; transition:all .2s; }
.expense-action-btn:hover { background:#f1f5f9; color:#2563eb; border-color:#cbd5e1; }
.expense-action-btn.danger:hover { background:#fef2f2; color:#dc2626; border-color:#fecaca; }
.expense-action-btn svg { width:14px; height:14px; }
.expense-empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:80px 24px; text-align:center; background:#fff; border-radius:16px; border:1px dashed #cbd5e1; }
.expense-empty-illustration { width:80px; height:80px; background:linear-gradient(135deg,#eff6ff,#dbeafe); border-radius:24px; display:flex; align-items:center; justify-content:center; font-size:36px; margin-bottom:24px; box-shadow:0 8px 16px rgba(37,99,235,.1); }
.expense-empty-title { font-size:18px; font-weight:700; color:#0f172a; margin:0 0 8px; }
.expense-empty-desc { font-size:14px; color:#64748b; max-width:340px; margin:0 0 24px; line-height:1.6; }
@media (max-width:768px) {
  .expense-header-wrap { flex-direction:column; align-items:stretch; }
  .expense-kpi-grid { grid-template-columns:1fr 1fr; }
  .expense-filter-toolbar { flex-direction:column; align-items:stretch; }
  .expense-table-wrap { overflow-x:auto; }
}
@media (max-width:480px) { .expense-kpi-grid { grid-template-columns:1fr; } }

/* ═══ GLOBAL TOPBAR ═══ */
.global-topbar { position:sticky; top:0; z-index:100; display:flex; align-items:center; justify-content:space-between; padding:0 28px; height:56px; background:rgba(255,255,255,.82); backdrop-filter:blur(16px) saturate(1.8); -webkit-backdrop-filter:blur(16px) saturate(1.8); border-bottom:1px solid rgba(226,232,240,.55); margin:-28px -32px 28px; }
.topbar-left { display:flex; align-items:center; gap:14px; flex:1; }
.topbar-center { display:flex; align-items:center; justify-content:center; flex:2; }
.topbar-right { display:flex; align-items:center; gap:6px; flex:1; justify-content:flex-end; }
.topbar-divider { width:1px; height:24px; background:#e2e8f0; margin:0 6px; }
.topbar-search-wrap { display:flex; align-items:center; gap:8px; background:#f1f5f9; border:1px solid #e2e8f0; border-radius:10px; padding:7px 14px; width:100%; max-width:420px; transition:all .2s; }
.topbar-search-wrap:focus-within { background:#fff; border-color:#cbd5e1; box-shadow:0 0 0 3px rgba(37,99,235,.06); }
.topbar-search-wrap input { border:none!important; background:transparent!important; outline:none; padding:0!important; font-size:13px; color:#0f172a; width:100%; box-shadow:none!important; }
.topbar-search-wrap input::placeholder { color:#94a3b8; }
.topbar-kbd { font-family:'DM Mono',monospace; font-size:10px; font-weight:600; color:#94a3b8; background:#e2e8f0; padding:2px 5px; border-radius:4px; line-height:1; }
.topbar-icon-btn { width:34px; height:34px; border-radius:8px; border:1px solid transparent; background:transparent; color:#64748b; display:inline-flex; align-items:center; justify-content:center; cursor:pointer; transition:all .15s; position:relative; }
.topbar-icon-btn:hover { background:#f1f5f9; color:#0f172a; }
.topbar-icon-btn.ai-btn { background:linear-gradient(135deg,#eff6ff,#dbeafe); color:#2563eb; border-color:#bfdbfe; }
.topbar-icon-btn.ai-btn:hover { background:linear-gradient(135deg,#dbeafe,#bfdbfe); box-shadow:0 2px 8px rgba(37,99,235,.12); }

/* ═══ PROFILE ═══ */
.profile-menu-wrap { position:relative; }
.profile-trigger { display:flex; align-items:center; gap:6px; background:transparent; border:none; cursor:pointer; padding:4px 6px 4px 4px; border-radius:20px; transition:all .15s; }
.profile-trigger:hover { background:#f1f5f9; }
.profile-avatar { width:30px; height:30px; border-radius:50%; background:linear-gradient(135deg,#3b82f6,#6366f1); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size:12px; font-family:'DM Mono',monospace; }
.profile-dropdown { position:absolute; top:calc(100% + 8px); right:0; width:220px; background:#fff; border:1px solid #e2e8f0; border-radius:12px; box-shadow:0 12px 28px -4px rgba(15,23,42,.1),0 4px 8px -2px rgba(15,23,42,.04); padding:6px 0; opacity:0; visibility:hidden; pointer-events:none; transform:translateY(-8px) scale(.97); transition:all .18s cubic-bezier(.16,1,.3,1); z-index:1000; }
.profile-dropdown.open { opacity:1; visibility:visible; pointer-events:auto; transform:translateY(0) scale(1); }
.profile-dropdown-header { padding:10px 14px; border-bottom:1px solid #f1f5f9; margin-bottom:4px; }
.profile-dropdown-name { font-weight:600; color:#0f172a; font-size:13px; }
.profile-dropdown-email { color:#94a3b8; font-size:11px; margin-top:1px; }
.profile-dropdown-item { display:flex; align-items:center; gap:10px; padding:7px 14px; color:#334155; font-size:13px; font-weight:500; background:transparent; border:none; width:100%; text-align:left; cursor:pointer; transition:all .12s; text-decoration:none; }
.profile-dropdown-item svg { color:#94a3b8; flex-shrink:0; transition:color .12s; }
.profile-dropdown-item:hover { background:#f8fafc; color:#2563eb; }
.profile-dropdown-item:hover svg { color:#2563eb; }
.profile-dropdown-item.danger:hover { color:#dc2626; background:#fef2f2; }
.profile-dropdown-item.danger:hover svg { color:#dc2626; }
.profile-dropdown-divider { height:1px; background:#f1f5f9; margin:4px 0; }

/* ═══ AI PANEL ═══ */
.topbar-ai-wrap { position:relative; }
.ai-panel { position:absolute; top:calc(100% + 10px); right:-20px; width:360px; height:440px; max-height:calc(100vh - 80px); background:#fff; border:1px solid #e2e8f0; border-radius:14px; box-shadow:0 16px 40px -8px rgba(15,23,42,.12),0 4px 12px -4px rgba(15,23,42,.06); display:flex; flex-direction:column; opacity:0; visibility:hidden; pointer-events:none; transform:translateY(-8px) scale(.97); transition:all .2s cubic-bezier(.16,1,.3,1); z-index:999; }
.ai-panel.open { opacity:1; visibility:visible; pointer-events:auto; transform:translateY(0) scale(1); }
.ai-panel-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #f1f5f9; }
.ai-panel-close { background:none; border:none; cursor:pointer; color:#94a3b8; font-size:16px; padding:2px 6px; border-radius:6px; transition:all .12s; }
.ai-panel-close:hover { background:#f1f5f9; color:#0f172a; }
.ai-panel-body { flex:1; overflow-y:auto; padding:14px 16px; display:flex; flex-direction:column; gap:10px; }
.ai-msg { padding:10px 14px; border-radius:12px; font-size:13px; line-height:1.55; max-width:90%; animation:dash-fade-up .3s ease forwards; }
.ai-msg.bot { background:#f8fafc; color:#334155; align-self:flex-start; border:1px solid #e2e8f0; }
.ai-msg.user { background:linear-gradient(135deg,#2563eb,#3b82f6); color:#fff; align-self:flex-end; }
.ai-suggestions { display:flex; flex-wrap:wrap; gap:6px; margin-top:4px; }
.ai-suggestions button { background:#f1f5f9; border:1px solid #e2e8f0; border-radius:20px; padding:5px 12px; font-size:12px; color:#475569; cursor:pointer; transition:all .12s; font-family:inherit; }
.ai-suggestions button:hover { background:#eff6ff; border-color:#bfdbfe; color:#2563eb; }
.ai-panel-input { display:flex; align-items:center; gap:8px; padding:10px 14px; border-top:1px solid #f1f5f9; }
.ai-panel-input input { flex:1; border:1px solid #e2e8f0; border-radius:8px; padding:8px 12px; font-size:13px; outline:none; font-family:inherit; transition:border .12s; }
.ai-panel-input input:focus { border-color:#2563eb; }
.ai-panel-input button { width:34px; height:34px; border-radius:8px; border:none; background:#2563eb; color:#fff; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all .12s; flex-shrink:0; }
.ai-panel-input button:hover { background:#1d4ed8; }

/* ═══ SHORTCUT TOAST ═══ */
.shortcut-toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(16px); background:rgba(15,23,42,.92); backdrop-filter:blur(8px); color:#fff; padding:10px 20px; border-radius:28px; font-size:13px; font-weight:500; display:flex; align-items:center; gap:8px; box-shadow:0 8px 20px rgba(15,23,42,.2); opacity:0; visibility:hidden; transition:all .25s cubic-bezier(.16,1,.3,1); z-index:9999; }
.shortcut-toast.show { opacity:1; visibility:visible; transform:translateX(-50%) translateY(0); }
.kbd-tag { background:rgba(255,255,255,.15); padding:2px 7px; border-radius:4px; font-family:'DM Mono',monospace; font-size:11px; font-weight:600; }

/* ═══ SIDEBAR REFINEMENTS ═══ */
.sidebar { border-right-color:rgba(226,232,240,.7); }
.sidebar nav a { position:relative; transition:all .15s ease; margin:1px 10px; padding:9px 12px; border-radius:8px; }
.sidebar nav a:hover { background:rgba(37,99,235,.04); color:#2563eb; transform:translateX(2px); }
.sidebar nav a.active { background:rgba(37,99,235,.08); color:#2563eb; font-weight:600; }
.sidebar nav a.active::before { content:''; position:absolute; left:-10px; top:50%; transform:translateY(-50%); height:18px; width:3px; background:linear-gradient(180deg,#2563eb,#3b82f6); border-radius:0 3px 3px 0; }
.nav-section { font-size:9.5px; letter-spacing:.1em; color:#cbd5e1; padding:14px 12px 5px; }
@media (max-width:768px) {
  .global-topbar { padding:0 16px; height:52px; margin:-28px -16px 20px; }
  .topbar-search-wrap { width:160px; }
  .topbar-kbd { display:none; }
  .ai-panel { width:calc(100vw - 32px); right:-60px; }
  .profile-dropdown { right:-8px; }
}

/* ════════════════════════════════════════════════════════════
   PREMIUM CLIENTS / VENDORS PAGE
   ════════════════════════════════════════════════════════════ */

/* ── Page Header ── */
.page-header { margin-bottom:20px; }
.page-header h1 { font-size:24px; font-weight:700; letter-spacing:-.5px; color:#0f172a; margin-bottom:1px; }
.page-subtitle { font-size:13px; color:#94a3b8; font-weight:400; margin:0; line-height:1.4; }
.page-header-actions { display:flex; gap:8px; align-items:center; }
.page-header .btn-primary {
  background:linear-gradient(135deg,#2563eb,#3b82f6); border:none;
  padding:9px 20px; font-weight:600; font-size:13px; border-radius:10px;
  box-shadow:0 2px 8px rgba(37,99,235,.18); transition:all .18s ease;
}
.page-header .btn-primary:hover {
  background:linear-gradient(135deg,#1d4ed8,#2563eb);
  box-shadow:0 4px 16px rgba(37,99,235,.28); transform:translateY(-1px);
}
.page-header .btn-secondary {
  padding:9px 16px; border-radius:10px; font-weight:500; font-size:13px;
  border:1px solid #e2e8f0; color:#475569; transition:all .15s;
}
.page-header .btn-secondary:hover { background:#f8fafc; border-color:#cbd5e1; }

/* ── Filter Card ── */
.filter-card {
  background:rgba(255,255,255,.92); backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
  border:1px solid rgba(226,232,240,.55); border-radius:14px;
  padding:12px 16px 8px; margin-bottom:16px;
  box-shadow:0 1px 3px rgba(15,23,42,.03), 0 4px 14px rgba(15,23,42,.02);
}
.client-filter-card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:12px 16px; margin-bottom:16px;
  box-shadow:var(--shadow);
}
.client-filter-card .filter-search { position:relative; }
.client-filter-card .filter-search-input {
  width:100%; padding:8px 11px 8px 36px !important;
}
.client-filter-card .filter-select {
  width:100%; padding:8px 30px 8px 11px !important; height:auto;
  min-width:auto; max-width:none;
}
.filter-toolbar {
  display:flex; gap:8px; align-items:center;
}
.filter-search { position:relative; flex:1.8; min-width:180px; }
.filter-search-icon {
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  color:#94a3b8; pointer-events:none; z-index:1;
}
.filter-search-input {
  width:100%; padding:7px 12px 7px 34px !important; height:36px;
  border:1px solid #e2e8f0 !important; border-radius:9px !important;
  font-size:13px; background:#f8fafc !important; color:#0f172a;
  transition:all .18s; font-family:inherit;
}
.filter-search-input::placeholder { color:#a0aec0; font-weight:400; }
.filter-search-input:focus {
  background:#fff !important; border-color:#2563eb !important;
  box-shadow:0 0 0 3px rgba(37,99,235,.08) !important; outline:none;
}
.filter-select {
  padding:7px 28px 7px 11px !important; height:36px;
  border:1px solid #e2e8f0 !important; border-radius:9px !important;
  font-size:12.5px; color:#334155; background:#f8fafc !important;
  cursor:pointer; min-width:80px; flex-shrink:0;
  appearance:none; font-family:inherit;
  background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat:no-repeat !important; background-position:right 9px center !important;
  transition:all .15s;
}
.filter-select:hover { border-color:#cbd5e1 !important; background:#fff !important; }
.filter-select:focus {
  border-color:#2563eb !important; background:#fff !important;
  box-shadow:0 0 0 3px rgba(37,99,235,.08) !important; outline:none;
}
.filter-clear-btn {
  display:inline-flex; align-items:center; gap:4px; height:36px;
  padding:0 12px; border-radius:9px; border:1px solid #e2e8f0;
  background:#fff; color:#64748b; font-size:12px; font-weight:500;
  cursor:pointer; white-space:nowrap; transition:all .15s; font-family:inherit;
  flex-shrink:0;
}
.filter-clear-btn:hover { background:#fef2f2; border-color:#fecaca; color:#dc2626; }
.filter-clear-btn svg { transition:transform .2s; }
.filter-clear-btn:hover svg { transform:rotate(90deg); }
.filter-meta {
  font-size:11.5px; color:#94a3b8; font-weight:500; margin-top:8px;
  padding-top:7px; border-top:1px solid rgba(241,245,249,.7);
}
.filter-count { font-weight:700; color:#475569; font-family:'DM Mono',monospace; font-size:12px; }

/* ── Table ── */
.table-wrap { border-radius:14px; box-shadow:0 1px 3px rgba(15,23,42,.03), 0 4px 14px rgba(15,23,42,.02); overflow:hidden; }
.party-table { width:100%; border-collapse:separate; border-spacing:0; }
.party-table th {
  background:#f8fafc; padding:11px 16px; text-align:left;
  font-size:10px; font-weight:700; color:#94a3b8; text-transform:uppercase;
  letter-spacing:.07em; border-bottom:1px solid #e2e8f0;
  position:sticky; top:0; z-index:2; white-space:nowrap;
}
.party-table td {
  padding:12px 16px; font-size:13px; color:#334155;
  border-bottom:1px solid #f1f5f9; vertical-align:middle;
  transition:background .12s ease;
}
.party-table tr:last-child td { border-bottom:none; }
.party-table tbody tr { transition:background .12s ease; }
.party-table tbody tr:hover td { background:rgba(248,250,252,.9); }

/* ── Party Name ── */
.party-name-wrap { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.party-name { font-weight:600; color:#0f172a; font-size:13.5px; letter-spacing:-.01em; }

/* ── GSTIN ── */
.party-gstin {
  font-family:'DM Mono',monospace; font-size:11.5px; color:#64748b;
  background:#f8fafc; padding:3px 8px; border-radius:6px;
  border:1px solid #f1f5f9; letter-spacing:.02em; white-space:nowrap;
}

/* ── Location ── */
.party-location {
  color:#64748b; font-size:12.5px; display:inline-flex; align-items:center; gap:4px;
}
.party-location svg { color:#94a3b8; flex-shrink:0; opacity:.7; }

/* ── Email ── */
.party-email { color:#64748b; font-size:12.5px; }

/* ── Client Type Badges ── */
[class*="badge-client-"] {
  font-size:9.5px; padding:2px 8px; border-radius:20px; font-weight:600;
  text-transform:uppercase; letter-spacing:.04em; white-space:nowrap;
}
.badge-client-retail { background:#eff6ff; color:#2563eb; border:1px solid #bfdbfe; }
.badge-client-wholesale { background:#f0fdf4; color:#16a34a; border:1px solid #bbf7d0; }
.badge-client-distributor { background:#faf5ff; color:#7c3aed; border:1px solid #ddd6fe; }
.badge-client-corporate { background:#fefce8; color:#ca8a04; border:1px solid #fef08a; }
.badge-client-government { background:#fff1f2; color:#e11d48; border:1px solid #fecdd3; }
.badge-client-export { background:#ecfdf5; color:#059669; border:1px solid #a7f3d0; }
.badge-client-service { background:#f0f9ff; color:#0284c7; border:1px solid #bae6fd; }

/* ── Status Badges ── */
.badge.active { background:#ecfdf5; color:#059669; border:1px solid #a7f3d0; }
.badge.inactive { background:#fef2f2; color:#dc2626; border:1px solid #fecaca; }

/* ── Action Buttons ── */
.party-actions { gap:5px !important; flex-wrap:nowrap !important; }
.btn-action {
  width:32px; height:32px; border-radius:8px; border:1px solid transparent;
  background:transparent; display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer; transition:all .18s ease; padding:0; color:#94a3b8;
  position:relative; flex-shrink:0;
}
.btn-action:hover { transform:translateY(-1px); }
.btn-action-wa { color:#16a34a; }
.btn-action-wa:hover {
  background:#dcfce7; border-color:#bbf7d0; color:#15803d;
  box-shadow:0 2px 8px rgba(22,163,74,.12);
}
.btn-action-edit:hover {
  background:#eff6ff; border-color:#bfdbfe; color:#2563eb;
  box-shadow:0 2px 8px rgba(37,99,235,.1);
}
.btn-action-deactivate:hover {
  background:#fef2f2; border-color:#fecaca; color:#dc2626;
  box-shadow:0 2px 8px rgba(220,38,38,.1);
}
/* Tooltip */
.btn-action[title] { position:relative; }
.btn-action[title]::after {
  content:attr(title); position:absolute; bottom:calc(100% + 6px); left:50%;
  transform:translateX(-50%) translateY(4px); background:#1e293b; color:#fff;
  padding:4px 10px; border-radius:6px; font-size:11px; font-weight:500;
  white-space:nowrap; opacity:0; visibility:hidden; pointer-events:none;
  transition:all .15s ease; z-index:50; box-shadow:0 4px 12px rgba(0,0,0,.15);
}
.btn-action[title]:hover::after { opacity:1; visibility:visible; transform:translateX(-50%) translateY(0); }

/* ── Pagination ── */
.pagination-bar {
  display:flex; align-items:center; justify-content:center;
  gap:12px; padding:16px 0 4px; margin-top:12px;
}
.pagination-info { font-size:13px; color:#64748b; font-weight:500; }
.pagination-bar .btn {
  border-radius:10px !important; padding:8px 18px !important;
  font-weight:500; transition:all .15s; font-size:13px;
}
.pagination-bar .btn:disabled { opacity:.35; cursor:not-allowed; }

/* ── Empty State ── */
.empty {
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:64px 24px; text-align:center;
}
.empty .icon { font-size:44px; margin-bottom:14px; opacity:.65; }
.empty p { color:#64748b; font-size:14px; margin-bottom:20px; max-width:320px; line-height:1.6; }

/* ── Responsive ── */
@media (max-width:1024px) {
  .filter-toolbar { flex-wrap:wrap; }
  .filter-search { min-width:100%; flex:1 1 100%; }
  .filter-select { flex:1; min-width:0; }
}
@media (max-width:768px) {
  .filter-toolbar { flex-direction:column; align-items:stretch; gap:6px; }
  .filter-search { min-width:100%; }
  .filter-select { width:100%; max-width:none; }
  .filter-clear-btn { width:100%; justify-content:center; }
  .page-header { flex-direction:column; align-items:flex-start; gap:12px; }
  .page-header-actions { width:100%; }
  .party-table th, .party-table td { padding:10px 12px; font-size:12px; }
  .party-actions { gap:4px !important; }
  .btn-action { width:28px; height:28px; }
}
