:root{
  --bg:#f5f7f5; --surface:#ffffff; --surface-2:#fafbfa; --surface-3:#f2f5f2;
  --border:#e7ebe8; --border-strong:#d9dfda;
  --text:#151c18; --muted:#68736c; --faint:#98a29b;
  --accent:#1f9d5a; --accent-strong:#178047; --accent-soft:#e7f5ed;
  --blue:#2f6fed; --blue-soft:#eaf0fe;
  --amber:#c9821a; --amber-soft:#fbf0dd;
  --red:#d84636; --red-soft:#fbe9e6;
  --shadow:0 1px 2px rgba(20,28,24,.05),0 1px 3px rgba(20,28,24,.04);
  --shadow-lg:0 2px 8px rgba(20,28,24,.06),0 8px 24px rgba(20,28,24,.05);
  --sidebar-width:266px;
}
[data-theme="dark"]{
  --bg:#0d1310; --surface:#141b17; --surface-2:#101712; --surface-3:#1a231d;
  --border:#243029; --border-strong:#2e3c33;
  --text:#e9efea; --muted:#94a099; --faint:#65746c;
  --accent:#35c97a; --accent-strong:#2bb56b; --accent-soft:#132a1d;
  --blue:#5f8dff; --blue-soft:#152238;
  --amber:#e0a247; --amber-soft:#2b2211;
  --red:#f0685a; --red-soft:#2e1512;
  --shadow:0 1px 2px rgba(0,0,0,.35),0 1px 3px rgba(0,0,0,.3);
  --shadow-lg:0 2px 8px rgba(0,0,0,.4),0 12px 30px rgba(0,0,0,.35);
}
*{box-sizing:border-box;margin:0;padding:0;}
body{font-family:'Geist',system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);
     display:flex;min-height:100vh;font-size:14px;-webkit-font-smoothing:antialiased;}
a{color:inherit;text-decoration:none;}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:20px;border:2px solid transparent;background-clip:content-box;}

/* Sidebar */
.sidebar{width:var(--sidebar-width);background:var(--surface);border-right:1px solid var(--border);
  display:flex;flex-direction:column;position:fixed;top:0;left:0;bottom:0;z-index:100;overflow-y:auto;}
.sidebar-brand{padding:22px 20px 18px;display:flex;align-items:center;gap:13px;
  border-bottom:1px solid var(--border);flex-shrink:0;}
.brand-icon{width:44px;height:44px;border-radius:12px;
  background:linear-gradient(150deg,var(--accent),var(--accent-strong));
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 4px 12px rgba(31,157,90,.28);flex-shrink:0;}
.brand-icon i{color:#fff;font-size:20px;}
.brand-icon img{width:100%;height:100%;object-fit:contain;border-radius:12px;}
.brand-name{font-size:14px;font-weight:700;letter-spacing:-.01em;line-height:1.15;}
.brand-sub{font-family:'Geist Mono',monospace;font-size:10.5px;color:var(--faint);margin-top:3px;}
.sidebar-nav{padding:14px 12px;flex:1;display:flex;flex-direction:column;gap:2px;}
.sidebar-section-label{font-size:10.5px;font-weight:600;letter-spacing:.11em;color:var(--faint);
  padding:10px 12px 6px;text-transform:uppercase;}
.sidebar-section-label:not(:first-child){padding-top:16px;}
.nav-item{display:flex;align-items:center;gap:12px;padding:9px 12px;border-radius:9px;
  color:var(--muted);font-size:13.5px;font-weight:500;transition:background .12s,color .12s;}
.nav-item i{font-size:16px;width:18px;text-align:center;flex-shrink:0;}
.nav-item:hover{background:var(--surface-3);color:var(--text);}
.nav-item.active{background:var(--accent-soft);color:var(--accent-strong);font-weight:600;}
.nav-item.active i{color:var(--accent-strong);}
.sidebar-footer{margin-top:auto;padding:14px 12px;border-top:1px solid var(--border);}
.sidebar-user{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:9px;}
.user-avatar{width:34px;height:34px;border-radius:9px;
  background:linear-gradient(150deg,var(--accent),var(--accent-strong));color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex-shrink:0;}
.user-avatar.sm{width:32px;height:32px;font-size:12px;}
.user-name{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.user-role{font-size:11px;color:var(--faint);font-family:'Geist Mono',monospace;}

/* Main */
.main-content{margin-left:var(--sidebar-width);flex:1;min-width:0;display:flex;
  flex-direction:column;min-height:100vh;}

/* Topbar */
.topbar{height:64px;background:var(--surface);border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;padding:0 26px;gap:20px;
  position:sticky;top:0;z-index:50;flex-shrink:0;}
.topbar-left{display:flex;align-items:center;gap:11px;}
.topbar-breadcrumb{font-size:15px;font-weight:600;letter-spacing:-.01em;}
.topbar-sep{color:var(--faint);}
.topbar-page{font-size:14px;color:var(--muted);}
.topbar-right{display:flex;align-items:center;gap:10px;}
.topbar-btn{width:38px;height:38px;border-radius:9px;border:1px solid var(--border);
  background:var(--surface);color:var(--muted);display:flex;align-items:center;
  justify-content:center;cursor:pointer;transition:background .12s,color .12s;}
.topbar-btn:hover{background:var(--surface-3);color:var(--text);}
.topbar-divider{width:1px;height:26px;background:var(--border);}
.topbar-user{display:flex;align-items:center;gap:10px;padding:4px 6px;border-radius:9px;cursor:pointer;}
.topbar-user:hover{background:var(--surface-3);}
.dropdown{display:none;position:absolute;top:calc(100% + 6px);right:0;background:var(--surface);
  border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);
  min-width:170px;z-index:1000;overflow:hidden;}
.dropdown a{display:flex;align-items:center;gap:9px;padding:10px 14px;font-size:13px;font-weight:500;}
.dropdown a:hover{background:var(--surface-3);}
.dropdown a.danger{color:var(--red);}

/* Page */
.page-content{padding:26px;flex:1;}
.page-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:22px;gap:16px;}
.page-title{font-size:20px;font-weight:700;letter-spacing:-.02em;}
.page-subtitle{font-size:13px;color:var(--muted);margin-top:4px;}
.page-icon{width:42px;height:42px;border-radius:11px;background:var(--accent-soft);
  color:var(--accent-strong);display:flex;align-items:center;justify-content:center;
  font-size:18px;flex-shrink:0;}

/* Cards */
.card{background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow);}
.card-header{padding:16px 20px;border-bottom:1px solid var(--border);font-size:14px;
  font-weight:600;display:flex;align-items:center;gap:9px;}
.card-body{padding:20px;}
.grid{display:grid;gap:16px;}
.grid-4{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));}
.grid-2{grid-template-columns:repeat(auto-fit,minmax(320px,1fr));}

/* KPI */
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:14px;
  padding:18px 20px;box-shadow:var(--shadow);}
.kpi-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;}
.kpi-icon{width:38px;height:38px;border-radius:10px;display:flex;align-items:center;
  justify-content:center;font-size:17px;}
.kpi-tag{font-family:'Geist Mono',monospace;font-size:10px;font-weight:600;
  padding:3px 7px;border-radius:5px;background:var(--surface-3);color:var(--faint);
  letter-spacing:.04em;}
.kpi-value{font-size:28px;font-weight:700;letter-spacing:-.03em;line-height:1;}
.kpi-label{font-size:11.5px;color:var(--faint);text-transform:uppercase;
  letter-spacing:.07em;font-weight:600;margin-top:7px;}

/* Table */
.table-container{background:var(--surface);border:1px solid var(--border);
  border-radius:14px;box-shadow:var(--shadow);overflow:hidden;}
.table{width:100%;border-collapse:collapse;font-size:13.5px;}
.table thead tr{background:var(--surface-2);}
.table th{text-align:left;padding:11px 16px;font-size:11px;font-weight:600;
  letter-spacing:.06em;color:var(--faint);text-transform:uppercase;white-space:nowrap;}
.table td{padding:12px 16px;border-top:1px solid var(--border);vertical-align:middle;}
.table tbody tr:hover{background:var(--surface-2);}
.empty-row{text-align:center;color:var(--faint);padding:40px 16px;}

/* Badges */
.badge{display:inline-flex;align-items:center;gap:5px;font-family:'Geist Mono',monospace;
  font-size:11px;font-weight:600;padding:3px 8px;border-radius:6px;}
.badge-success{color:var(--accent-strong);background:var(--accent-soft);}
.badge-danger{color:var(--red);background:var(--red-soft);}
.badge-warning{color:var(--amber);background:var(--amber-soft);}
.badge-info{color:var(--blue);background:var(--blue-soft);}
.badge-muted{color:var(--muted);background:var(--surface-3);}

/* Buttons */
.btn{display:inline-flex;align-items:center;gap:7px;padding:8px 14px;border-radius:9px;
  font-size:13.5px;font-weight:600;cursor:pointer;border:none;
  transition:background .12s,opacity .12s;font-family:'Geist',sans-serif;}
.btn-primary{background:var(--accent);color:#fff;}
.btn-primary:hover{background:var(--accent-strong);}
.btn-danger{background:var(--red-soft);color:var(--red);}
.btn-ghost{background:transparent;color:var(--muted);border:1px solid var(--border);}
.btn-ghost:hover{background:var(--surface-3);color:var(--text);}
.btn-sm{padding:5px 10px;font-size:12px;border-radius:7px;}
.btn:disabled{opacity:.55;cursor:default;}

/* Forms */
.form-label{display:block;font-size:11px;font-weight:600;text-transform:uppercase;
  letter-spacing:.06em;color:var(--muted);margin-bottom:7px;}
.form-control,.form-select{width:100%;background:var(--surface);border:1px solid var(--border);
  border-radius:9px;padding:9px 13px;font-size:13.5px;color:var(--text);outline:none;
  font-family:'Geist',sans-serif;transition:border-color .15s,box-shadow .15s;}
.form-control:focus,.form-select:focus{border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(31,157,90,.12);}

/* Alerts */
.alert{padding:12px 16px;border-radius:10px;font-size:13.5px;margin-bottom:16px;
  display:flex;align-items:center;gap:10px;}
.alert-success{background:var(--accent-soft);color:var(--accent-strong);}
.alert-danger{background:var(--red-soft);color:var(--red);}
.alert-info{background:var(--blue-soft);color:var(--blue);}

.mono{font-family:'Geist Mono',monospace;font-size:12.5px;}
.text-muted{color:var(--muted);}
.text-faint{color:var(--faint);}
.status-dot{width:7px;height:7px;border-radius:50%;display:inline-block;flex-shrink:0;}
.status-dot.active{background:var(--accent);box-shadow:0 0 0 3px var(--accent-soft);}
.status-dot.inactive{background:var(--faint);box-shadow:0 0 0 3px var(--surface-3);}

/* Modal */
.modal-backdrop{position:fixed;inset:0;background:rgba(10,16,12,.45);z-index:500;
  display:flex;align-items:center;justify-content:center;padding:24px;backdrop-filter:blur(2px);}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:16px;
  box-shadow:var(--shadow-lg);width:100%;max-width:640px;max-height:88vh;
  display:flex;flex-direction:column;}
.modal-head{padding:18px 22px;border-bottom:1px solid var(--border);font-size:15px;
  font-weight:700;display:flex;align-items:center;justify-content:space-between;}
.modal-body{padding:22px;overflow-y:auto;}
.modal-foot{padding:16px 22px;border-top:1px solid var(--border);
  display:flex;justify-content:flex-end;gap:9px;}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;}
@media(max-width:640px){.form-grid{grid-template-columns:1fr;}}
input[type=checkbox]{accent-color:var(--accent);width:15px;height:15px;}

.picker{border:1px solid var(--border);border-radius:10px;max-height:190px;overflow-y:auto;
  background:var(--surface-2);}
.pick{display:flex;align-items:center;gap:10px;padding:9px 13px;font-size:13.5px;cursor:pointer;
  border-bottom:1px solid var(--border);}
.pick:last-child{border-bottom:0;}
.pick:hover{background:var(--surface-3);}

.colour-row{display:flex;gap:10px;align-items:center;}
.colour-row input[type=color]{width:44px;height:38px;padding:2px;border:1px solid var(--border);
  border-radius:9px;background:var(--surface);cursor:pointer;flex-shrink:0;}

/* Simple bar chart */
.chart{display:flex;align-items:flex-end;gap:6px;height:190px;}
.bar-wrap{flex:1;display:flex;flex-direction:column;align-items:center;gap:8px;min-width:0;}
.bar{width:100%;max-width:44px;height:150px;display:flex;align-items:flex-end;
  background:var(--surface-3);border-radius:7px;overflow:hidden;}
.bar-fill{width:100%;background:var(--accent-soft);position:relative;
  border-radius:7px 7px 0 0;display:flex;align-items:flex-end;transition:height .25s;}
.bar-answered{width:100%;background:var(--accent);border-radius:7px 7px 0 0;}
.bar-label{font-size:10.5px;color:var(--faint);font-family:'Geist Mono',monospace;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;}

/* Wallboard */
.wb-kpi .kpi-value{font-size:34px;}
.kpi.alert-state{border-color:var(--red);box-shadow:0 0 0 3px var(--red-soft);}
#board:fullscreen{background:var(--bg);padding:26px;overflow-y:auto;}
#board:fullscreen .kpi-value{font-size:46px;}
#board:fullscreen .table{font-size:15px;}

/* Trend chart */
.trend-chart{display:flex;align-items:flex-end;gap:5px;height:230px;overflow-x:auto;padding-bottom:4px;}
.tc-col{flex:1;min-width:28px;display:flex;flex-direction:column;align-items:center;gap:7px;}
.tc-bars{width:100%;height:190px;display:flex;align-items:flex-end;gap:2px;}
.tc-bar{flex:1;border-radius:4px 4px 0 0;min-height:2px;transition:height .25s;}
.tc-label{font-size:10px;color:var(--faint);font-family:'Geist Mono',monospace;
  white-space:nowrap;}
.legend{display:inline-block;width:9px;height:9px;border-radius:3px;vertical-align:middle;
  margin-right:4px;}

/* Ticket timeline */
.tl{border:1px solid var(--border);border-radius:10px;background:var(--surface-2);
  max-height:230px;overflow-y:auto;padding:12px 14px;}
.tl-item{display:flex;gap:11px;padding:7px 0;}
.tl-dot{width:8px;height:8px;border-radius:50%;background:var(--border-strong);
  margin-top:6px;flex-shrink:0;}
.tl-dot.comment{background:var(--accent);}
.tl-head{display:flex;gap:9px;align-items:baseline;font-size:12.5px;}
.tl-text{font-size:12.5px;color:var(--muted);margin-top:2px;word-break:break-word;}
textarea.form-control{font-family:'Geist',sans-serif;resize:vertical;}

.logo-slot{display:flex;align-items:center;gap:16px;padding:14px 0;
  border-bottom:1px solid var(--border);}
.logo-meta{flex:1;min-width:0;}
.logo-actions{display:flex;gap:6px;flex-shrink:0;}
.logo-box{width:60px;height:60px;border-radius:12px;border:1px dashed var(--border-strong);
  background:var(--surface-2);display:flex;align-items:center;justify-content:center;
  overflow:hidden;flex-shrink:0;font-size:20px;}

/* Agent status widget */
.status-widget{position:relative;}
.status-pill{display:flex;align-items:center;gap:8px;padding:7px 12px;border-radius:9px;
  border:1px solid var(--border);background:var(--surface);cursor:pointer;
  font-family:'Geist',sans-serif;font-size:12.5px;font-weight:600;color:var(--text);}
.status-pill:hover{background:var(--surface-3);}
.status-pill.ok{border-color:var(--accent-soft);background:var(--accent-soft);color:var(--accent-strong);}
.status-pill.busy{border-color:var(--blue-soft);background:var(--blue-soft);color:var(--blue);}
.status-pill.away{border-color:var(--amber-soft);background:var(--amber-soft);color:var(--amber);}
.status-pill.off{color:var(--muted);}
.status-dot.ok{background:var(--accent);box-shadow:0 0 0 3px var(--accent-soft);}
.status-dot.busy{background:var(--blue);box-shadow:0 0 0 3px var(--blue-soft);}
.status-dot.away{background:var(--amber);box-shadow:0 0 0 3px var(--amber-soft);}
.status-dot.off{background:var(--faint);}
.status-timer{font-size:11px;opacity:.75;font-variant-numeric:tabular-nums;}
.status-menu{min-width:210px;max-height:340px;overflow-y:auto;}
.status-menu a{cursor:pointer;}
.menu-sep{font-size:10px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;
  color:var(--faint);padding:9px 14px 4px;border-top:1px solid var(--border);}
.menu-sep:empty{padding:0;height:1px;}

/* Ticket wallboard */
.status-strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));
  gap:2px;border-radius:14px;overflow:hidden;box-shadow:var(--shadow);}
.strip-cell{padding:16px 18px;background:var(--surface);border-top:3px solid transparent;}
.strip-cell.open{background:var(--blue-soft);border-top-color:var(--blue);}
.strip-cell.pending{background:var(--surface-3);border-top-color:var(--faint);}
.strip-cell.hold{background:var(--amber-soft);border-top-color:var(--amber);}
.strip-cell.closed{background:var(--accent-soft);border-top-color:var(--accent);}
.strip-cell.breach{background:var(--red-soft);border-top-color:var(--red);}
.strip-cell.total{background:var(--surface-2);border-top-color:var(--border-strong);}
.strip-label{font-size:10.5px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);}
.strip-value{font-size:30px;font-weight:700;letter-spacing:-.03em;margin-top:6px;}

.chart-row{display:flex;align-items:center;gap:22px;flex-wrap:wrap;}
.donut{width:160px;height:160px;flex-shrink:0;}
.donut-num{font-size:26px;font-weight:700;fill:var(--text);font-family:'Geist',sans-serif;}
.donut-cap{font-size:9px;fill:var(--faint);letter-spacing:.14em;font-family:'Geist Mono',monospace;}
.donut-empty{width:160px;height:160px;display:grid;place-items:center;color:var(--faint);
  border:1px dashed var(--border-strong);border-radius:50%;font-size:12.5px;}
.legend-list{flex:1;min-width:170px;display:flex;flex-direction:column;gap:7px;}
.legend-item{display:flex;align-items:center;gap:9px;font-size:12.5px;}
.legend-swatch{width:10px;height:10px;border-radius:3px;flex-shrink:0;}
.legend-name{flex:1;}
.legend-val{font-weight:600;}
.legend-pct{width:2.6rem;text-align:right;font-size:11.5px;}

.mini-bar{height:8px;background:var(--surface-3);border-radius:5px;overflow:hidden;}
.mini-bar div{height:100%;border-radius:5px;transition:width .3s;}

.res-bars{display:flex;align-items:flex-end;gap:14px;height:180px;}
.res-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:7px;}
.res-track{width:100%;max-width:70px;height:120px;background:var(--surface-3);
  border-radius:8px;display:flex;align-items:flex-end;overflow:hidden;}
.res-fill{width:100%;border-radius:8px 8px 0 0;transition:height .3s;min-height:3px;}
.res-val{font-size:13px;font-weight:600;}
.res-label{font-size:11px;color:var(--faint);font-family:'Geist Mono',monospace;}

#board:fullscreen{background:var(--bg);padding:26px;overflow-y:auto;}
#board:fullscreen .strip-value{font-size:44px;}
#board:fullscreen .table{font-size:15px;}

/* Sales funnel */
.funnel{display:flex;flex-direction:column;gap:9px;}
.funnel-row{display:grid;grid-template-columns:8rem 1fr 8rem;align-items:center;gap:14px;}
.funnel-name{font-size:13px;font-weight:500;}
.funnel-track{height:30px;background:var(--surface-3);border-radius:8px;overflow:hidden;}
.funnel-fill{height:100%;border-radius:8px;display:flex;align-items:center;
  padding-left:11px;min-width:2.2rem;transition:width .3s;}
.funnel-fill span{color:#fff;font-size:12.5px;font-weight:700;
  font-family:'Geist Mono',monospace;text-shadow:0 1px 2px rgba(0,0,0,.25);}
.funnel-amount{text-align:right;font-size:12.5px;color:var(--muted);}

/* Settings */
.tabs{display:inline-flex;}
.tree-row{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;}
.tree-row:hover{background:var(--surface-2);}
.tree-dot{width:9px;height:9px;border-radius:3px;flex-shrink:0;}
.tree-name{font-size:13.5px;font-weight:500;flex:1;}
.tree-name.off{color:var(--faint);text-decoration:line-through;}
.tree-actions{display:flex;gap:4px;opacity:0;transition:opacity .12s;}
.tree-row:hover .tree-actions{opacity:1;}

/* Inbox list nested under Conversations */
.nav-sub{display:flex;flex-direction:column;gap:1px;margin:2px 0 6px 0;
  padding-left:12px;border-left:1px solid var(--border);margin-left:22px;}
.nav-sub-item{display:flex;align-items:center;gap:9px;padding:6px 10px;
  border-radius:7px;font-size:12.5px;color:var(--muted);cursor:pointer;}
.nav-sub-item i{font-size:13px;width:15px;text-align:center;flex-shrink:0;}
.nav-sub-item span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.nav-sub-item:hover{background:var(--surface-3);color:var(--text);}
.nav-sub-item.active{background:var(--accent-soft);color:var(--accent-strong);font-weight:600;}
.nav-sub-item .unread-pill{min-width:17px;height:17px;font-size:9.5px;}
.nav-sub-empty{font-size:11.5px;color:var(--faint);padding:6px 10px;}

/* Permission picker */
#permBox{border:1px solid var(--border);border-radius:10px;background:var(--surface-2);
  max-height:280px;overflow-y:auto;margin-bottom:10px;}
.perm-group{border-bottom:1px solid var(--border);}
.perm-group:last-child{border-bottom:0;}
.perm-group-title{font-size:10.5px;font-weight:600;letter-spacing:.09em;
  text-transform:uppercase;color:var(--faint);padding:9px 13px 5px;}
.perm-item{display:flex;align-items:center;gap:9px;padding:6px 13px;
  font-size:12.5px;cursor:pointer;}
.perm-item:hover{background:var(--surface-3);}
.perm-item.locked{opacity:.6;cursor:default;}
.perm-label{flex:1;}

/* ---------- Responsive shell ---------- */
.nav-toggle{background:none;border:0;color:var(--muted);font-size:20px;
  cursor:pointer;padding:0 2px;display:flex;align-items:center;}
.nav-toggle:hover{color:var(--text);}
.nav-scrim{display:none;position:fixed;inset:0;background:rgba(10,16,12,.45);
  z-index:99;backdrop-filter:blur(2px);}

@media (max-width: 1024px){
  .sidebar{transform:translateX(-100%);transition:transform .22s cubic-bezier(.3,.8,.3,1);
    box-shadow:var(--shadow-lg);}
  body.nav-open .sidebar{transform:none;}
  body.nav-open .nav-scrim{display:block;}
  .main-content{margin-left:0;}
  .topbar{padding:0 16px;gap:12px;}
  .topbar-breadcrumb{font-size:14px;}
  .topbar-sep,.topbar-page{display:none;}
  .page-content{padding:18px 16px;}
  .grid-4{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));}
}

@media (max-width: 720px){
  .page-header{flex-direction:column;align-items:stretch;gap:14px;}
  .page-actions,.page-header > div:last-child{width:100%;}
  .kpi-value{font-size:24px;}
  .topbar-user > div{display:none;}
  .topbar-user .user-avatar{margin:0;}
  .status-pill span:not(.status-timer){display:none;}
  .modal{max-height:94vh;}
  .form-grid{grid-template-columns:1fr;}
  .table-container{overflow-x:auto;}
  .table{min-width:640px;}
  .rt-state span{display:none;}
}

.raw-json{background:var(--surface-2);border:1px solid var(--border);border-radius:10px;
  padding:14px;font-family:'Geist Mono',monospace;font-size:11.5px;line-height:1.55;
  max-height:52vh;overflow:auto;white-space:pre-wrap;word-break:break-word;color:var(--muted);}

/* SLA alerts */
.sla-wrap{position:relative;}
#slaBell{position:relative;}
#slaBell.alarm{color:var(--red);border-color:var(--red-soft);background:var(--red-soft);}
.sla-dot{position:absolute;top:-5px;right:-5px;min-width:17px;height:17px;padding:0 4px;
  border-radius:9px;background:var(--red);color:#fff;font-size:10px;font-weight:700;
  display:flex;align-items:center;justify-content:center;
  font-family:'Geist Mono',monospace;border:2px solid var(--surface);}
.sla-menu{min-width:330px;max-height:400px;overflow-y:auto;}
.sla-item{display:flex;align-items:center;gap:9px;padding:9px 13px;font-size:12.5px;}
.sla-item:hover{background:var(--surface-3);}
.sla-ref{font-size:11px;color:var(--muted);flex-shrink:0;}
.sla-subject{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sla-empty{padding:22px 14px;text-align:center;color:var(--faint);font-size:12.5px;}
.sla-badge{margin-left:auto;background:var(--red);color:#fff;font-size:10px;font-weight:700;
  min-width:18px;height:18px;padding:0 5px;border-radius:9px;
  display:inline-flex;align-items:center;justify-content:center;
  font-family:'Geist Mono',monospace;}

.sla-toast{position:fixed;right:22px;bottom:22px;z-index:400;width:330px;
  background:var(--surface);border:1px solid var(--red);border-left-width:4px;
  border-radius:12px;padding:13px 14px;box-shadow:var(--shadow-lg);cursor:pointer;
  display:flex;gap:11px;align-items:flex-start;font-size:13px;
  animation:slaIn .22s cubic-bezier(.2,.9,.3,1.2);}
.sla-toast > .bi{color:var(--red);font-size:18px;flex-shrink:0;margin-top:1px;}
.sla-toast > div{flex:1;min-width:0;}
.sla-toast-sub{font-size:12px;color:var(--muted);margin-top:3px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sla-toast button{background:none;border:0;color:var(--faint);cursor:pointer;
  font-size:14px;padding:0;line-height:1;}
@keyframes slaIn{from{opacity:0;transform:translateY(14px);}to{opacity:1;transform:none;}}

/* AI master switch */
.master-switch{border-width:2px;transition:border-color .2s,background .2s;}
.master-switch.on{border-color:var(--accent);background:var(--accent-soft);}
.switch-icon{width:56px;height:56px;border-radius:16px;background:var(--surface-3);
  color:var(--faint);display:flex;align-items:center;justify-content:center;
  font-size:26px;flex-shrink:0;transition:background .2s,color .2s;}
.switch-icon.on{background:var(--accent);color:#fff;}

/* Template preview */
.tpl-preview{background:var(--accent-soft);border-radius:12px 12px 12px 3px;
  padding:13px 15px;font-size:13.5px;line-height:1.5;color:var(--text);
  white-space:pre-wrap;word-break:break-word;}
.tpl-header{font-weight:700;margin-bottom:6px;}
.tpl-footer{font-size:11.5px;color:var(--muted);margin-top:8px;}
.tpl-meta{font-size:11px;color:var(--faint);margin-top:10px;
  font-family:'Geist Mono',monospace;}

/* System status */
.overall{border-width:2px;}
.overall.ok{border-color:var(--accent);background:var(--accent-soft);}
.overall.warn{border-color:var(--amber);background:var(--amber-soft);}
.overall.down{border-color:var(--red);background:var(--red-soft);}
.overall-icon{width:52px;height:52px;border-radius:15px;display:flex;
  align-items:center;justify-content:center;font-size:24px;color:#fff;flex-shrink:0;}
.overall-icon.ok{background:var(--accent);}
.overall-icon.warn{background:var(--amber);}
.overall-icon.down{background:var(--red);}
.check-card{border-left-width:3px;}
.check-card.ok{border-left-color:var(--accent);}
.check-card.warn{border-left-color:var(--amber);}
.check-card.down{border-left-color:var(--red);}
.check-dot{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;
  justify-content:center;font-size:15px;flex-shrink:0;}
.check-dot.ok{background:var(--accent-soft);color:var(--accent-strong);}
.check-dot.warn{background:var(--amber-soft);color:var(--amber);}
.check-dot.down{background:var(--red-soft);color:var(--red);}

/* ---------- segmented control (filter tabs) ---------- */
.seg{display:inline-flex;gap:2px;padding:3px;border-radius:10px;
  background:var(--surface-2);border:1px solid var(--border);}
.seg button{border:0;background:transparent;color:var(--muted);font:inherit;
  font-size:13px;font-weight:500;padding:7px 14px;border-radius:7px;
  cursor:pointer;white-space:nowrap;transition:background .12s,color .12s;}
.seg button:hover{color:var(--text);}
.seg button.active{background:var(--surface);color:var(--accent-strong);
  font-weight:600;box-shadow:0 1px 2px rgba(0,0,0,.07);}

/* ---------- wide tables scroll instead of clipping ---------- */
/* Break Report and Call Records have more columns than fit on a laptop.
   Keeping headers on one line forces the table to its natural width, and
   the container scrolls horizontally instead of cutting columns off. */
.table-container{overflow-x:auto;}
.table th{white-space:nowrap;}
.table-container::-webkit-scrollbar{height:9px;}
.table-container::-webkit-scrollbar-thumb{background:var(--border);border-radius:5px;}
.table-container::-webkit-scrollbar-thumb:hover{background:var(--muted);}

/* ---------- collapsible sidebar ---------- */
/* Overriding the width variable on <body> is enough: both the sidebar and
   the main content already derive their size from it. */
.sidebar,.main-content{transition:width .18s ease,margin-left .18s ease;}
body.nav-slim{--sidebar-width:66px;}
body.nav-slim .nav-item{font-size:0;gap:0;justify-content:center;padding:11px 0;}
body.nav-slim .nav-item i{font-size:17px;width:auto;}
body.nav-slim .sidebar-section-label,
body.nav-slim .brand-name,
body.nav-slim .brand-sub,
body.nav-slim .nav-sub,
body.nav-slim .sla-badge{display:none;}
body.nav-slim .sidebar-brand{justify-content:center;padding:18px 0;}
body.nav-slim .brand-icon{width:38px;height:38px;}

/* ---------- collapse handle + slim polish ---------- */
.nav-collapse{position:fixed;top:50%;transform:translateY(-50%);
  left:calc(var(--sidebar-width) - 12px);width:24px;height:24px;
  border-radius:50%;border:1px solid var(--border);background:var(--surface);
  color:var(--muted);display:flex;align-items:center;justify-content:center;
  cursor:pointer;z-index:120;box-shadow:0 1px 5px rgba(0,0,0,.10);
  transition:left .18s ease,color .12s,border-color .12s;}
.nav-collapse:hover{color:var(--accent-strong);border-color:var(--accent);}
.nav-collapse i{font-size:11px;transition:transform .18s ease;}
body.nav-slim .nav-collapse i{transform:rotate(180deg);}
@media (max-width:1024px){.nav-collapse{display:none;}}
body.nav-slim .sidebar-nav{padding:12px 0;align-items:center;}
body.nav-slim .nav-item{width:44px;height:40px;border-radius:10px;padding:0;}
body.nav-slim .sidebar-brand{border-bottom:1px solid var(--border);}

/* The brand text is hidden in slim mode, but its wrapper still consumed the
   flex gap and pushed the logo off centre. */
body.nav-slim .sidebar-brand{gap:0;}
body.nav-slim .sidebar-brand > *:not(.brand-icon){display:none;}

/* ---------- file inputs ---------- */
input[type="file"].form-control{padding:8px 10px;line-height:1.7;cursor:pointer;}
input[type="file"].form-control::file-selector-button{
  border:0;border-radius:8px;padding:7px 15px;margin-right:12px;cursor:pointer;
  background:var(--accent-soft);color:var(--accent-strong);
  font:inherit;font-size:13px;font-weight:600;
  transition:background .12s,color .12s;}
input[type="file"].form-control::file-selector-button:hover{
  background:var(--accent);color:#fff;}
input[type="file"].form-control:hover{border-color:var(--accent);}
audio{width:100%;margin:10px 0 4px;border-radius:10px;}
.muted{color:var(--muted);font-size:12.5px;}

/* Notifikasi & konfirmasi bergaya portal, menggantikan alert()/confirm() */
.pesan-tumpuk{position:fixed;right:18px;bottom:18px;z-index:4000;display:flex;
  flex-direction:column;gap:9px;max-width:380px;}
.pesan{display:flex;align-items:flex-start;gap:9px;background:var(--surface);
  border:1px solid var(--border);border-left:3px solid var(--blue);
  border-radius:11px;box-shadow:var(--shadow-lg);padding:12px 14px;
  font-size:13px;line-height:1.45;animation:pesanMasuk .18s ease-out;}
.pesan span{flex:1;}
.pesan button{background:none;border:none;color:var(--faint);cursor:pointer;
  font-size:16px;line-height:1;padding:0;}
.pesan-ok{border-left-color:var(--accent);}
.pesan-error{border-left-color:var(--red);}
@keyframes pesanMasuk{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:none;}}
