/* Playback video library */
.playback-quick-search{display:grid;grid-template-columns:1fr 1.3fr 1.2fr auto auto;gap:9px;margin:22px 0 8px}.playback-quick-search label{display:grid;gap:7px;color:var(--theme-muted);font:700 9px var(--aegis-mono)}.playback-quick-search input,.playback-quick-search select,.playback-quick-search button{height:42px;padding:0 11px;border:1px solid var(--aegis-border);background:var(--theme-panel);color:var(--theme-text)}.playback-quick-search button{align-self:end}.playback-quick-search .primary{background:var(--aegis-amber);color:#090a0b}.playback-quick-result{margin:0 0 18px;padding:16px;border:1px solid var(--aegis-border);background:var(--theme-panel)}.playback-quick-result[hidden]{display:none}.playback-quick-result-head{display:flex;justify-content:space-between;margin-bottom:14px;font:700 10px var(--aegis-mono);letter-spacing:1.4px}.playback-quick-result-head span{color:var(--aegis-amber)}.playback-day-timeline{position:relative;padding-top:22px}.playback-day-scale{position:relative;height:18px;color:var(--theme-muted);font:9px var(--aegis-mono)}.playback-day-scale span{position:absolute;transform:translateX(-50%)}.playback-day-track{position:relative;height:44px;border:1px solid var(--aegis-border);background:var(--theme-input)}.playback-day-block{position:absolute;top:8px;height:26px;min-width:2px;border:0;background:var(--aegis-amber);cursor:pointer}.playback-day-marker{position:absolute;z-index:2;top:0;width:2px;height:44px;background:var(--theme-danger)}.playback-neighbors{display:flex;align-items:center;gap:10px;margin-top:12px;padding:11px;border:1px solid var(--theme-warning);color:var(--theme-warning)}.playback-neighbors[hidden]{display:none}.playback-neighbors button{height:32px;border:1px solid var(--aegis-border);background:var(--theme-panel-2);color:var(--theme-text)}.playback-hour-groups{display:grid;gap:7px;margin-top:14px}.playback-hour-groups details{border:1px solid var(--aegis-border);background:var(--theme-panel-2)}.playback-hour-groups summary{padding:10px 12px;cursor:pointer;font-weight:700}.playback-hour-groups summary span{float:right;color:var(--theme-muted);font:10px var(--aegis-mono)}.playback-hour-groups details button{display:flex;align-items:center;gap:9px;width:100%;padding:9px 16px;border:0;border-top:1px solid var(--aegis-border);background:transparent;color:var(--theme-text);text-align:left}.playback-hour-groups svg{width:15px;color:var(--aegis-amber)}
body.playback-library-page .content{padding-top:28px}.playback-head{display:flex;justify-content:space-between;align-items:end}.playback-head .eyebrow{color:var(--aegis-amber);font:700 11px var(--aegis-mono);letter-spacing:2.5px}.playback-head h1{margin:5px 0;font-size:30px}.playback-head p{margin:0;color:var(--theme-muted,#89909a)}.playback-trash{height:40px;border:1px solid var(--aegis-border);background:var(--theme-panel);color:var(--theme-muted)}
.playback-filters{display:grid;grid-template-columns:1fr 1.2fr 1.2fr 1.2fr auto auto;gap:9px;margin:22px 0 8px}.playback-filters[hidden]{display:none}.playback-filters label{display:grid;gap:7px;color:var(--theme-muted);font:700 9px var(--aegis-mono)}.playback-filters input,.playback-filters select,.playback-filters button{height:42px;padding:0 10px;border:1px solid var(--aegis-border);background:var(--theme-panel,#17191d);color:var(--theme-text,#eee)}.playback-filters button{align-self:end}.playback-filters .primary{background:var(--aegis-amber);color:#090a0b}.playback-feedback{min-height:28px;color:var(--theme-muted);font-size:11px}.playback-feedback.success{color:var(--theme-success)}.playback-feedback.warning{color:var(--theme-warning)}.playback-feedback.error{color:var(--theme-danger)}
.playback-workspace{display:grid;grid-template-columns:270px minmax(0,1fr);min-height:590px;border:1px solid var(--aegis-border)}.playback-tree-panel{padding:16px;border-right:1px solid var(--aegis-border);overflow:auto}.panel-label,.playback-timeline-head,.playback-list-head{font:700 10px var(--aegis-mono);letter-spacing:1.6px}.playback-tree{margin-top:14px}.playback-tree details{margin:5px}.playback-tree summary{padding:7px;cursor:pointer}.playback-tree button{display:flex;justify-content:space-between;width:100%;padding:8px 8px 8px 24px;border:0;background:transparent;color:var(--theme-text)}.playback-tree small{color:var(--theme-muted)}.playback-browser{padding:18px;min-width:0}.playback-timeline-head,.playback-list-head{display:flex;justify-content:space-between;margin-bottom:12px}.playback-timeline-head b{color:var(--aegis-amber)}
.playback-timeline{position:relative;height:76px;margin-bottom:22px;border:1px solid var(--aegis-border);background:var(--theme-input,#0d0f11)}.playback-time-block{position:absolute;left:var(--left);width:max(var(--width),3px);top:14px;height:46px;border:0;background:var(--aegis-amber)}.playback-time-block.gap{background:repeating-linear-gradient(135deg,#222 0 6px,#15171a 6px 12px)}.playback-timeline-empty{display:grid;height:100%;place-items:center;color:var(--theme-muted)}.playback-list-head button{height:32px;border:1px solid var(--aegis-border);background:var(--theme-panel);color:var(--theme-text)}.playback-segments{display:grid;gap:7px}.playback-file{display:grid;grid-template-columns:auto auto 1fr auto;align-items:center;gap:11px;padding:11px;border:1px solid var(--aegis-border);background:var(--theme-panel)}.playback-file svg{width:17px;color:var(--aegis-amber)}.playback-file span{display:grid}.playback-file small{color:var(--theme-muted)}.playback-file.failed{border-color:var(--theme-danger)}.playback-empty{padding:35px;text-align:center;color:var(--theme-muted)}
.playback-player{position:fixed;z-index:8000;right:24px;bottom:24px;width:min(440px,calc(100vw - 48px));padding:14px;border:1px solid var(--aegis-border);background:var(--theme-panel);box-shadow:0 20px 60px #000b}.playback-player[hidden]{display:none}.playback-player>button:first-child{float:right}.playback-player video{width:100%;max-height:260px;background:#000}.playback-player div{margin-top:8px;color:var(--theme-muted)}@media(max-width:1200px){.playback-filters{grid-template-columns:repeat(3,1fr)}}@media(max-width:850px){.playback-filters{grid-template-columns:1fr 1fr}.playback-workspace{grid-template-columns:1fr}.playback-tree-panel{border-right:0;border-bottom:1px solid var(--aegis-border)}}
.playback-folder-browser{min-height:560px;border:1px solid var(--aegis-border);background:var(--theme-panel)}.playback-breadcrumb{display:flex;align-items:center;gap:4px;min-height:50px;padding:0 18px;border-bottom:1px solid var(--aegis-border);overflow-x:auto}.playback-breadcrumb button{border:0;background:transparent;color:var(--theme-muted);font:700 12px var(--aegis-mono);white-space:nowrap;cursor:pointer}.playback-breadcrumb button:last-of-type{color:var(--theme-text)}.playback-breadcrumb svg{width:14px;height:14px;color:var(--theme-muted);flex:0 0 auto}.playback-browser-toolbar{display:flex;align-items:center;justify-content:space-between;padding:14px 18px}.playback-browser-toolbar button{display:inline-flex;align-items:center;gap:8px;height:36px;padding:0 13px;border:1px solid var(--aegis-border);background:var(--theme-panel-2);color:var(--theme-text);font:700 10px var(--aegis-mono);letter-spacing:1px}.playback-browser-toolbar button:disabled{opacity:.35}.playback-browser-toolbar svg{width:15px}.playback-browser-toolbar span{color:var(--theme-muted);font:600 11px var(--aegis-mono)}.playback-folder-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px;padding:4px 18px 24px}.playback-folder-grid[hidden]{display:none}.playback-folder-card{display:flex;align-items:center;gap:14px;min-height:86px;padding:15px;border:1px solid var(--aegis-border);background:var(--theme-panel-2);color:var(--theme-text);text-align:left;cursor:pointer;transition:border-color .15s,background .15s,transform .15s}.playback-folder-card:hover{border-color:color-mix(in srgb,var(--aegis-amber) 55%,var(--aegis-border));transform:translateY(-1px)}.playback-folder-card.selected{border-color:var(--aegis-amber);background:color-mix(in srgb,var(--aegis-amber) 10%,var(--theme-panel-2))}.playback-folder-card>svg{width:34px;height:34px;color:var(--aegis-amber);fill:color-mix(in srgb,var(--aegis-amber) 18%,transparent);flex:0 0 auto}.playback-folder-card span{display:grid;gap:7px;min-width:0}.playback-folder-card b{overflow:hidden;text-overflow:ellipsis;font-size:14px;white-space:nowrap}.playback-folder-card small{color:var(--theme-muted);font:500 10px var(--aegis-mono)}.playback-day-view{padding:4px 18px 24px}.playback-day-view[hidden]{display:none}@media(max-width:700px){.playback-folder-grid{grid-template-columns:1fr}.playback-breadcrumb,.playback-browser-toolbar,.playback-folder-grid,.playback-day-view{padding-left:12px;padding-right:12px}.playback-player{inset:auto 0 0;width:100%;max-height:82vh;overflow:auto}}

 :root{
    --blue-600:#2563eb; --blue-700:#1d4ed8; --blue-500:#3b82f6; --blue-50:#eff6ff; --blue-100:#dbeafe;
    --cyan-400:#22d3ee;
    --slate-900:#0f172a; --slate-800:#1e293b; --slate-700:#334155; --slate-600:#475569; --slate-500:#64748b;
    --slate-400:#94a3b8; --slate-300:#cbd5e1; --slate-200:#e2e8f0; --slate-100:#f1f5f9; --slate-50:#f8fafc;
    --red-500:#ef4444; --red-50:#fef2f2; --red-600:#dc2626;
    --green-500:#22c55e; --green-50:#f0fdf4; --green-600:#16a34a;
    --amber-500:#f59e0b; --amber-50:#fffbeb; --amber-600:#d97706;
    --purple-500:#8b5cf6;
    --indigo-500:#6366f1;
    --radius:10px;
    --shadow:0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  }
  *{box-sizing:border-box;}
  body{margin:0;font-family:'Segoe UI',-apple-system,BlinkMacSystemFont,Roboto,Helvetica,Arial,sans-serif;background:var(--slate-50);color:var(--slate-800);}
  ::-webkit-scrollbar{width:8px;height:8px;}
  ::-webkit-scrollbar-thumb{background:var(--slate-300);border-radius:4px;}

  /* ============ LOGIN ============ */
  #login-screen{display:flex;min-height:100vh;}
  .login-left{flex:1.2;background:linear-gradient(160deg,#dbeafe 0%,#eff6ff 50%,#f0f9ff 100%);padding:64px 64px;position:relative;overflow:hidden;}
  .login-left::after{content:'';position:absolute;right:-120px;bottom:-80px;width:480px;height:480px;background:radial-gradient(circle,rgba(59,130,246,.15),transparent 70%);border-radius:50%;}
  .brand{display:flex;align-items:center;gap:10px;margin-bottom:6px;}
  .brand-icon{width:46px;height:46px;border-radius:12px;background:linear-gradient(135deg,var(--blue-600),var(--cyan-400));display:flex;align-items:center;justify-content:center;color:#fff;}
  .brand-name{font-size:24px;font-weight:800;color:var(--slate-900);}
  .brand-name span{color:var(--blue-600);}
  .tagline{color:var(--slate-500);margin:0 0 48px 56px;font-size:14px;}
  .login-left h1{font-size:36px;line-height:1.25;color:var(--slate-900);margin:0 0 18px;font-weight:800;max-width:480px;}
  .login-left p.desc{color:var(--slate-600);max-width:440px;line-height:1.7;margin-bottom:40px;}
  .feature{display:flex;gap:16px;margin-bottom:26px;align-items:flex-start;max-width:440px;}
  .feature-icon{width:46px;height:46px;border-radius:12px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
  .feature-icon.blue{background:var(--blue-50);color:var(--blue-600);}
  .feature-icon.red{background:var(--red-50);color:var(--red-500);}
  .feature-icon.purple{background:#f3e8ff;color:var(--purple-500);}
  .feature h4{margin:0 0 4px;font-size:15px;color:var(--slate-900);}
  .feature p{margin:0;font-size:13px;color:var(--slate-500);line-height:1.5;}

  .login-right{flex:1;display:flex;align-items:center;justify-content:center;padding:40px;}
  .login-card{width:100%;max-width:420px;background:#fff;border-radius:16px;box-shadow:0 10px 40px rgba(15,23,42,.08);padding:40px 36px;}
  .login-card .brand{justify-content:center;margin-bottom:4px;}
  .login-card .tagline{text-align:center;margin:0 0 28px;}
  .field{margin-bottom:18px;}
  .field label{display:block;font-size:13px;font-weight:600;color:var(--slate-700);margin-bottom:6px;}
  .input-wrap{position:relative;display:flex;align-items:center;}
  .input-wrap svg{position:absolute;left:13px;color:var(--slate-400);width:17px;height:17px;}
  .input-wrap input{width:100%;padding:11px 14px 11px 38px;border:1px solid var(--slate-200);border-radius:9px;font-size:14px;color:var(--slate-800);outline:none;transition:.15s;}
  .input-wrap input:focus{border-color:var(--blue-500);box-shadow:0 0 0 3px var(--blue-100);}
  .input-wrap .toggle-eye{left:auto;right:13px;cursor:pointer;}
  .row-between{display:flex;justify-content:space-between;align-items:center;font-size:13px;margin-bottom:22px;}
  .row-between label{display:flex;align-items:center;gap:7px;color:var(--slate-600);cursor:pointer;}
  .row-between a{color:var(--blue-600);text-decoration:none;}
  .btn-primary{width:100%;background:linear-gradient(135deg,var(--blue-600),var(--blue-700));color:#fff;border:none;padding:13px;border-radius:9px;font-size:15px;font-weight:600;cursor:pointer;transition:.15s;}
  .btn-primary:hover{opacity:.92;}
  .divider{display:flex;align-items:center;gap:12px;margin:20px 0;color:var(--slate-400);font-size:12px;}
  .divider::before,.divider::after{content:'';flex:1;height:1px;background:var(--slate-200);}
  .btn-google{width:100%;display:flex;align-items:center;justify-content:center;gap:10px;border:1px solid var(--slate-200);background:#fff;padding:11px;border-radius:9px;font-size:14px;font-weight:500;cursor:pointer;color:var(--slate-700);}
  .login-foot{text-align:center;margin-top:28px;font-size:12px;color:var(--slate-400);}
  .login-foot a{color:var(--slate-500);text-decoration:none;margin:0 6px;}

  /* ============ APP SHELL ============ */
  #app{display:none;min-height:100vh;}
  .layout{display:flex;min-height:100vh;}
  .sidebar{width:240px;background:#fff;border-right:1px solid var(--slate-200);display:flex;flex-direction:column;flex-shrink:0;}
  .sidebar .brand{padding:20px 22px;margin:0;}
  .sidebar .brand-icon{width:36px;height:36px;border-radius:9px;}
  .sidebar .brand-name{font-size:18px;}
  nav.menu{flex:1;padding:8px 12px;}
  .menu a{display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:9px;color:var(--slate-600);text-decoration:none;font-size:14px;margin-bottom:3px;position:relative;cursor:pointer;}
  .menu a svg{width:18px;height:18px;flex-shrink:0;}
  .menu a:hover{background:var(--slate-100);}
  .menu a.active{background:var(--blue-600);color:#fff;}
  .menu a .badge{margin-left:auto;background:var(--red-500);color:#fff;font-size:11px;font-weight:700;padding:1px 7px;border-radius:10px;}
  .menu a.active .badge{background:#fff;color:var(--blue-600);}
  .sidebar-foot{padding:14px 20px;border-top:1px solid var(--slate-100);font-size:12px;color:var(--slate-400);display:flex;align-items:center;gap:8px;}
  .dot-green{width:7px;height:7px;border-radius:50%;background:var(--green-500);}

  .main{flex:1;display:flex;flex-direction:column;min-width:0;}
  .topbar{height:64px;background:#fff;border-bottom:1px solid var(--slate-200);display:flex;align-items:center;justify-content:space-between;padding:0 28px;flex-shrink:0;}
  .topbar h2{font-size:17px;margin:0;color:var(--slate-900);font-weight:700;}
  .topbar-right{display:flex;align-items:center;gap:18px;}
  .icon-btn{position:relative;width:36px;height:36px;border-radius:9px;display:flex;align-items:center;justify-content:center;color:var(--slate-500);cursor:pointer;}
  .icon-btn:hover{background:var(--slate-100);}
  .icon-btn .badge{position:absolute;top:0;right:0;background:var(--red-500);color:#fff;font-size:10px;font-weight:700;border-radius:10px;padding:1px 5px;}
  .notification-dropdown{position:absolute;top:44px;right:0;width:min(360px,calc(100vw - 32px));max-height:460px;background:#fff;border:1px solid var(--slate-200);border-radius:10px;box-shadow:0 18px 48px rgba(15,23,42,0.18);z-index:900;overflow:hidden;display:none;text-align:left;}
  .notification-dropdown.open{display:block;}
  .notification-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 14px;border-bottom:1px solid var(--slate-100);}
  .notification-title{font-size:13px;font-weight:800;color:var(--slate-900);}
  .notification-read-all{border:0;background:transparent;color:var(--blue-600);font-size:12px;font-weight:700;cursor:pointer;padding:4px 0;}
  .notification-body{max-height:390px;overflow:auto;}
  .notification-item{width:100%;border:0;border-bottom:1px solid var(--slate-100);background:#fff;padding:11px 14px;text-align:left;cursor:pointer;display:block;}
  .notification-item:hover{background:var(--slate-50);}
  .notification-item.unread{background:#eff6ff;}
  .notification-item-title{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:13px;font-weight:800;color:var(--slate-900);margin-bottom:4px;}
  .notification-item-message{font-size:12px;color:var(--slate-600);line-height:1.4;margin-bottom:6px;}
  .notification-item-meta{display:flex;align-items:center;gap:8px;font-size:11px;color:var(--slate-400);}
  .notification-state{width:7px;height:7px;border-radius:50%;background:var(--blue-600);display:inline-block;flex-shrink:0;}
  .notification-empty{padding:26px 16px;text-align:center;color:var(--slate-400);font-size:13px;}
  .user-chip{display:flex;align-items:center;gap:10px;cursor:pointer;}
  .avatar{width:36px;height:36px;border-radius:50%;background:linear-gradient(135deg,var(--blue-500),var(--purple-500));display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:13px;}
  .user-chip .uname{font-size:13px;font-weight:600;color:var(--slate-800);}
  .user-chip .urole{font-size:11px;color:var(--slate-400);}

  .content{padding:24px 28px;overflow-y:auto;flex:1;}
  .page{display:none;}
  .page.active{display:block;}
  .page-title{font-size:22px;font-weight:800;color:var(--slate-900);margin:0 0 4px;}
  .page-sub{color:var(--slate-500);font-size:13px;margin:0 0 22px;}

  .card{background:#fff;border:1px solid var(--slate-200);border-radius:var(--radius);box-shadow:var(--shadow);}
  .stats-row{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:20px;}
  .stats-row.cols-4{grid-template-columns:repeat(4,1fr);}
  .stat-card{padding:18px 20px;display:flex;flex-direction:column;gap:8px;}
  .stat-top{display:flex;align-items:center;gap:12px;}
  .stat-icon{width:42px;height:42px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
  .stat-label{font-size:12.5px;color:var(--slate-500);}
  .stat-value{font-size:24px;font-weight:800;color:var(--slate-900);}
  .stat-sub{font-size:11.5px;color:var(--slate-400);}
  .stat-sub.up{color:var(--red-600);}
  .stat-sub.upgreen{color:var(--green-600);}

  .grid-2{display:grid;grid-template-columns:2.2fr 1fr;gap:18px;margin-bottom:20px;}
  .card-head{display:flex;justify-content:space-between;align-items:center;padding:16px 18px;border-bottom:1px solid var(--slate-100);}
  .card-head h3{margin:0;font-size:15px;font-weight:700;color:var(--slate-900);}
  .link{color:var(--blue-600);font-size:12.5px;text-decoration:none;font-weight:600;}

  .cam-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:14px;padding:16px;}
  .cam-tile{position:relative;border-radius:9px;overflow:hidden;background:var(--slate-800);aspect-ratio:16/9;}
  .cam-tile img{width:100%;height:100%;object-fit:cover;display:block;opacity:.92;}
  .cam-label{position:absolute;top:8px;left:8px;background:rgba(0,0,0,.55);color:#fff;font-size:11.5px;padding:3px 8px;border-radius:5px;display:flex;align-items:center;gap:5px;}
  .cam-time{position:absolute;bottom:8px;left:8px;background:rgba(0,0,0,.5);color:#fff;font-size:10.5px;padding:2px 6px;border-radius:4px;}
  .cam-tag{position:absolute;top:8px;right:8px;background:var(--red-500);color:#fff;font-size:10px;font-weight:700;padding:2px 7px;border-radius:5px;}

  .quick-alert-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;padding:16px;}
  .qa-item{text-align:center;padding:14px 8px;background:var(--slate-50);border-radius:9px;}
  .qa-item .n{font-size:20px;font-weight:800;color:var(--slate-900);}
  .qa-item .l{font-size:11px;color:var(--slate-500);margin-top:2px;}

  .activity-item{display:flex;align-items:center;gap:12px;padding:12px 18px;border-bottom:1px solid var(--slate-100);}
  .activity-item:last-child{border-bottom:none;}
  .act-icon{width:34px;height:34px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
  .act-time{font-size:11px;color:var(--slate-400);width:48px;flex-shrink:0;}
  .act-body{flex:1;}
  .act-body .t{font-size:13px;font-weight:600;color:var(--slate-800);}
  .act-body .s{font-size:11px;color:var(--slate-400);}
  .act-loc{font-size:11.5px;color:var(--slate-500);}
  .act-thumb{width:42px;height:32px;border-radius:5px;object-fit:cover;background:var(--slate-200);}

  table{width:100%;border-collapse:collapse;font-size:13px;}
  th{text-align:left;padding:10px 18px;color:var(--slate-500);font-weight:600;font-size:12px;border-bottom:1px solid var(--slate-100);background:var(--slate-50);}
  td{padding:11px 18px;border-bottom:1px solid var(--slate-100);color:var(--slate-700);}
  tr:hover td{background:var(--slate-50);}
  .pill{display:inline-block;padding:2px 10px;border-radius:12px;font-size:11.5px;font-weight:600;}
  .pill.cao{background:#fee2e2;color:#dc2626;}
  .pill.trungbinh{background:#fef3c7;color:#b45309;}
  .pill.thap{background:#dbeafe;color:#1d4ed8;}
  .status{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;}
  .status .d{width:7px;height:7px;border-radius:50%;}
  .status.daxuly .d{background:var(--green-500);} .status.daxuly{color:var(--green-600);}
  .status.dangxuly .d{background:var(--blue-500);} .status.dangxuly{color:var(--blue-600);}

  .charts-row{display:grid;grid-template-columns:2fr 1fr;gap:18px;}
  .donut-wrap{display:flex;align-items:center;gap:20px;padding:18px;}
  .legend-item{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--slate-600);margin-bottom:8px;}
  .legend-dot{width:9px;height:9px;border-radius:50%;flex-shrink:0;}

  /* Camera trực tiếp page */
  .filters-row{display:flex;gap:12px;margin-bottom:16px;align-items:center;flex-wrap:wrap;}
  .filters-row select,.filters-row .search-box{padding:9px 12px;border:1px solid var(--slate-200);border-radius:8px;font-size:13px;background:#fff;color:var(--slate-700);}
  .search-box{display:flex;align-items:center;gap:8px;flex:1;min-width:200px;}
  .search-box input{border:none;outline:none;flex:1;font-size:13px;}
  .live-layout{display:grid;grid-template-columns:1fr 320px;gap:18px;}
  .live-cam-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;}
  .live-tile{position:relative;border-radius:9px;overflow:hidden;background:var(--slate-800);aspect-ratio:16/10;cursor:pointer;border:2px solid transparent;}
  .live-tile.selected{border-color:var(--blue-500);}
  .live-tile img{width:100%;height:100%;object-fit:!important;}
  .side-panel{padding:0;}
  .side-panel .cam-thumb{width:100%;aspect-ratio:16/9;object-fit:!important;}
  .side-section{padding:14px 18px;border-bottom:1px solid var(--slate-100);}
  .side-section h4{margin:0 0 10px;font-size:12.5px;color:var(--slate-400);font-weight:700;text-transform:uppercase;letter-spacing:.3px;}
  .info-row{display:flex;justify-content:space-between;font-size:12.5px;padding:5px 0;color:var(--slate-600);}
  .info-row span:last-child{color:var(--slate-900);font-weight:600;text-align:right;}
  .rule-chip{display:flex;align-items:center;gap:10px;background:var(--slate-50);border-radius:8px;padding:8px 10px;margin-bottom:8px;font-size:12px;}
  .rule-chip .rt{font-weight:600;color:var(--slate-800);flex:1;}
  .rule-chip .badge-on{background:#dcfce7;color:#16a34a;font-size:10.5px;font-weight:700;padding:2px 8px;border-radius:8px;}
  .qact-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;}
  .qact-grid div{display:flex;flex-direction:column;align-items:center;gap:5px;padding:10px 4px;background:var(--slate-50);border-radius:8px;font-size:10.5px;color:var(--slate-600);cursor:pointer;}

  /* Alerts page */
  .alert-layout{display:grid;grid-template-columns:1fr 420px;gap:18px;}
  .alert-row{display:flex;align-items:center;gap:14px;padding:14px 18px;border-bottom:1px solid var(--slate-100);cursor:pointer;}
  .alert-row.selected{background:var(--blue-50);}
  .alert-row .time{width:80px;font-size:12px;color:var(--slate-400);flex-shrink:0;}
  .alert-row .time b{display:block;color:var(--slate-800);font-size:13px;}
  .alert-icon{width:36px;height:36px;border-radius:9px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
  .alert-mid{flex:1;}
  .alert-mid .t{font-size:13px;font-weight:600;color:var(--slate-800);}
  .alert-mid .s{font-size:11.5px;color:var(--slate-400);}
  .detail-evidence{position:relative;border-radius:9px;overflow:hidden;margin-bottom:10px;}
  .detail-evidence img{width:100%;display:block;}
  .evid-thumbs{display:flex;gap:8px;}
  .evid-thumbs img{width:60px;height:44px;object-fit:cover;border-radius:6px;cursor:pointer;border:2px solid transparent;}
  .evid-thumbs img.sel{border-color:var(--blue-500);}
  .ai-summary{background:var(--slate-50);border-radius:9px;padding:12px 14px;font-size:12.5px;color:var(--slate-600);line-height:1.6;margin-bottom:10px;}
  .reco-item{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--slate-600);padding:6px 0;}
  .btn-row{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:14px;}
  .btn-sm{padding:10px;border-radius:8px;font-size:13px;font-weight:600;border:1px solid var(--slate-200);background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:6px;}
  .btn-sm.primary{background:var(--blue-600);color:#fff;border:none;}
  .btn-sm.green{color:var(--green-600);}
  .btn-sm.red{color:var(--red-600);}

  /* reports */
  .filters-grid{display:grid;grid-template-columns:repeat(5,1fr) auto;gap:12px;align-items:end;margin-bottom:20px;}
  .filters-grid .fg label{display:block;font-size:11.5px;color:var(--slate-500);margin-bottom:5px;}
  .filters-grid select,.filters-grid input{width:100%;padding:9px 10px;border:1px solid var(--slate-200);border-radius:8px;font-size:12.5px;}
  .heatmap{padding:16px;overflow-x:auto;}
  .heatmap table{font-size:11px;}
  .heatmap td,.heatmap th{padding:4px 6px;text-align:center;}
  .hm-cell{width:26px;height:22px;border-radius:4px;display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:#1e3a8a;}

  /* users */
  .user-row-avatar{width:34px;height:34px;border-radius:50%;display:flex;align-items:center;justify-content:center;color:#fff;font-size:12px;font-weight:700;flex-shrink:0;}
  .role-pill{padding:2px 10px;border-radius:10px;font-size:11.5px;font-weight:600;}
  .role-pill.admin{background:#fee2e2;color:#dc2626;}
  .role-pill.giamsat{background:#dbeafe;color:#1d4ed8;}
  .role-pill.nhanvien{background:#dcfce7;color:#16a34a;}
  .pagination{display:flex;justify-content:space-between;align-items:center;padding:14px 18px;font-size:12.5px;color:var(--slate-500);}
  .pg-btns{display:flex;gap:4px;}
  .pg-btns button{width:28px;height:28px;border-radius:7px;border:1px solid var(--slate-200);background:#fff;cursor:pointer;font-size:12px;}
  .pg-btns button.active{background:var(--blue-600);color:#fff;border-color:var(--blue-600);}
  .udetail-tabs{display:flex;border-bottom:1px solid var(--slate-100);padding:0 18px;}
  .udetail-tabs span{padding:12px 4px;margin-right:20px;font-size:12.5px;color:var(--slate-400);cursor:pointer;border-bottom:2px solid transparent;}
  .udetail-tabs span.active{color:var(--blue-600);border-color:var(--blue-600);font-weight:600;}
  .perm-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px 14px;}
  .perm-item{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--slate-600);}

  .toolbar-flex{display:flex;justify-content:space-between;align-items:center;margin-bottom:16px;}

/* ==========================================================================
   MultiCAMAI dark command center theme inspired by the provided Aegis UI
   ========================================================================== */
/* MultiCAMAI per-user theme tokens */
:root[data-color-mode="dark"]{color-scheme:dark;--theme-bg:#0c0d0f;--theme-sidebar:#111417;--theme-topbar:#111315;--theme-surface:#181a1d;--theme-surface-raised:#202226;--theme-surface-hover:#24272c;--theme-text:#e7e9ee;--theme-text-strong:#f2f3f5;--theme-text-muted:#9298a2;--theme-text-dim:#686f7a;--theme-border:#2b2e33;--theme-line:#23262b;--theme-input:#141619;--theme-disabled-bg:#1a1c20;--theme-disabled-text:#676c75;--theme-success:#00d28a;--theme-success-soft:#073d32;--theme-danger:#ff4343;--theme-danger-soft:#401c1c;--theme-warning:#f5a524;--theme-warning-soft:#3a2a0d;--theme-info:#4b8cff;--theme-info-soft:#14294d;--theme-shadow:0 18px 48px rgba(0,0,0,.35)}
:root[data-color-mode="light"]{color-scheme:light;--theme-bg:#f3f5f8;--theme-sidebar:#fff;--theme-topbar:#fff;--theme-surface:#fff;--theme-surface-raised:#f7f8fa;--theme-surface-hover:#edf0f4;--theme-text:#17191d;--theme-text-strong:#090a0b;--theme-text-muted:#5f6672;--theme-text-dim:#7a828e;--theme-border:#d7dbe2;--theme-line:#e4e7ec;--theme-input:#fff;--theme-disabled-bg:#e7e9ed;--theme-disabled-text:#8b929d;--theme-success:#087f5b;--theme-success-soft:#d9f5ea;--theme-danger:#c92a2a;--theme-danger-soft:#ffe3e3;--theme-warning:#9a5b00;--theme-warning-soft:#fff1cc;--theme-info:#2459b3;--theme-info-soft:#dce8ff;--theme-shadow:0 14px 38px rgba(30,41,59,.13)}

/* Theme accent presets */
:root[data-accent="aegis-amber"]{--theme-accent:#ffa51f;--theme-accent-hover:#e88e00;--theme-accent-soft:rgba(255,165,31,.14);--theme-on-accent:#111}
:root[data-accent="blue"]{--theme-accent:#3b82f6;--theme-accent-hover:#2563eb;--theme-accent-soft:rgba(59,130,246,.14);--theme-on-accent:#fff}
:root[data-accent="green"]{--theme-accent:#16a36a;--theme-accent-hover:#0f8555;--theme-accent-soft:rgba(22,163,106,.14);--theme-on-accent:#fff}
:root[data-accent="purple"]{--theme-accent:#8b5cf6;--theme-accent-hover:#7544df;--theme-accent-soft:rgba(139,92,246,.14);--theme-on-accent:#fff}
:root[data-accent="red"]{--theme-accent:#e5484d;--theme-accent-hover:#ca3338;--theme-accent-soft:rgba(229,72,77,.14);--theme-on-accent:#fff}

/* Aegis theme aliases */
:root[data-color-mode] body.aegis-theme{--aegis-bg:var(--theme-bg);--aegis-sidebar:var(--theme-sidebar);--aegis-top:var(--theme-topbar);--aegis-panel:var(--theme-surface);--aegis-panel-2:var(--theme-surface-raised);--aegis-border:var(--theme-border);--aegis-line:var(--theme-line);--aegis-text:var(--theme-text);--aegis-muted:var(--theme-text-muted);--aegis-dim:var(--theme-text-dim);--aegis-amber:var(--theme-accent);--aegis-green:var(--theme-success);--aegis-red:var(--theme-danger);--aegis-blue:var(--theme-info);background:var(--theme-bg);color:var(--theme-text)}
/* End Aegis theme aliases */

body.aegis-theme{
  --aegis-bg:#0c0d0f;
  --aegis-sidebar:#111417;
  --aegis-top:#111315;
  --aegis-panel:#181a1d;
  --aegis-panel-2:#202226;
  --aegis-border:#2b2e33;
  --aegis-line:#23262b;
  --aegis-text:#d7d9dd;
  --aegis-muted:#8b8f98;
  --aegis-dim:#5f636d;
  --aegis-amber:#ffa51f;
  --aegis-green:#00d28a;
  --aegis-red:#ff3b3b;
  --aegis-blue:#1f6fff;
  --aegis-mono:"Cascadia Mono","Consolas","SFMono-Regular",monospace;
  background:var(--aegis-bg);
  color:var(--aegis-text);
  font-family:"Inter","Segoe UI",Roboto,Arial,sans-serif;
}
body.aegis-theme ::-webkit-scrollbar{width:13px;height:13px;background:#090a0b;}
body.aegis-theme ::-webkit-scrollbar-thumb{background:#9b9b9b;border:3px solid #090a0b;border-radius:8px;}
body.aegis-theme .layout{background:var(--aegis-bg);}
body.aegis-theme .sidebar{width:300px;background:var(--aegis-sidebar);border-right:1px solid var(--aegis-border);color:var(--aegis-text);}
body.aegis-theme .sidebar .brand{height:70px;padding:16px 24px;border-bottom:1px solid var(--aegis-border);gap:12px;margin:0;}
body.aegis-theme .brand-icon{width:35px;height:35px;border-radius:4px;background:var(--aegis-amber);color:#090909;}
body.aegis-theme .brand-name{color:#f2f3f5;font-size:18px;line-height:1;letter-spacing:.01em;}
body.aegis-theme .brand-name span{color:#f2f3f5!important;}
body.aegis-theme .brand-subtitle{margin-top:5px;color:#9da2ad;font:11px/1 var(--aegis-mono);letter-spacing:.22em;text-transform:uppercase;}
body.aegis-theme nav.menu{padding:18px 14px;overflow:auto;}
body.aegis-theme .menu-section-label{margin:22px 15px 10px;color:#8d96a6;font:700 13px/1 var(--aegis-mono);letter-spacing:.18em;text-transform:uppercase;}
body.aegis-theme .menu a{height:42px;border-radius:0;margin:0 0 3px;padding:0 16px;color:#e6e8ec;text-decoration:none;font-size:16px;font-weight:600;background:transparent;border-left:3px solid transparent;gap:13px;}
body.aegis-theme .menu a svg{width:19px;height:19px;color:#c9cdd4;}
body.aegis-theme .menu a:hover{background:#171a1e;color:#fff;}
body.aegis-theme .menu a.active{background:rgba(255,165,31,.11);color:var(--aegis-amber);border-left-color:var(--aegis-amber);}
body.aegis-theme .menu a.active svg{color:var(--aegis-amber);}
body.aegis-theme .menu a .badge{background:var(--aegis-red);color:#fff;}
body.aegis-theme .sidebar-foot{height:48px;padding:0 15px;border-top:1px solid var(--aegis-border);color:#80858e;font:11px var(--aegis-mono);letter-spacing:.15em;text-transform:uppercase;}
body.aegis-theme .dot-green{background:var(--aegis-green);}
body.aegis-theme .main{background:var(--aegis-bg);}
body.aegis-theme .topbar{height:70px;background:var(--aegis-top);border-bottom:1px solid var(--aegis-border);padding:0 28px 0 30px;}
body.aegis-theme .aegis-topbar{display:grid;grid-template-columns:minmax(380px,720px) 1fr auto auto auto auto;width:100%;align-items:center;gap:28px;}
body.aegis-theme .aegis-search{height:38px;border:1px solid var(--aegis-border);background:#0d0f11;display:flex;align-items:center;gap:12px;padding:0 14px;color:var(--aegis-muted);}
body.aegis-theme .aegis-search input{flex:1;border:0!important;outline:0;background:transparent!important;color:var(--aegis-text)!important;font-size:15px;}
body.aegis-theme .aegis-clock-label{color:#737780;font:700 12px/1 var(--aegis-mono);letter-spacing:.28em;text-transform:uppercase;}
body.aegis-theme .aegis-clock-value{color:#e9eaed;font:700 16px/1.2 var(--aegis-mono);letter-spacing:.04em;margin-top:6px;}
body.aegis-theme .aegis-online{color:var(--aegis-green);font:700 13px var(--aegis-mono);letter-spacing:.16em;text-transform:uppercase;white-space:nowrap;}
body.aegis-theme .aegis-admin{text-align:right;}
body.aegis-theme .aegis-admin-name{font-weight:800;color:#f2f3f5;font-size:14px;}
body.aegis-theme .aegis-admin-role{font:11px var(--aegis-mono);letter-spacing:.18em;color:#8a8e98;text-transform:uppercase;margin-top:4px;}
body.aegis-theme .aegis-logout{width:40px;height:40px;border:1px solid var(--aegis-border);background:#15171b;color:#e7e9ee;display:flex;align-items:center;justify-content:center;cursor:pointer;}
body.aegis-theme .content{background:var(--aegis-bg);padding:32px 30px;}
body.aegis-theme .page-title{color:#e5e7eb;font-size:28px;line-height:1.15;margin:0 0 8px;}
body.aegis-theme .page-title::before{content:attr(data-kicker);display:block;margin-bottom:9px;color:var(--aegis-amber);font:700 13px/1 var(--aegis-mono);letter-spacing:.28em;text-transform:uppercase;}
body.aegis-theme .page-sub{color:var(--aegis-muted);font-size:15px;}
body.aegis-theme .card{background:var(--aegis-panel);border:1px solid var(--aegis-border);border-radius:0;box-shadow:none;}
body.aegis-theme .stat-card{min-height:134px;padding:20px;background:var(--aegis-panel);}
body.aegis-theme .stat-top{align-items:flex-start;justify-content:space-between;}
body.aegis-theme .stat-icon{order:2;width:auto;height:auto;background:transparent!important;color:#8e939d!important;}
body.aegis-theme .stat-label{color:#8a8f99;font:800 13px var(--aegis-mono);letter-spacing:.16em;text-transform:uppercase;}
body.aegis-theme .stat-value{margin-top:8px;color:#e5e7eb;font-size:30px;font-family:var(--aegis-mono);}
body.aegis-theme .stat-sub{color:#7e838d;font-size:13px;}
body.aegis-theme .stat-sub.upgreen{color:var(--aegis-green);}
body.aegis-theme .card-head{border-bottom:1px solid var(--aegis-border);padding:16px 24px;}
body.aegis-theme .card-head h3{color:#d8dbe0;font:800 14px var(--aegis-mono);letter-spacing:.12em;text-transform:uppercase;}
body.aegis-theme .link{color:var(--aegis-amber);font:700 12px var(--aegis-mono);letter-spacing:.18em;text-transform:uppercase;}
body.aegis-theme table{color:var(--aegis-text);font-size:14px;}
body.aegis-theme th{background:#151719;color:#858a94;border-bottom:1px solid var(--aegis-line);font:800 12px var(--aegis-mono);letter-spacing:.18em;text-transform:uppercase;}
body.aegis-theme td{color:#cfd2d8;border-bottom:1px solid var(--aegis-line);}
body.aegis-theme tr:hover td{background:#202227;}
body.aegis-theme .pill{border-radius:4px;font-family:var(--aegis-mono);background:rgba(255,165,31,.12);color:var(--aegis-amber);border:1px solid rgba(255,165,31,.35);}
body.aegis-theme .pill.cao{background:rgba(255,59,59,.16);color:var(--aegis-red);border-color:rgba(255,59,59,.35);}
body.aegis-theme .pill.trungbinh{background:rgba(255,165,31,.15);color:var(--aegis-amber);}
body.aegis-theme .pill.thap{background:rgba(0,210,138,.12);color:var(--aegis-green);border-color:rgba(0,210,138,.35);}
body.aegis-theme .filters-row select,body.aegis-theme .filters-row .search-box,body.aegis-theme .filters-grid select,body.aegis-theme .filters-grid input,body.aegis-theme input,body.aegis-theme select,body.aegis-theme textarea{background:#141619!important;border:1px solid var(--aegis-border)!important;color:var(--aegis-text)!important;border-radius:0!important;}
body.aegis-theme .btn-sm,body.aegis-theme .btn-primary,body.aegis-theme .btn-google{border-radius:2px;background:#16181c;border:1px solid var(--aegis-border);color:var(--aegis-amber);font-family:var(--aegis-mono);letter-spacing:.08em;}
body.aegis-theme .btn-sm.primary,body.aegis-theme .btn-primary{background:var(--aegis-amber);color:#111;border-color:var(--aegis-amber);}
body.aegis-theme .cam-tile,body.aegis-theme .live-tile{border-radius:0;background:#071121;border:1px solid #10151f;}
body.aegis-theme .live-tile.selected{border-color:var(--aegis-amber);}
body.aegis-theme .cam-label{background:rgba(6,8,10,.86);border:1px solid var(--aegis-border);color:#edf0f4;border-radius:3px;font-family:var(--aegis-mono);}
body.aegis-theme .cam-tag{background:var(--aegis-red)!important;border-radius:3px;font-family:var(--aegis-mono);}
body.aegis-theme .cam-status-overlay{background:repeating-linear-gradient(45deg,#101010 0,#101010 10px,#171717 10px,#171717 20px)!important;color:#858b96!important;letter-spacing:.35em;font-family:var(--aegis-mono);}
body.aegis-theme .side-section{border-bottom:1px solid var(--aegis-border);}
body.aegis-theme .side-section h4{color:#8d929c;font-family:var(--aegis-mono);letter-spacing:.16em;}
body.aegis-theme .info-row{color:#8a8f98;}
body.aegis-theme .info-row span:last-child{color:#e2e4e8;}
body.aegis-theme .qa-item{background:#14171a;border-radius:0;}
body.aegis-theme .qa-item .n{font-family:var(--aegis-mono);color:var(--aegis-amber)!important;}
body.aegis-theme .activity-item{border-bottom:1px solid var(--aegis-line);}
body.aegis-theme .act-body .t{color:#e0e2e6;}
body.aegis-theme .act-body .s,body.aegis-theme .act-time,body.aegis-theme .act-loc{color:#7f8490;}
body.aegis-theme .notification-dropdown{background:#17191d;border-color:var(--aegis-border);border-radius:0;}
body.aegis-theme .notification-head,body.aegis-theme .notification-item{background:#17191d;border-color:var(--aegis-line);}
body.aegis-theme .notification-item.unread{background:#201b11;}
body.aegis-theme .notification-title,body.aegis-theme .notification-item-title{color:#eceef1;}
body.aegis-theme .notification-item-message{color:#a1a6ae;}
body.aegis-theme .map-container,body.aegis-theme #map,body.aegis-theme #cameraMap{border-radius:0!important;}
body.aegis-theme .leaflet-container{background:#111;}
body.aegis-theme .aegis-mock-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:16px;}
body.aegis-theme .aegis-mock-box{background:var(--aegis-panel);border:1px solid var(--aegis-border);padding:22px;min-height:110px;}
body.aegis-theme .aegis-mock-kicker{color:var(--aegis-amber);font:700 12px var(--aegis-mono);letter-spacing:.22em;text-transform:uppercase;margin-bottom:10px;}
body.aegis-theme .aegis-mock-title{font-weight:800;font-size:18px;color:#e6e8ec;}
body.aegis-theme .aegis-mock-sub{color:var(--aegis-muted);font-size:13px;margin-top:8px;line-height:1.6;}
@media (max-width:1200px){body.aegis-theme .sidebar{width:260px;}body.aegis-theme .aegis-topbar{grid-template-columns:1fr auto auto;}body.aegis-theme .aegis-clock{display:none;}body.aegis-theme .aegis-admin{display:none;}}

body.aegis-theme .aegis-section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:24px;}
body.aegis-theme .aegis-page-title{font-size:30px;line-height:1.1;color:#e7e9ee;margin:0;font-weight:900;}
body.aegis-theme .aegis-page-title::before{content:attr(data-kicker);display:block;color:var(--aegis-amber);font:800 13px/1 var(--aegis-mono);letter-spacing:.28em;text-transform:uppercase;margin-bottom:10px;}
body.aegis-theme .aegis-page-sub{color:#8a8f99;margin:8px 0 0;font-size:15px;}
body.aegis-theme .aegis-stat-grid{display:grid;grid-template-columns:repeat(4,minmax(180px,1fr));gap:18px;margin-bottom:30px;}
body.aegis-theme .aegis-stat{height:132px;background:var(--aegis-panel);border:1px solid var(--aegis-border);padding:20px;position:relative;}
body.aegis-theme .aegis-stat.danger{border-left:2px solid var(--aegis-red);}
body.aegis-theme .aegis-stat-label{font:800 13px var(--aegis-mono);letter-spacing:.17em;text-transform:uppercase;color:#858a94;}
body.aegis-theme .aegis-stat-value{font:900 32px var(--aegis-mono);color:#f0f1f4;margin-top:12px;}
body.aegis-theme .aegis-stat-value .thin{font-size:18px;color:#8b9098;}
body.aegis-theme .aegis-stat-sub{color:#8a8f99;margin-top:8px;font-size:13px;}
body.aegis-theme .aegis-grid-main{display:grid;grid-template-columns:minmax(0,2fr) minmax(340px,.95fr);gap:28px;}
body.aegis-theme .aegis-panel{background:var(--aegis-panel);border:1px solid var(--aegis-border);}
body.aegis-theme .aegis-panel-head{padding:18px 24px;border-bottom:1px solid var(--aegis-line);display:flex;align-items:center;justify-content:space-between;gap:12px;}
body.aegis-theme .aegis-panel-title{font:900 14px var(--aegis-mono);letter-spacing:.13em;text-transform:uppercase;color:#dedfe4;}
body.aegis-theme .aegis-event-feed{height:528px;overflow:auto;}
body.aegis-theme .aegis-feed-item{padding:16px;border-bottom:1px solid var(--aegis-line);display:grid;grid-template-columns:1fr auto;gap:10px;}
body.aegis-theme .aegis-severity-critical{color:var(--aegis-red);}
body.aegis-theme .aegis-severity-warning{color:var(--aegis-amber);}
body.aegis-theme .aegis-severity-info{color:var(--aegis-green);}
body.aegis-theme .aegis-severity-pill{display:inline-flex;align-items:center;height:24px;padding:0 9px;border-radius:4px;font:800 11px var(--aegis-mono);letter-spacing:.08em;text-transform:uppercase;border:1px solid currentColor;background:rgba(255,255,255,.03);}
body.aegis-theme .aegis-chart{height:380px;display:flex;align-items:flex-end;padding:30px 26px;gap:10px;}
body.aegis-theme .aegis-bar{flex:1;min-width:8px;background:linear-gradient(180deg,var(--aegis-amber),#6a440f);height:var(--h,20%);}
body.aegis-theme .aegis-area-grid{display:grid;grid-template-columns:repeat(2,minmax(220px,1fr));gap:16px;padding:24px;}
body.aegis-theme .aegis-area-card{border:1px solid var(--aegis-line);padding:18px;background:#15171a;}
body.aegis-theme .aegis-progress{height:5px;background:#0b0c0e;border-radius:20px;overflow:hidden;}
body.aegis-theme .aegis-progress span{display:block;height:100%;background:var(--aegis-amber);}
body.aegis-theme .aegis-live-toolbar{display:flex;justify-content:flex-end;gap:0;margin-bottom:22px;}
body.aegis-theme .aegis-live-toolbar button{height:36px;padding:0 18px;border:1px solid var(--aegis-border);background:#17191d;color:#858a94;font-family:var(--aegis-mono);cursor:pointer;}
body.aegis-theme .aegis-live-toolbar button.active{background:var(--aegis-amber);color:#101010;border-color:var(--aegis-amber);}
body.aegis-theme .aegis-live-grid{display:grid;grid-template-columns:repeat(var(--cols,4),minmax(220px,1fr));gap:16px;}
body.aegis-theme .aegis-live-card{position:relative;aspect-ratio:16/9;background:#071121;border:1px solid #10151f;overflow:hidden;}
body.aegis-theme .aegis-live-card.offline{background:repeating-linear-gradient(45deg,#101010 0,#101010 10px,#171717 10px,#171717 20px);border-color:#5a1717;}
body.aegis-theme .aegis-live-card iframe{width:100%;height:100%;border:0;display:block;}
body.aegis-theme .aegis-cam-badge{position:absolute;top:10px;left:10px;background:rgba(6,8,10,.86);border:1px solid var(--aegis-border);padding:6px 10px;font:800 12px var(--aegis-mono);color:#e9eaee;z-index:2;}
body.aegis-theme .aegis-cam-dot{display:inline-block;width:7px;height:7px;border-radius:50%;margin-right:7px;background:var(--aegis-green);}
body.aegis-theme .offline .aegis-cam-dot{background:var(--aegis-red);}
body.aegis-theme .aegis-cam-name{position:absolute;left:12px;bottom:12px;z-index:2;font-weight:800;color:#fff;}
body.aegis-theme .aegis-lost{height:100%;display:flex;align-items:center;justify-content:center;color:#858a94;font:800 13px var(--aegis-mono);letter-spacing:.3em;text-transform:uppercase;}
body.aegis-theme .aegis-controls{display:grid;grid-template-columns:repeat(4,minmax(150px,1fr));gap:12px;margin-bottom:20px;}
body.aegis-theme .aegis-control{background:#17191d;border:1px solid var(--aegis-border);padding:12px;}
body.aegis-theme .aegis-control label{display:block;color:#858a94;font:800 12px var(--aegis-mono);letter-spacing:.16em;text-transform:uppercase;margin-bottom:8px;}
body.aegis-theme .aegis-table{width:100%;border-collapse:collapse;background:var(--aegis-panel);border:1px solid var(--aegis-border);}
body.aegis-theme .aegis-table th,body.aegis-theme .aegis-table td{padding:16px;border-bottom:1px solid var(--aegis-line);text-align:left;}
body.aegis-theme .aegis-table .action{color:var(--aegis-amber);font:800 12px var(--aegis-mono);letter-spacing:.14em;text-transform:uppercase;background:transparent;border:0;cursor:pointer;}
body.aegis-theme .aegis-tabs{display:flex;gap:10px;margin:22px 0 18px;}
body.aegis-theme .aegis-tabs button{height:42px;padding:0 22px;background:#17191d;border:1px solid var(--aegis-border);color:#8c919b;font:800 12px var(--aegis-mono);letter-spacing:.2em;text-transform:uppercase;cursor:pointer;}
body.aegis-theme .aegis-tabs button.active{background:var(--aegis-amber);border-color:var(--aegis-amber);color:#101010;}
body.aegis-theme .aegis-tree{background:var(--aegis-panel);border:1px solid var(--aegis-border);padding:28px;font-size:17px;line-height:2.35;}
body.aegis-theme .aegis-tree-row{display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid transparent;padding:2px 0;}
body.aegis-theme .aegis-tree-row:hover{border-bottom-color:var(--aegis-line);}
body.aegis-theme .aegis-tree-actions{display:none;gap:10px;}
body.aegis-theme .aegis-tree-row:hover .aegis-tree-actions{display:flex;}
body.aegis-theme .aegis-tree-actions button{background:transparent;border:0;color:var(--aegis-amber);font:800 11px var(--aegis-mono);cursor:pointer;}
body.aegis-theme .aegis-video-stage{height:560px;background:#000;border:1px solid var(--aegis-border);display:flex;align-items:center;justify-content:center;color:#8a8f99;font-family:var(--aegis-mono);position:relative;overflow:hidden;}
body.aegis-theme .aegis-video-stage video{width:100%;height:100%;object-fit:contain;}
body.aegis-theme input[type=range]{accent-color:var(--aegis-amber);}
body.aegis-theme .aegis-timeline{height:46px;background:#111;border:1px solid var(--aegis-border);display:flex;align-items:center;padding:0 14px;gap:2px;}
body.aegis-theme .aegis-tick{height:22px;flex:1;background:#141619;border-right:1px solid #191c20;}
body.aegis-theme .aegis-tick.active{background:#704b15;}
body.aegis-theme .aegis-map-layout{display:grid;grid-template-columns:360px 1fr;gap:18px;height:calc(100vh - 150px);min-height:620px;}
body.aegis-theme .aegis-map-panel{background:rgba(20,22,25,.96);border:1px solid var(--aegis-border);padding:18px;overflow:auto;}
body.aegis-theme .aegis-map-canvas{border:1px solid var(--aegis-border);min-height:520px;}
body.aegis-theme .leaflet-popup-content-wrapper,body.aegis-theme .leaflet-popup-tip{background:#17191d;color:#e8eaee;border:1px solid var(--aegis-border);border-radius:0;}
body.aegis-theme .aegis-empty{padding:40px;text-align:center;color:#858a94;border:1px dashed var(--aegis-border);background:#141619;}
body.aegis-theme .hidden{display:none!important;}
@media (max-width:1400px){body.aegis-theme .aegis-stat-grid{grid-template-columns:repeat(2,1fr);}body.aegis-theme .aegis-grid-main{grid-template-columns:1fr;}body.aegis-theme .aegis-live-grid{--cols:2!important;}body.aegis-theme .aegis-map-layout{grid-template-columns:1fr;height:auto;}}

/* Aegis shell layout fix */
body.aegis-theme {
  --aegis-bg: #0f1012;
  --aegis-sidebar: #121518;
  --aegis-panel: #181a1e;
  --aegis-panel-2: #14171a;
  --aegis-border: #2a2d31;
  --aegis-text: #eef1f5;
  --aegis-muted: #8b929d;
  --aegis-amber: #ffa51f;
  --aegis-green: #00d084;
  --aegis-red: #ff4444;
  --aegis-mono: Consolas, "SFMono-Regular", "Courier New", monospace;
  margin: 0;
  background: var(--aegis-bg);
  color: var(--aegis-text);
  overflow: hidden;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.aegis-theme .layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  background: var(--aegis-bg);
}

body.aegis-theme .sidebar {
  position: relative;
  inset: auto;
  display: flex;
  flex-direction: column;
  width: auto;
  height: 100vh;
  overflow: hidden;
  background: var(--aegis-sidebar);
  border-right: 1px solid var(--aegis-border);
  color: var(--aegis-text);
}

body.aegis-theme .main {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--aegis-bg);
}

body.aegis-theme .content {
  padding: 30px;
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

body.aegis-theme .topbar {
  height: 70px;
  display: grid;
  grid-template-columns: minmax(260px, 720px) auto auto auto auto;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  border-bottom: 1px solid var(--aegis-border);
  background: #111417;
  box-sizing: border-box;
}

body.aegis-theme .aegis-brand {
  height: 70px;
  flex: 0 0 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--aegis-border);
  box-sizing: border-box;
}

body.aegis-theme .aegis-logo-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  background: var(--aegis-amber);
  color: #111417;
  border-radius: 4px;
}

body.aegis-theme .aegis-logo-mark svg,
body.aegis-theme .aegis-logo-mark i {
  width: 20px;
  height: 20px;
}

body.aegis-theme .aegis-logo-name {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.05;
  color: #ffffff;
}

body.aegis-theme .aegis-logo-sub {
  margin-top: 4px;
  font-family: var(--aegis-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: #a5abb5;
}

body.aegis-theme .aegis-nav {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 14px;
}

body.aegis-theme .aegis-nav-group {
  margin: 0 0 24px;
}

body.aegis-theme .aegis-nav-title {
  padding: 0 14px 8px;
  font-family: var(--aegis-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #8f98a5;
  text-transform: uppercase;
}

body.aegis-theme .aegis-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-left: 3px solid transparent;
  color: #e6eaf0;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

body.aegis-theme .aegis-nav a:hover,
body.aegis-theme .aegis-nav a.active {
  color: var(--aegis-amber);
  background: rgba(255, 165, 31, 0.13);
  border-left-color: var(--aegis-amber);
}

body.aegis-theme .aegis-nav a svg,
body.aegis-theme .aegis-nav a i {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  stroke-width: 2;
}

body.aegis-theme .aegis-sidebar-foot {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--aegis-border);
  background: var(--aegis-sidebar);
  font-family: var(--aegis-mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: #8f98a5;
  text-transform: uppercase;
}

body.aegis-theme .aegis-global-search {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--aegis-border);
  background: #0d0f11;
  color: var(--aegis-muted);
  min-width: 0;
}

body.aegis-theme .aegis-global-search svg,
body.aegis-theme .aegis-global-search i {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

body.aegis-theme .aegis-global-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--aegis-text);
  font-size: 14px;
}

body.aegis-theme .aegis-system-time {
  white-space: nowrap;
  text-align: right;
  font-family: var(--aegis-mono);
  color: #f5f7fb;
  font-weight: 800;
}

body.aegis-theme .aegis-system-time span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 4px;
  color: #8f98a5;
}

body.aegis-theme .aegis-online-dot {
  white-space: nowrap;
  color: var(--aegis-green);
  font-family: var(--aegis-mono);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
}

body.aegis-theme .aegis-online-dot::before {
  content: "";
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 10px;
  border-radius: 999px;
  background: var(--aegis-green);
  vertical-align: middle;
}

body.aegis-theme .aegis-user-box {
  min-width: 130px;
  text-align: right;
  white-space: nowrap;
}

body.aegis-theme .aegis-user-name {
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}

body.aegis-theme .aegis-user-role {
  margin-top: 3px;
  font-family: var(--aegis-mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: #8f98a5;
  text-transform: uppercase;
}

body.aegis-theme .aegis-logout {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--aegis-border);
  background: #15171b;
  color: #fff;
  cursor: pointer;
}

body.aegis-theme .aegis-logout svg,
body.aegis-theme .aegis-logout i {
  width: 18px;
  height: 18px;
}

body.aegis-theme .aegis-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

body.aegis-theme .aegis-eyebrow {
  margin-bottom: 8px;
  font-family: var(--aegis-mono);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 5px;
  color: var(--aegis-amber);
  text-transform: uppercase;
}

body.aegis-theme .aegis-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  color: #f4f6fa;
}

body.aegis-theme .aegis-subtitle {
  margin-top: 8px;
  color: var(--aegis-muted);
}

body.aegis-theme .aegis-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
}

body.aegis-theme .aegis-stat-card,
body.aegis-theme .aegis-panel,
body.aegis-theme .aegis-table-wrap,
body.aegis-theme .aegis-map-panel {
  border: 1px solid var(--aegis-border);
  background: var(--aegis-panel);
  border-radius: 0;
  box-shadow: none;
}

body.aegis-theme .aegis-stat-label,
body.aegis-theme .aegis-panel-title,
body.aegis-theme .aegis-table th {
  font-family: var(--aegis-mono);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: #9aa2ad;
}

body.aegis-theme .aegis-map-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 170px);
}

body.aegis-theme .aegis-map-panel {
  padding: 18px;
}

body.aegis-theme .aegis-map-panel label {
  display: block;
  margin: 14px 0 7px;
  font-family: var(--aegis-mono);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #9aa2ad;
  text-transform: uppercase;
}

body.aegis-theme .aegis-map-panel input,
body.aegis-theme .aegis-map-panel select,
body.aegis-theme .aegis-field {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid var(--aegis-border);
  background: #0d0f11;
  color: #f0f2f5;
  outline: none;
}

body.aegis-theme .aegis-map-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

body.aegis-theme .aegis-btn {
  height: 40px;
  border: 1px solid var(--aegis-border);
  background: #15171b;
  color: #fff;
  font-family: var(--aegis-mono);
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  text-transform: uppercase;
}

body.aegis-theme .aegis-btn.primary {
  border-color: var(--aegis-amber);
  background: var(--aegis-amber);
  color: #111417;
}

body.aegis-theme .aegis-map-canvas {
  min-height: calc(100vh - 170px);
  border: 1px solid var(--aegis-border);
  background: #111417;
}

body.aegis-theme .aegis-camera-list {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

body.aegis-theme .aegis-camera-list button {
  text-align: left;
  padding: 10px;
  border: 1px solid var(--aegis-border);
  background: #14171a;
  color: #eef1f5;
  cursor: pointer;
}

body.aegis-theme .aegis-camera-list small {
  display: block;
  margin-top: 4px;
  color: var(--aegis-muted);
}

body.aegis-theme .leaflet-container {
  background: #101114;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.aegis-theme .leaflet-popup-content-wrapper,
body.aegis-theme .leaflet-popup-tip {
  background: #181a1e;
  color: #eef1f5;
  border: 1px solid var(--aegis-border);
  border-radius: 0;
}

body.aegis-theme .aegis-popup-title {
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
}

body.aegis-theme .aegis-popup-meta {
  color: #a8afb9;
  font-size: 12px;
  line-height: 1.6;
}

body.aegis-theme .aegis-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

body.aegis-theme .aegis-popup-actions a {
  padding: 7px 9px;
  background: var(--aegis-amber);
  color: #111417;
  text-decoration: none;
  font-weight: 900;
  font-size: 12px;
}

@media (max-width: 1280px) {
  body.aegis-theme .layout { grid-template-columns: 260px minmax(0, 1fr); }
  body.aegis-theme .topbar { grid-template-columns: minmax(220px, 1fr) auto auto; }
  body.aegis-theme .aegis-system-time { display: none; }
  body.aegis-theme .aegis-stat-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

@media (max-width: 900px) {
  body.aegis-theme { overflow: auto; }
  body.aegis-theme .layout { display: block; overflow: visible; }
  body.aegis-theme .sidebar,
  body.aegis-theme .main { height: auto; overflow: visible; }
  body.aegis-theme .topbar { grid-template-columns: 1fr; height: auto; padding: 14px; }
  body.aegis-theme .aegis-map-layout { grid-template-columns: 1fr; }
}
/* End Aegis shell layout fix */

/* Theme-aware shared component overrides */
:root[data-color-mode] body.aegis-theme .layout,:root[data-color-mode] body.aegis-theme .main,:root[data-color-mode] body.aegis-theme .content{background:var(--theme-bg);color:var(--theme-text)}
:root[data-color-mode] body.aegis-theme .sidebar{background:var(--theme-sidebar);border-color:var(--theme-border)}
:root[data-color-mode] body.aegis-theme .topbar{background:var(--theme-topbar);border-color:var(--theme-border)}
:root[data-color-mode] body.aegis-theme .aegis-brand-name,:root[data-color-mode] body.aegis-theme .brand-name,:root[data-color-mode] body.aegis-theme .aegis-user-box b,:root[data-color-mode] body.aegis-theme .aegis-page-title,:root[data-color-mode] body.aegis-theme .page-title,:root[data-color-mode] body.aegis-theme .aegis-panel-title,:root[data-color-mode] body.aegis-theme .card-head h3{color:var(--theme-text-strong)!important}
:root[data-color-mode] body.aegis-theme .aegis-page-sub,:root[data-color-mode] body.aegis-theme .page-sub,:root[data-color-mode] body.aegis-theme .aegis-user-box span{color:var(--theme-text-muted)!important}
:root[data-color-mode] body.aegis-theme .aegis-panel,:root[data-color-mode] body.aegis-theme .card,:root[data-color-mode] body.aegis-theme .aegis-stat,:root[data-color-mode] body.aegis-theme .aegis-mock-box{background:var(--theme-surface);border-color:var(--theme-border);color:var(--theme-text)}
:root[data-color-mode] body.aegis-theme th{background:var(--theme-surface-raised);color:var(--theme-text-muted);border-color:var(--theme-line)}
:root[data-color-mode] body.aegis-theme td{color:var(--theme-text);border-color:var(--theme-line)}
:root[data-color-mode] body.aegis-theme tr:hover td{background:var(--theme-surface-hover)}
:root[data-color-mode] body.aegis-theme input,:root[data-color-mode] body.aegis-theme select,:root[data-color-mode] body.aegis-theme textarea,:root[data-color-mode] body.aegis-theme .aegis-search,:root[data-color-mode] body.aegis-theme .user-area-filter summary{background:var(--theme-input)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}
:root[data-color-mode] body.aegis-theme .menu a{color:var(--theme-text)}
:root[data-color-mode] body.aegis-theme .menu a:hover{background:var(--theme-surface-hover);color:var(--theme-text-strong)}
:root[data-color-mode] body.aegis-theme .menu a.active{background:var(--theme-accent-soft);color:var(--theme-accent);border-left-color:var(--theme-accent)}
:root[data-color-mode] body.aegis-theme .menu a.active svg{color:var(--theme-accent)}
:root[data-color-mode] body.aegis-theme .btn-primary,:root[data-color-mode] body.aegis-theme .btn-sm.primary,:root[data-color-mode] body.aegis-theme .camera-add-button,:root[data-color-mode] body.aegis-theme .user-add-button,:root[data-color-mode] body.aegis-theme .role-create button,:root[data-color-mode] body.aegis-theme .role-order-save{background:var(--theme-accent)!important;border-color:var(--theme-accent)!important;color:var(--theme-on-accent)!important}
:root[data-color-mode] body.aegis-theme .btn-primary:hover,:root[data-color-mode] body.aegis-theme .btn-sm.primary:hover{background:var(--theme-accent-hover)!important}
:root[data-color-mode] body.aegis-theme .btn-sm,:root[data-color-mode] body.aegis-theme .aegis-logout,:root[data-color-mode] body.aegis-theme .user-actions button{background:var(--theme-surface);border-color:var(--theme-border);color:var(--theme-text)}
:root[data-color-mode] body.aegis-theme .user-status.online,:root[data-color-mode] body.aegis-theme .status.daxuly{color:var(--theme-success)}
:root[data-color-mode] body.aegis-theme .user-account{border-color:var(--theme-success);background:var(--theme-success-soft);color:var(--theme-success)}
:root[data-color-mode] body.aegis-theme .user-account.locked{border-color:var(--theme-danger);background:var(--theme-danger-soft);color:var(--theme-danger)}
:root[data-color-mode] body.aegis-theme .user-actions button.danger,:root[data-color-mode] body.aegis-theme .camera-action-delete{color:var(--theme-danger)!important}
body.aegis-theme :is(button,input,select,textarea,a):focus-visible{outline:2px solid var(--theme-accent);outline-offset:2px}
body.aegis-theme :is(button,input,select,textarea):disabled{background:var(--theme-disabled-bg)!important;color:var(--theme-disabled-text)!important;border-color:var(--theme-border)!important;cursor:not-allowed}
body.aegis-theme ::selection{background:var(--theme-accent);color:var(--theme-on-accent)}
:root[data-color-mode="light"] body.aegis-theme .aegis-search input{color:var(--theme-text)!important}
:root[data-color-mode="light"] body.aegis-theme .aegis-clock-value,:root[data-color-mode="light"] body.aegis-theme .aegis-admin-name,:root[data-color-mode="light"] body.aegis-theme .aegis-stat-value{color:var(--theme-text-strong)}
:root[data-color-mode="light"] body.aegis-theme .aegis-chart,:root[data-color-mode="light"] body.aegis-theme .aegis-area-card,:root[data-color-mode="light"] body.aegis-theme .qa-item{background:var(--theme-surface-raised)}

/* Per-user theme settings */
.settings-page-stack{display:grid;gap:24px;max-width:1050px}
.theme-settings-panel,.settings-standard-panel{padding:26px}
.theme-settings-panel h2{margin:12px 0 8px;color:var(--theme-text);font-size:18px}
.theme-settings-description{margin:0 0 20px;color:var(--theme-text-muted);line-height:1.55}
.theme-mode-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.theme-choice,.theme-accent-choice{position:relative;display:grid;cursor:pointer;border:1px solid var(--theme-border);background:var(--theme-surface-soft);transition:border-color .16s ease,background .16s ease,transform .16s ease}
.theme-choice{grid-template-columns:112px 1fr;grid-template-rows:auto auto;column-gap:16px;align-items:center;padding:14px}
.theme-choice:hover,.theme-accent-choice:hover{border-color:var(--theme-accent);transform:translateY(-1px)}
.theme-choice:has(input:checked),.theme-accent-choice:has(input:checked){border-color:var(--theme-accent);background:var(--theme-accent-soft);box-shadow:inset 3px 0 0 var(--theme-accent)}
.theme-choice input,.theme-accent-choice input{position:absolute;opacity:0;pointer-events:none}
.theme-choice strong,.theme-accent-choice b{color:var(--theme-text)}
.theme-choice small,.theme-accent-choice small{color:var(--theme-text-muted)}
.theme-mode-preview{grid-row:1/3;display:grid;grid-template-columns:26px 1fr;grid-template-rows:11px 35px;gap:3px;width:112px;height:52px;padding:4px;border:1px solid var(--theme-border);background:#0d1014}
.theme-mode-preview i{display:block;background:#20252c}
.theme-mode-preview i:first-child{grid-row:1/3;background:#161a20}
.theme-mode-preview i:nth-child(2){background:var(--theme-accent)}
.theme-mode-preview.light{background:#f3f5f8}
.theme-mode-preview.light i{background:#d8dee7}
.theme-mode-preview.light i:first-child{background:#e7ebf1}
.theme-mode-preview.light i:nth-child(2){background:var(--theme-accent)}
.theme-accent-heading{margin-top:26px!important}
.theme-accent-options{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}
.theme-accent-choice{grid-template-columns:24px 1fr;column-gap:10px;align-items:center;padding:13px 12px;min-height:66px}
.theme-accent-choice>span{grid-row:1/3;width:20px;height:20px;border-radius:50%;background:var(--swatch);box-shadow:0 0 0 4px color-mix(in srgb,var(--swatch) 18%,transparent)}
.theme-feedback{min-height:20px;margin-top:18px;color:var(--theme-warning);font-size:13px}
.theme-feedback.error{color:var(--theme-danger)}
.theme-settings-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:12px;padding-top:18px;border-top:1px solid var(--theme-border)}
.theme-settings-actions button{min-height:42px;padding:0 18px;border:1px solid var(--theme-border);background:var(--theme-surface-soft);color:var(--theme-text);font-family:var(--aegis-mono);font-weight:700;text-transform:uppercase;letter-spacing:.08em;cursor:pointer}
.theme-settings-actions button.primary{border-color:var(--theme-accent);background:var(--theme-accent);color:var(--theme-on-accent)}
.theme-settings-actions button:disabled{border-color:var(--theme-disabled-bg);background:var(--theme-disabled-bg);color:var(--theme-disabled-text);cursor:not-allowed}
.settings-standard-panel label{display:block;margin:16px 0 8px;color:var(--theme-text)}
.settings-standard-panel input{display:block;width:min(100%,520px)}

@media(max-width:760px){
  .theme-mode-options,.theme-accent-options{grid-template-columns:1fr}
  .theme-settings-panel,.settings-standard-panel{padding:18px}
  .theme-settings-actions{flex-direction:column-reverse}
  .theme-settings-actions button{width:100%}
}

/* Shared Aegis header layout fix */
body.aegis-theme .topbar {
  display: flex;
  width: 100%;
  height: 70px;
  padding: 0 28px 0 30px;
  grid-template-columns: none;
  overflow: hidden;
}

body.aegis-theme .aegis-topbar {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(320px, 720px) minmax(24px, 1fr) auto auto auto 40px;
  align-items: center;
  gap: 24px;
}

body.aegis-theme .aegis-search {
  min-width: 0;
}

body.aegis-theme .aegis-user-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 150px;
  text-align: right;
  white-space: nowrap;
}

body.aegis-theme .aegis-user-box b {
  color: #f2f3f5;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

body.aegis-theme .aegis-user-box span {
  display: block;
  margin-top: 4px;
  color: #8a8e98;
  font: 11px var(--aegis-mono);
  letter-spacing: .16em;
  line-height: 1;
  text-transform: uppercase;
}

/* Camera management: keep legacy global button rules from distorting this page. */
body.camera-management-page.aegis-theme .aegis-section-head {
  align-items: flex-start;
}

body.camera-management-page.aegis-theme .aegis-page-title {
  white-space: nowrap;
}

body.camera-management-page.aegis-theme .camera-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: auto !important;
  min-width: 146px;
  height: 40px;
  padding: 0 18px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

body.camera-management-page.aegis-theme .camera-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

body.camera-management-page.aegis-theme .camera-search-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 520px) 190px auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

body.camera-management-page.aegis-theme .camera-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--aegis-border);
  background: #0d0f11;
  color: #7f8792;
}

body.camera-management-page.aegis-theme .camera-search-input-wrap svg {
  width: 17px;
  height: 17px;
}

body.camera-management-page.aegis-theme .camera-search-input-wrap input,
body.camera-management-page.aegis-theme .camera-search-toolbar select {
  height: 40px;
  border: 1px solid var(--aegis-border);
  outline: 0;
  background: #0d0f11;
  color: var(--aegis-text);
}

body.camera-management-page.aegis-theme .camera-search-input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
}

body.camera-management-page.aegis-theme .camera-search-toolbar select {
  width: 100%;
  padding: 0 12px;
}

body.camera-management-page.aegis-theme .camera-search-input-wrap:focus-within,
body.camera-management-page.aegis-theme .camera-search-toolbar select:focus {
  border-color: var(--aegis-amber);
}

body.camera-management-page.aegis-theme .camera-search-result-count {
  color: #8a8f99;
  font: 700 11px var(--aegis-mono);
  letter-spacing: .08em;
  white-space: nowrap;
}

body.camera-management-page.aegis-theme .camera-search-empty td {
  padding: 42px 20px;
  color: #8a8f99;
  text-align: center;
}

body.camera-management-page.aegis-theme .camera-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  font: 800 11px var(--aegis-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .16s ease, background-color .16s ease;
}

body.camera-management-page.aegis-theme .camera-row-action svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  stroke-width: 2;
}

body.camera-management-page.aegis-theme .camera-action-edit {
  color: var(--aegis-amber);
}

body.camera-management-page.aegis-theme .camera-action-edit:hover {
  background: rgba(255, 165, 31, .12);
}

body.camera-management-page.aegis-theme .camera-action-record {
  color: var(--aegis-green);
}

body.camera-management-page.aegis-theme .camera-action-record:hover {
  background: rgba(0, 208, 132, .12);
}

body.camera-management-page.aegis-theme .camera-action-stop {
  color: #ffb020;
}

body.camera-management-page.aegis-theme .camera-action-stop:hover {
  background: rgba(255, 176, 32, .12);
}

body.camera-management-page.aegis-theme .camera-action-delete {
  color: var(--aegis-red);
}

body.camera-management-page.aegis-theme .camera-action-delete:hover {
  background: rgba(255, 68, 68, .12);
}

body.camera-management-page.aegis-theme .camera-create-panel-host {
  display: grid;
  grid-template-rows: 0fr;
  margin-bottom: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: grid-template-rows 200ms ease, margin-bottom 200ms ease,
    opacity 180ms ease, transform 200ms ease;
}

body.camera-management-page.aegis-theme .camera-create-panel-host.open {
  grid-template-rows: 1fr;
  margin-bottom: 20px;
  opacity: 1;
  transform: translateY(0);
}

body.camera-management-page.aegis-theme .camera-create-panel-clip {
  min-height: 0;
  overflow: hidden;
}

body.camera-management-page.aegis-theme .camera-create-panel {
  padding: 26px 20px 20px;
  border: 1px solid var(--aegis-border);
  background: var(--aegis-panel);
}

@media (prefers-reduced-motion: reduce) {
  body.camera-management-page.aegis-theme .camera-create-panel-host {
    transition: none;
  }
}

body.camera-management-page.aegis-theme .camera-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 16px;
}

body.camera-management-page.aegis-theme .camera-create-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

body.camera-management-page.aegis-theme .camera-create-field span {
  color: #969da8;
  font: 800 11px var(--aegis-mono);
  letter-spacing: .17em;
  text-transform: uppercase;
}

body.camera-management-page.aegis-theme .camera-create-field input,
body.camera-management-page.aegis-theme .camera-create-field select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--aegis-border);
  border-radius: 0;
  outline: 0;
  background: #0d0f11;
  color: #eef1f5;
  font-size: 14px;
}

body.camera-management-page.aegis-theme .camera-create-field input:focus,
body.camera-management-page.aegis-theme .camera-create-field select:focus {
  border-color: var(--aegis-amber);
  box-shadow: 0 0 0 2px rgba(255, 165, 31, .1);
}

body.camera-management-page.aegis-theme .camera-create-feedback {
  min-height: 20px;
  margin-top: 16px;
  color: #9299a4;
  font-size: 13px;
  line-height: 1.55;
}

body.camera-management-page.aegis-theme .camera-create-feedback.error {
  color: var(--aegis-red);
}

body.camera-management-page.aegis-theme .camera-create-feedback.pending {
  color: #ffb020;
}

body.camera-management-page.aegis-theme .camera-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

body.camera-management-page.aegis-theme .camera-create-cancel,
body.camera-management-page.aegis-theme .camera-create-submit {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--aegis-border);
  font: 900 11px var(--aegis-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
}

body.camera-management-page.aegis-theme .camera-create-cancel {
  background: #15171b;
  color: #d8dbe1;
}

body.camera-management-page.aegis-theme .camera-create-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: var(--aegis-amber);
  background: var(--aegis-amber);
  color: #111417;
}

body.camera-management-page.aegis-theme .camera-create-submit svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 1100px) {
  body.camera-management-page.aegis-theme .camera-create-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  body.camera-management-page.aegis-theme .camera-search-toolbar {
    grid-template-columns: 1fr;
  }

  body.camera-management-page.aegis-theme .camera-create-grid {
    grid-template-columns: 1fr;
  }

  body.camera-management-page.aegis-theme .camera-create-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
}

@media (max-width: 1280px) {
  body.aegis-theme .aegis-topbar {
    grid-template-columns: minmax(260px, 1fr) minmax(12px, .4fr) auto auto 40px;
    gap: 16px;
  }

  body.aegis-theme .aegis-system-time {
    display: none;
  }
}

@media (max-width: 900px) {
  body.aegis-theme .topbar {
    height: auto;
    padding: 14px;
  }

  body.aegis-theme .aegis-topbar {
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 12px;
  }

  body.aegis-theme .aegis-topbar-spacer,
  body.aegis-theme .aegis-online-dot,
  body.aegis-theme .aegis-system-time,
  body.aegis-theme .aegis-user-box {
    display: none;
  }

  body.camera-management-page.aegis-theme .aegis-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  body.camera-management-page.aegis-theme .camera-add-button {
    align-self: flex-start;
  }
}

/* Dynamic area tree management */
body.area-management-page.aegis-theme .area-page-head {
  margin-top: 12px;
}

body.area-management-page.aegis-theme .area-page-head .aegis-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.area-management-page.aegis-theme .area-page-head .aegis-page-title::before {
  position: absolute;
  transform: translateY(-32px);
}

body.area-management-page.aegis-theme .area-page-head .aegis-page-title svg {
  width: 24px;
  color: var(--aegis-amber);
}

body.area-management-page.aegis-theme .area-page-head .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: auto;
  min-height: 42px;
  padding: 0 18px;
}

body.area-management-page.aegis-theme .area-page-head .btn-primary svg {
  width: 16px;
}

body.area-management-page.aegis-theme .area-tree-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

body.area-management-page.aegis-theme .area-tree-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--aegis-border);
  background: #0d0f11;
  color: #7f8792;
}

body.area-management-page.aegis-theme .area-tree-search:focus-within {
  border-color: var(--aegis-amber);
}

body.area-management-page.aegis-theme .area-tree-search svg {
  width: 17px;
}

body.area-management-page.aegis-theme .area-tree-search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0 !important;
  outline: 0;
  background: transparent !important;
}

body.area-management-page.aegis-theme #areaTreeCount {
  color: #8a8f99;
  font: 700 11px var(--aegis-mono);
  letter-spacing: .08em;
  white-space: nowrap;
}

body.area-management-page.aegis-theme .area-tree {
  min-height: 360px;
  padding: 18px 20px 22px;
  border: 1px solid var(--aegis-border);
  background: var(--aegis-panel);
}

body.area-management-page.aegis-theme .area-tree-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 2px 4px 2px calc(var(--area-depth) * 20px);
}

body.organization-management-page.aegis-theme .area-tree-row {
  grid-template-columns: 22px minmax(0, 1fr) auto;
}

body.area-management-page.aegis-theme .area-tree-row:hover,
body.area-management-page.aegis-theme .area-tree-row:focus-within {
  background: #1b1d21;
}

body.area-management-page.aegis-theme .area-tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #9299a4;
  cursor: pointer;
}

body.area-management-page.aegis-theme .area-tree-toggle.empty {
  visibility: hidden;
}

body.area-management-page.aegis-theme .area-tree-toggle svg {
  width: 14px;
}

body.area-management-page.aegis-theme .area-tree-name {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

body.area-management-page.aegis-theme .area-tree-name strong {
  overflow: hidden;
  color: #e7e9ee;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.area-management-page.aegis-theme .area-tree-name code {
  color: #777f8a;
  font: 11px var(--aegis-mono);
}

body.area-management-page.aegis-theme .area-tree-counts {
  display: flex;
  gap: 8px;
}

body.area-management-page.aegis-theme .area-tree-counts span {
  padding: 4px 7px;
  border: 1px solid #30343a;
  color: #8e959f;
  font: 10px var(--aegis-mono);
  white-space: nowrap;
}

body.area-management-page.aegis-theme .area-tree-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}

body.area-management-page.aegis-theme .area-tree-row:hover .area-tree-actions,
body.area-management-page.aegis-theme .area-tree-row:focus-within .area-tree-actions {
  opacity: 1;
}

body.area-management-page.aegis-theme .area-tree-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #737a84;
  cursor: pointer;
}

body.area-management-page.aegis-theme .area-tree-actions button:hover {
  background: rgba(255, 255, 255, .06);
  color: #d8dbe1;
}

body.area-management-page.aegis-theme .area-tree-actions button.add {
  color: var(--aegis-amber);
}

body.area-management-page.aegis-theme .area-tree-actions button.danger {
  color: #737a84;
}

body.area-management-page.aegis-theme .area-tree-actions button.danger:hover {
  background: rgba(255, 68, 68, .12);
  color: var(--aegis-red);
}

body.area-management-page.aegis-theme .area-tree-actions svg {
  width: 14px;
}

body.area-management-page.aegis-theme .area-tree-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: #858c96;
  text-align: center;
}

body.area-management-page.aegis-theme .area-add-root {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 24px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--aegis-amber);
  font: 800 12px var(--aegis-mono);
  letter-spacing: .12em;
  cursor: pointer;
}

body.area-management-page.aegis-theme .area-add-root:hover {
  color: #ffc15d;
}

body.area-management-page.aegis-theme .area-add-root svg {
  width: 14px;
}

body.area-management-page.aegis-theme .area-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 8, .78);
  backdrop-filter: blur(3px);
}

body.area-management-page.aegis-theme .area-dialog {
  width: min(480px, 100%);
  padding: 24px;
  border: 1px solid #353a40;
  background: #181a1e;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

body.area-management-page.aegis-theme .area-dialog-title {
  color: #f0f1f4;
  font-size: 20px;
  font-weight: 900;
}

body.area-management-page.aegis-theme .area-dialog p {
  color: #9ba1aa;
  line-height: 1.6;
}

body.area-management-page.aegis-theme .area-dialog label {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: #9097a1;
  font: 800 11px var(--aegis-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}

body.area-management-page.aegis-theme .area-dialog input,
body.area-management-page.aegis-theme .area-dialog select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
}

body.area-management-page.aegis-theme .area-dialog-feedback {
  min-height: 22px;
  margin-top: 10px;
  color: var(--aegis-red);
  font-size: 13px;
}

body.area-management-page.aegis-theme .area-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

body.area-management-page.aegis-theme .area-dialog-actions button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--aegis-border);
  background: #15171b;
  color: #d8dbe1;
  font: 800 11px var(--aegis-mono);
  letter-spacing: .1em;
  cursor: pointer;
}

body.area-management-page.aegis-theme .area-dialog-actions button.primary {
  border-color: var(--aegis-amber);
  background: var(--aegis-amber);
  color: #111;
}

body.area-management-page.aegis-theme .area-dialog-actions button.danger {
  border-color: var(--aegis-red);
  background: var(--aegis-red);
  color: #fff;
}

@media (max-width: 1050px) {
  body.area-management-page.aegis-theme .area-tree-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  body.area-management-page.aegis-theme .area-tree-counts {
    display: none;
  }
}

@media (max-width: 760px) {
  body.area-management-page.aegis-theme .area-page-head {
    flex-direction: column;
  }

  body.area-management-page.aegis-theme .area-tree-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  body.area-management-page.aegis-theme .area-tree {
    padding: 8px;
    overflow-x: auto;
  }

  body.area-management-page.aegis-theme .area-tree-actions {
    opacity: 1;
  }
}
.content.aegis-route-loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 120ms ease;
}

/* User management v2 */
body.user-management-page.aegis-theme .user-page-head { margin-top:12px; align-items:flex-end; }
body.user-management-page.aegis-theme .user-add-button { display:inline-flex;align-items:center;gap:8px;width:auto;min-height:40px;padding:0 18px;border:1px solid var(--aegis-amber);background:var(--aegis-amber);color:#111;font:800 11px var(--aegis-mono);letter-spacing:.12em;cursor:pointer; }
body.user-management-page.aegis-theme .user-add-button svg { width:15px; }
body.user-management-page.aegis-theme .user-page-toolbar { display:grid;grid-template-columns:minmax(260px,1fr) 190px 230px 210px auto;gap:10px;margin:22px 0 10px;align-items:stretch; }
body.user-management-page.aegis-theme .user-page-toolbar input,
body.user-management-page.aegis-theme .user-page-toolbar select,
body.user-management-page.aegis-theme .user-area-filter summary { width:100%;height:42px;padding:0 12px;border:1px solid var(--aegis-border);background:#17191d;color:#e4e6ea;font-size:13px; }
body.user-management-page.aegis-theme .user-search { position:relative;display:flex;align-items:center; }
body.user-management-page.aegis-theme .user-search svg { position:absolute;left:12px;width:17px;color:#838a94; }
body.user-management-page.aegis-theme .user-search input { padding-left:40px; }
body.user-management-page.aegis-theme .user-area-filter { position:relative; }
body.user-management-page.aegis-theme .user-area-filter summary { display:flex;align-items:center;cursor:pointer;list-style:none; }
body.user-management-page.aegis-theme .user-filter-tree { position:absolute;z-index:50;top:46px;right:0;width:360px;max-height:320px;overflow:auto;padding:10px;border:1px solid #383c43;background:#17191d;box-shadow:0 18px 45px #0009; }
body.user-management-page.aegis-theme .user-tree-option { display:grid;grid-template-columns:18px minmax(0,1fr) auto;align-items:center;gap:8px;min-height:34px;padding-left:calc(var(--user-tree-depth) * 18px);color:#d9dce2;font-size:13px; }
body.user-management-page.aegis-theme .user-tree-option code { color:#737b87;font:10px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-reset-filter { display:inline-flex;align-items:center;justify-content:center;gap:7px;padding:0 13px;border:1px solid var(--aegis-border);background:#17191d;color:#aeb3bb;font:800 10px var(--aegis-mono);letter-spacing:.08em;cursor:pointer; }
body.user-management-page.aegis-theme .user-reset-filter svg { width:14px; }
body.user-management-page.aegis-theme .user-result-line { display:flex;justify-content:space-between;gap:16px;margin:10px 0;color:#777e89;font:11px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-server-note { color:#9b731f; }
body.user-management-page.aegis-theme .user-table-wrap { overflow:auto;border:1px solid var(--aegis-border); }
body.user-management-page.aegis-theme .user-table { min-width:1450px; }
body.user-management-page.aegis-theme .user-table code { color:var(--aegis-amber);font:12px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-role { color:var(--aegis-amber); }
body.user-management-page.aegis-theme .user-muted { color:#777e89; }
body.user-management-page.aegis-theme .user-more { padding:2px 6px;border:1px solid #454a52;color:#aeb3bb;font:10px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-status { display:inline-flex;align-items:center;gap:6px;font:800 10px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-status i { width:7px;height:7px;border-radius:50%;background:#747b85; }
body.user-management-page.aegis-theme .user-status.online { color:var(--aegis-green); } body.user-management-page.aegis-theme .user-status.online i { background:var(--aegis-green); }
body.user-management-page.aegis-theme .user-status.offline { color:#8b919a; }
body.user-management-page.aegis-theme .user-account { padding:4px 8px;border:1px solid #087759;background:#073d32;color:var(--aegis-green);font:800 10px var(--aegis-mono); }
body.user-management-page.aegis-theme .user-account.locked { border-color:#8b2f2f;background:#401c1c;color:var(--aegis-red); }
body.user-management-page.aegis-theme .user-actions { display:flex;align-items:center;justify-content:flex-end;gap:6px;white-space:nowrap; }
body.user-management-page.aegis-theme .user-actions button { display:inline-flex;align-items:center;gap:4px;padding:5px 7px;border:1px solid #3b4048;background:#181a1e;color:#c8ccd3;font-size:11px;cursor:pointer; }
body.user-management-page.aegis-theme .user-actions button svg { width:13px; }
body.user-management-page.aegis-theme .user-actions button.lock { color:var(--aegis-amber); } body.user-management-page.aegis-theme .user-actions button.danger { color:var(--aegis-red); }
body.user-management-page.aegis-theme .user-empty { padding:42px;text-align:center;color:#858c96; }
body.user-management-page.aegis-theme .user-error { color:var(--aegis-red); }
body.user-management-page.aegis-theme .user-error button { margin-left:10px; }
body.user-management-page.aegis-theme .user-inline-form { margin:18px 0 22px;padding:22px;border:1px solid #343940;background:#181a1e;animation:userPanelIn .2s ease-out; }
@keyframes userPanelIn { from { opacity:0;transform:translateY(-10px); } to { opacity:1;transform:none; } }
body.user-management-page.aegis-theme .user-form-title { display:flex;justify-content:space-between;align-items:start;margin-bottom:18px; }
body.user-management-page.aegis-theme .user-form-title span { color:var(--aegis-amber);font:800 11px var(--aegis-mono);letter-spacing:.13em; }
body.user-management-page.aegis-theme .user-form-title h2 { margin:5px 0 0;color:#eef0f3;font-size:20px; }
body.user-management-page.aegis-theme .user-form-title button { border:0;background:transparent;color:#9299a3;cursor:pointer; }
body.user-management-page.aegis-theme .user-form-grid { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px; }
body.user-management-page.aegis-theme .user-form-grid>label,
body.user-management-page.aegis-theme .user-scope-field>span,
body.user-management-page.aegis-theme .user-password-inputs label { display:grid;gap:7px;color:#8d949e;font:800 10px var(--aegis-mono);letter-spacing:.12em; }
body.user-management-page.aegis-theme .user-form-grid input,
body.user-management-page.aegis-theme .user-form-grid select { width:100%;height:42px;padding:0 11px;border:1px solid var(--aegis-border);background:#0e0f11;color:#e6e8eb; }
body.user-management-page.aegis-theme .user-scope-field { grid-column:span 2; }
body.user-management-page.aegis-theme .user-scope-field details { margin-top:8px;border:1px solid var(--aegis-border);background:#111316; }
body.user-management-page.aegis-theme .user-scope-field summary { padding:10px;cursor:pointer;color:#c9cdd3;font-size:12px; }
body.user-management-page.aegis-theme .user-form-tree { max-height:210px;overflow:auto;padding:8px 12px; }
body.user-management-page.aegis-theme .user-check { display:flex!important;grid-template-columns:none!important;align-items:center;gap:8px!important;margin-top:10px;color:#c9cdd3!important;font:12px sans-serif!important;letter-spacing:0!important; }
body.user-management-page.aegis-theme .user-check input { width:15px!important;height:15px!important; }
body.user-management-page.aegis-theme .user-password-field { display:grid;align-content:start; }
body.user-management-page.aegis-theme .user-password-inputs { display:grid;gap:10px; }
body.user-management-page.aegis-theme .user-password-inputs[hidden] { display:none; }
body.user-management-page.aegis-theme .user-form-feedback { min-height:22px;margin-top:12px;color:var(--aegis-red);font-size:12px; }
body.user-management-page.aegis-theme .user-form-actions,
body.user-management-page.aegis-theme .user-dialog-actions { display:flex;justify-content:flex-end;gap:10px; }
body.user-management-page.aegis-theme .user-form-actions button,
body.user-management-page.aegis-theme .user-dialog-actions button { min-height:40px;padding:0 18px;border:1px solid var(--aegis-border);background:#15171b;color:#d8dbe1;font:800 10px var(--aegis-mono);letter-spacing:.1em;cursor:pointer; }
body.user-management-page.aegis-theme .user-form-actions button.primary { border-color:var(--aegis-amber);background:var(--aegis-amber);color:#111; }
body.user-management-page.aegis-theme .user-dialog-backdrop { position:fixed;inset:0;z-index:10000;display:grid;place-items:center;padding:20px;background:#030508cc;backdrop-filter:blur(3px); }
body.user-management-page.aegis-theme .user-dialog { width:min(480px,100%);padding:24px;border:1px solid #353a40;background:#181a1e;color:#e8eaed; }
body.user-management-page.aegis-theme .user-dialog label { display:grid;gap:8px;margin:15px 0;color:#9097a1;font:800 10px var(--aegis-mono);letter-spacing:.1em; }
body.user-management-page.aegis-theme .user-dialog select,
body.user-management-page.aegis-theme .user-dialog input { height:42px;padding:0 10px;background:#0d0f11;color:#fff;border:1px solid var(--aegis-border); }
body.user-management-page.aegis-theme .user-lock-range { display:grid;grid-template-columns:1fr 1fr;gap:12px; }
body.user-management-page.aegis-theme .user-lock-range[hidden] { display:none; }
body.user-management-page.aegis-theme .user-warning { color:#b78b35;font-size:12px;line-height:1.5; }
body.user-management-page.aegis-theme .user-dialog-actions button.danger { border-color:var(--aegis-red);background:var(--aegis-red);color:#fff; }
@media (max-width:1250px) { body.user-management-page.aegis-theme .user-page-toolbar { grid-template-columns:1fr 1fr 1fr; } body.user-management-page.aegis-theme .user-form-grid { grid-template-columns:1fr 1fr; } }
@media (max-width:760px) { body.user-management-page.aegis-theme .user-page-head { align-items:flex-start;flex-direction:column; } body.user-management-page.aegis-theme .user-page-toolbar,body.user-management-page.aegis-theme .user-form-grid,body.user-management-page.aegis-theme .user-lock-range { grid-template-columns:1fr; } body.user-management-page.aegis-theme .user-scope-field { grid-column:auto; } body.user-management-page.aegis-theme .user-filter-tree { left:0;right:auto;width:min(360px,calc(100vw - 48px)); } }

/* Database-backed RBAC role matrix */
.role-column-draggable{cursor:grab;transition:opacity .16s ease,box-shadow .16s ease,background-color .16s ease}.role-column-draggable:active{cursor:grabbing}.role-column-dragging{opacity:.42}.role-column-drop-target{box-shadow:inset 3px 0 0 #ffa51f;background:#211a10!important}.role-column-actions button:disabled{opacity:.25;cursor:not-allowed}.role-column-system{cursor:default}
.role-order-actions{display:flex;justify-content:flex-end;padding:18px 0}.role-order-save{min-width:178px;height:42px;padding:0 18px;border:1px solid #ffa51f;background:#ffa51f;color:#090a0b;font:700 12px var(--aegis-mono,monospace);letter-spacing:1.5px;display:inline-flex;align-items:center;justify-content:center;gap:8px;cursor:pointer}.role-order-save svg{width:15px;height:15px}.role-order-save:disabled{border-color:#30343a;background:#1a1c20;color:#676c75;cursor:not-allowed;opacity:.7}
.role-page-app{padding-top:4px}.role-page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;margin-bottom:22px}.role-create{display:flex;gap:10px;align-items:center}.role-create input{width:230px;height:42px;background:#17191d;border:1px solid #2a2d32;color:#e8e9eb;padding:0 14px}.role-create button{height:42px;padding:0 18px;border:0;background:var(--aegis-amber,#ffa51f);color:#090a0b;font:700 12px var(--aegis-mono,monospace);letter-spacing:2px;display:flex;align-items:center;gap:7px;cursor:pointer}.role-create svg{width:15px}.role-feedback{min-height:22px;color:#00d99a;font-size:13px}.role-feedback.error{color:#ff4343}.role-matrix-scroll{border:1px solid #2b2e33;overflow:auto;max-width:100%}.role-matrix{width:100%;min-width:920px;border-collapse:collapse;background:#17191c}.role-matrix th,.role-matrix td{border-bottom:1px solid #24272c;padding:17px 15px;text-align:center}.role-matrix thead th{position:sticky;top:0;z-index:2;background:#111315;color:#ffa51f;font:700 12px var(--aegis-mono,monospace);letter-spacing:2px;min-width:190px}.role-matrix .role-permission-column{position:sticky;left:0;z-index:3;background:#17191c;text-align:left;min-width:330px}.role-matrix thead .role-permission-column{background:#111315;color:#888d96}.role-matrix td.role-permission-column strong{display:block;color:#e5e7eb;font-size:15px}.role-matrix td.role-permission-column code{display:block;color:#89a0bc;margin-top:4px}.role-group td{position:sticky;left:0;background:#131518;color:#838891;text-align:left;font:12px var(--aegis-mono,monospace);letter-spacing:3px;padding:11px}.role-column-title{text-transform:uppercase}.role-system-label{margin-top:5px;color:#858991;font:11px var(--aegis-mono,monospace);letter-spacing:1px}.role-column-actions{display:flex;justify-content:center;gap:8px;margin-top:7px}.role-column-actions button{border:0;background:transparent;color:#9298a2;cursor:pointer;padding:2px}.role-column-actions button.danger{color:#ff4343}.role-column-actions svg{width:15px;height:15px}.role-checkbox{width:16px;height:16px;accent-color:#ffa51f;cursor:pointer}.role-checkbox:disabled{cursor:not-allowed}.role-state{border:1px solid #2b2e33;padding:42px;text-align:center;color:#9297a0}.role-state button{display:block;margin:16px auto 0;background:#ffa51f;border:0;padding:10px 16px}.role-error{color:#ff6868}.role-dialog-backdrop{position:fixed;inset:0;background:rgba(2,4,7,.78);z-index:10000;display:grid;place-items:center;padding:20px}.role-dialog{width:min(440px,100%);background:#181a1e;border:1px solid #363a42;padding:26px;color:#e8eaee}.role-dialog h2{margin:0 0 18px}.role-dialog p{color:#adb1ba;line-height:1.6}.role-dialog label{display:grid;gap:8px;color:#aeb3bc}.role-dialog input{height:44px;background:#0d0f11;border:1px solid #30343a;color:#fff;padding:0 12px}.role-dialog-error{min-height:20px;color:#ff5353;margin-top:10px}.role-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:18px}.role-dialog-actions button{height:40px;padding:0 18px;background:#131518;border:1px solid #30343a;color:#ddd}.role-dialog-actions .primary{background:#ffa51f;color:#090a0b;border-color:#ffa51f}.role-dialog-actions .danger{background:#ff3d46;color:#fff;border-color:#ff3d46}@media(max-width:900px){.role-page-head{align-items:stretch;flex-direction:column}.role-create{justify-content:flex-end}.role-create input{flex:1}.role-matrix .role-permission-column{min-width:250px}}

/* Operational map */
body.operational-map-page .content{padding-top:28px}.map-page-heading{margin-bottom:18px}.map-page-heading .eyebrow{color:var(--aegis-amber);font:700 11px var(--aegis-mono);letter-spacing:2.5px}.map-page-heading h1{margin:6px 0 4px;font-size:28px}.map-page-heading p{margin:0;color:var(--theme-muted,#858b95)}
.operational-map-layout{display:grid;grid-template-columns:320px minmax(0,1fr);height:calc(100vh - 188px);min-height:560px;border:1px solid var(--aegis-border);background:var(--theme-panel,#17191d)}.map-filter-panel{z-index:500;padding:20px;border-right:1px solid var(--aegis-border);overflow:auto}.map-panel-head{display:flex;justify-content:space-between;padding-bottom:15px;border-bottom:1px solid var(--aegis-border);font:700 11px var(--aegis-mono);letter-spacing:1.5px}.map-panel-head b{color:var(--aegis-amber);font-weight:500;letter-spacing:0}
.map-control-group{display:grid;gap:8px;padding:17px 0;border-bottom:1px solid var(--aegis-border)}.map-control-group label{color:var(--theme-muted,#8a9099);font:700 10px var(--aegis-mono);letter-spacing:1.3px}.map-control-group input,.map-control-group select{height:40px;padding:0 11px;border:1px solid var(--aegis-border);background:var(--theme-input,#0d0f11);color:var(--theme-text,#e6e8eb)}.map-search-row{display:grid;grid-template-columns:1fr auto;gap:7px}.map-search-row button,.map-filter-actions button{padding:0 13px;border:1px solid var(--aegis-border);background:var(--theme-panel,#202329);color:var(--theme-text,#eee);font:700 10px var(--aegis-mono);cursor:pointer}.map-search-row button,.map-filter-actions .primary{background:var(--aegis-amber);color:#090a0b}.map-filter-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;height:40px}
.map-feedback{min-height:48px;padding:14px 0;color:var(--theme-muted,#8b919a);font-size:11px}.map-feedback.success{color:var(--theme-success,#00d99a)}.map-feedback.warning{color:var(--theme-warning,#ffa51f)}.map-feedback.error{color:var(--theme-danger,#ff4343)}.map-legend{display:flex;gap:20px;font-size:11px}.map-legend span{display:flex;align-items:center;gap:7px}.map-legend i{width:9px;height:9px;border-radius:50%;background:var(--theme-success,#00d99a)}.map-legend i.offline{background:var(--theme-danger,#ff4343)}.map-hint{margin-top:18px;color:var(--theme-muted,#777e88);font-size:11px}.operational-map-canvas{height:100%;background:#0d1015}
.camera-map-marker-wrap{background:none;border:0}.camera-map-marker{display:block;width:18px;height:18px;border:3px solid #fff;border-radius:50%;background:var(--marker-color);box-shadow:0 2px 8px #000b}.operational-map-canvas .leaflet-popup-content-wrapper,.operational-map-canvas .leaflet-popup-tip{border-radius:0;background:var(--theme-panel,#17191d);color:var(--theme-text,#eee)}.operational-map-canvas .leaflet-popup-content{width:285px!important;margin:0}.map-popup-preview{height:150px;background:#050608}.map-popup-preview iframe{width:100%;height:100%;border:0}.map-popup-offline{display:grid;height:100%;place-items:center;color:var(--theme-danger,#ff4343);font:700 11px var(--aegis-mono)}.map-popup-body{padding:14px}.map-popup-body strong,.map-popup-body code{display:block}.map-popup-body code{color:var(--aegis-amber)}.map-popup-body p{color:var(--theme-muted,#9197a0)}.map-popup-status{color:var(--theme-danger,#ff4343)}.map-popup-status.online{color:var(--theme-success,#00d99a)}.map-popup-body nav{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:12px}.map-popup-body nav a{display:grid;min-height:34px;place-items:center;border:1px solid var(--aegis-border);color:inherit;font:700 9px var(--aegis-mono);text-decoration:none}.map-popup-body nav a:first-child{background:var(--aegis-amber);color:#090a0b}.camera-deep-link-highlight{outline:2px solid var(--theme-danger,#ff4343)!important;outline-offset:-2px;box-shadow:0 0 0 4px #ff434338!important}@media(max-width:900px){.operational-map-layout{grid-template-columns:1fr;height:auto}.operational-map-canvas{height:65vh}}
/* Shared hierarchical picker */
.tree-picker { position: relative; width: 100%; }
.tree-picker button { font: inherit; }
.tree-picker-trigger {
  width: 100%; min-height: 42px; padding: 9px 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; color: var(--aegis-text, #d9dde5);
  background: var(--aegis-input, #0d0f11); border: 1px solid var(--aegis-border, #2a2d31);
  cursor: pointer; text-align: left;
}
.tree-picker-popover {
  position: absolute; z-index: 150; top: calc(100% + 6px); left: 0; width: min(520px, 92vw);
  max-height: 360px; overflow: auto; padding: 10px; background: var(--aegis-panel, #17191c);
  border: 1px solid var(--aegis-border, #30343a); box-shadow: 0 18px 48px rgba(0,0,0,.35);
}
.tree-picker-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 9px; border-bottom: 1px solid var(--aegis-border, #30343a); }
.tree-picker-breadcrumb button, .tree-picker-select-current {
  padding: 6px 9px; color: var(--aegis-amber, #ffa51f); background: transparent;
  border: 1px solid var(--aegis-border, #30343a); cursor: pointer;
}
.tree-picker-select-current { width: 100%; margin: 10px 0 4px; }
.tree-picker-options { display: grid; gap: 4px; padding-top: 8px; }
.tree-picker-option {
  min-height: 40px; padding: 8px 10px; display: grid; grid-template-columns: minmax(0,1fr) auto 18px;
  align-items: center; gap: 10px; color: var(--aegis-text, #d9dde5); background: transparent;
  border: 1px solid transparent; cursor: pointer; text-align: left;
}
.tree-picker-option:hover, .tree-picker-option:focus-visible { border-color: var(--aegis-amber, #ffa51f); outline: none; }
.tree-picker-option code { color: var(--aegis-muted, #858b96); font-size: 11px; }
.tree-picker-option[aria-disabled="true"] { opacity: .82; cursor: pointer; }
.tree-picker-empty { padding: 14px 10px; color: var(--aegis-muted, #858b96); }
@media (max-width: 700px) { .tree-picker-popover { position: fixed; inset: 18% 12px auto; width: auto; max-height: 64vh; } }
/* Atomic camera redistribution wizard */
.area-restructure-backdrop { padding: 24px; }
.area-restructure-dialog { width: min(1180px, 96vw); max-height: 92vh; overflow: auto; background: var(--aegis-panel, #17191c); border: 1px solid var(--aegis-border, #30343a); color: var(--aegis-text, #d9dde5); }
.area-restructure-dialog > header, .area-restructure-dialog > footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--aegis-border, #30343a); }
.area-restructure-dialog > header span, .area-restructure-dialog > footer span { display: block; color: var(--aegis-muted, #858b96); font: 11px var(--aegis-mono); letter-spacing: .14em; }
.area-restructure-dialog > header h2 { margin: 5px 0 0; }
.area-restructure-dialog > header button { color: var(--aegis-text, #d9dde5); background: transparent; border: 0; font-size: 26px; cursor: pointer; }
.area-restructure-tools { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--aegis-border, #30343a); }
.area-restructure-tools label { display: grid; gap: 6px; color: var(--aegis-muted, #858b96); font: 11px var(--aegis-mono); letter-spacing: .1em; }
.area-restructure-tools input { min-height: 40px; padding: 8px 10px; color: var(--aegis-text, #d9dde5); background: var(--aegis-input, #0d0f11); border: 1px solid var(--aegis-border, #30343a); }
.area-restructure-tools button, .area-restructure-dialog > footer button { align-self: end; min-height: 40px; padding: 9px 14px; color: var(--aegis-text, #d9dde5); background: transparent; border: 1px solid var(--aegis-border, #30343a); cursor: pointer; }
.area-restructure-dialog > footer button.primary { color: #111; background: var(--aegis-amber, #ffa51f); border-color: var(--aegis-amber, #ffa51f); }
.area-restructure-dialog > footer button:disabled { opacity: .38; cursor: not-allowed; }
.area-restructure-grid { display: grid; grid-template-columns: minmax(320px,.8fr) minmax(420px,1.2fr); min-height: 380px; }
.area-restructure-cameras, .area-restructure-tree { padding: 16px 20px; overflow: auto; }
.area-restructure-cameras { border-right: 1px solid var(--aegis-border, #30343a); }
.area-restructure-section-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.area-restructure-cameras > button { width: 100%; display: grid; grid-template-columns: 20px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px; color: var(--aegis-text, #d9dde5); background: transparent; border: 1px solid var(--aegis-border, #30343a); text-align: left; cursor: grab; }
.area-restructure-cameras > button + button { margin-top: 6px; }
.area-restructure-cameras > button.selected { border-color: var(--aegis-amber, #ffa51f); background: color-mix(in srgb, var(--aegis-amber, #ffa51f) 10%, transparent); }
.area-restructure-cameras code, .area-restructure-node code { display: block; margin-top: 3px; color: var(--aegis-muted, #858b96); font-size: 10px; }
.area-restructure-cameras em { color: var(--aegis-muted, #858b96); font-size: 11px; font-style: normal; }
.area-restructure-node { margin-left: calc(var(--area-depth) * 22px); min-height: 44px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--aegis-border, #30343a); }
.area-restructure-node.leaf { border: 1px dashed var(--aegis-amber, #ffa51f); margin-top: 6px; cursor: copy; }
.area-restructure-node.parent { opacity: .64; }
.area-restructure-dialog > footer { border-top: 1px solid var(--aegis-border, #30343a); border-bottom: 0; justify-content: flex-end; }
.area-restructure-dialog > footer > div { margin-right: auto; }
@media (max-width: 900px) { .area-restructure-tools, .area-restructure-grid { grid-template-columns: 1fr; } .area-restructure-cameras { border-right: 0; border-bottom: 1px solid var(--aegis-border, #30343a); } }
/* Redistribution before deleting area/organization trees */
.playback-camera-empty {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px dashed var(--aegis-border);
  color: var(--theme-muted);
  text-align: center;
}

.tree-delete-dialog-backdrop { padding: 24px; }
.tree-delete-dialog { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; width: min(1160px, 96vw); height: min(744px, calc(100vh - 48px)); overflow: hidden; border: 1px solid var(--aegis-border); background: var(--theme-panel, #17191d); color: var(--theme-text, #eef0f4); box-shadow: 0 24px 70px #000b; }
.tree-delete-dialog > header { display: flex; align-items: center; justify-content: space-between; padding: 18px; border-bottom: 1px solid var(--aegis-border); }
.tree-delete-dialog > header span { color: var(--aegis-amber); font: 700 10px var(--aegis-mono); letter-spacing: .18em; }
.tree-delete-dialog > header h2 { margin: 7px 0 0; font-size: 24px; }
.tree-delete-dialog > header button { border: 0; background: transparent; color: inherit; font-size: 24px; cursor: pointer; }
.tree-delete-grid { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.3fr); min-height: 0; overflow: hidden; }
.tree-delete-grid > section { min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 18px; }
.tree-delete-grid > section + section { border-left: 1px solid var(--aegis-border); }
.tree-delete-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.tree-delete-section-head label { color: var(--theme-muted, #9298a2); font-size: 12px; }
.tree-delete-search { position: relative; display: flex; align-items: center; margin-bottom: 12px; }
.tree-delete-search svg { position: absolute; left: 11px; width: 16px; color: var(--theme-muted, #9298a2); pointer-events: none; }
.tree-delete-search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--aegis-border); background: var(--theme-input, #0d0f11); color: inherit; outline: none; }
.tree-delete-search input:focus { border-color: var(--aegis-amber); }
.tree-delete-objects > [data-delete-object] { display: grid; grid-template-columns: 18px 24px minmax(0,1fr) auto; align-items: center; width: 100%; min-height: 52px; margin-bottom: 6px; padding: 0 8px; border: 1px solid var(--aegis-border); background: transparent; color: inherit; text-align: left; cursor: grab; }
.tree-delete-objects > [data-delete-object].selected { border-color: var(--aegis-amber); background: color-mix(in srgb, var(--aegis-amber) 12%, transparent); }
.tree-delete-objects [data-delete-object-checkbox] { width: 14px; height: 14px; accent-color: var(--aegis-amber); cursor: pointer; }
.tree-delete-objects [data-delete-object] span strong,.tree-delete-objects [data-delete-object] span code { display: block; }
.tree-delete-objects [data-delete-object] em { color: var(--theme-muted, #9298a2); font-size: 11px; font-style: normal; }
.tree-delete-tree-head { position: sticky; z-index: 2; top: -18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -18px -18px 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--aegis-border); background: var(--theme-panel, #17191d); }
.tree-delete-tree-head > span { color: var(--theme-muted, #9298a2); font: 10px var(--aegis-mono); text-align: right; }
.tree-delete-target { display: flex; align-items: center; justify-content: space-between; min-height: 54px; margin: 0 0 6px calc(var(--delete-depth) * 22px); padding: 9px 12px; border: 1px dashed var(--aegis-border); }
.tree-delete-target.allowed { border-color: var(--aegis-amber); cursor: copy; }
.tree-delete-target.blocked { opacity: .55; }
.tree-delete-target strong,.tree-delete-target code { display: block; }
.tree-delete-target code { color: var(--theme-muted, #9298a2); font: 10px var(--aegis-mono); }
.tree-delete-target span { font-size: 12px; }
.tree-delete-dialog > footer { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--aegis-border); }
.tree-delete-dialog > footer div strong,.tree-delete-dialog > footer div span { display: block; }
.tree-delete-dialog > footer div span { color: var(--theme-muted, #9298a2); font: 10px var(--aegis-mono); }
.tree-delete-dialog > footer button { min-height: 40px; padding: 0 16px; border: 1px solid var(--aegis-border); background: transparent; color: inherit; }
.tree-delete-dialog > footer button.primary { border-color: var(--aegis-amber); background: var(--aegis-amber); color: #090a0b; }
.tree-delete-dialog > footer button:disabled { opacity: .35; cursor: not-allowed; }
.tree-delete-feedback { min-height: 18px; padding: 0 18px 10px; color: var(--theme-danger, #ff4343); font-size: 12px; }
.tree-delete-empty { color: var(--theme-muted, #9298a2); }
@media (max-width: 800px) { .tree-delete-dialog-backdrop { padding: 8px; } .tree-delete-grid { grid-template-columns: 1fr; max-height: 70vh; overflow: auto; } .tree-delete-grid > section { overflow: visible; } .tree-delete-grid > section + section { border-left: 0; border-top: 1px solid var(--aegis-border); } .tree-delete-dialog > footer { grid-template-columns: 1fr 1fr; } .tree-delete-dialog > footer div { grid-column: 1 / -1; } }
/* System settings */
.system-settings{display:grid;grid-template-columns:230px minmax(0,1fr);gap:20px;align-items:start}
.system-settings__tabs{position:sticky;top:88px;display:grid;border:1px solid var(--aegis-border);background:var(--theme-panel)}
.system-settings__tab{min-height:46px;padding:0 16px;border:0;border-bottom:1px solid var(--aegis-border);background:transparent;color:var(--theme-muted);text-align:left;font:700 11px var(--aegis-mono);letter-spacing:1px;cursor:pointer}
.system-settings__tab:last-child{border-bottom:0}.system-settings__tab[aria-selected="true"]{background:var(--theme-accent);color:var(--theme-on-accent)}
.system-settings__panel{min-width:0;padding:26px}.settings-panel-head{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;margin-bottom:24px}.settings-panel-head h2{margin:7px 0;font-size:21px}.settings-panel-head p{margin:0;max-width:760px;color:var(--theme-muted);line-height:1.6}
.settings-api-badge{display:inline-flex;align-items:center;min-height:25px;padding:0 9px;border:1px solid currentColor;font:700 9px var(--aegis-mono);letter-spacing:1px;white-space:nowrap}.settings-api-badge[data-state="pending"]{color:var(--theme-warning)}.settings-api-badge[data-state="ready"]{color:var(--theme-success)}
.settings-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-bottom:18px}.settings-form-grid label{display:grid;gap:8px;color:var(--theme-text);font-size:12px}.settings-form-grid input,.settings-form-grid select{width:100%;min-height:42px;padding:0 12px;border:1px solid var(--aegis-border);background:var(--theme-input);color:var(--theme-text)}.settings-form-wide{grid-column:1/-1}.settings-check{display:flex!important;grid-template-columns:auto 1fr!important;align-items:center;justify-content:flex-start;gap:9px!important}.settings-check input{width:auto!important;min-height:0!important;accent-color:var(--theme-accent)}
.settings-note{padding:12px 14px;border:1px solid var(--aegis-border);background:var(--theme-panel-2);color:var(--theme-muted);line-height:1.6}.settings-empty{display:grid;gap:7px;place-items:center;min-height:145px;padding:24px;border:1px dashed var(--aegis-border);color:var(--theme-muted);text-align:center}
.settings-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-top:22px}.settings-button{min-height:40px;padding:0 15px;border:1px solid var(--aegis-border);background:var(--theme-panel-2);color:var(--theme-text);font:700 10px var(--aegis-mono);letter-spacing:.8px;cursor:pointer}.settings-button.primary{border-color:var(--theme-accent);background:var(--theme-accent);color:var(--theme-on-accent)}.settings-button:disabled{cursor:not-allowed;background:var(--theme-disabled-bg);color:var(--theme-disabled-text);opacity:.72}.settings-feedback{margin-right:auto;color:var(--theme-muted);font-size:12px}.settings-feedback[data-type="error"]{color:var(--theme-danger)}.settings-feedback[data-type="success"]{color:var(--theme-success)}.settings-feedback[data-type="warning"]{color:var(--theme-warning)}
.settings-audit-table{overflow:auto;border:1px solid var(--aegis-border)}.settings-audit-table table{width:100%;border-collapse:collapse;white-space:nowrap}.settings-audit-table th,.settings-audit-table td{padding:12px;border-bottom:1px solid var(--aegis-border);text-align:left}.settings-audit-table th{color:var(--theme-muted);font:700 9px var(--aegis-mono);letter-spacing:1px}.settings-link{border:0;background:transparent;color:var(--theme-accent);cursor:pointer}
.system-settings .settings-storage-summary{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px;margin-bottom:22px}.system-settings .settings-storage-card{display:grid;gap:10px;padding:16px;border:1px solid var(--aegis-border);background:var(--theme-panel-2)}.system-settings .settings-storage-card>div{display:flex;align-items:center;justify-content:space-between;gap:10px}.system-settings .settings-storage-card>b{font-size:17px}.system-settings .settings-storage-card small{color:var(--theme-muted);line-height:1.5}.system-settings .settings-storage-risk{padding:3px 7px;border:1px solid currentColor;font:700 9px var(--aegis-mono);text-transform:uppercase}.system-settings .settings-storage-risk[data-risk="normal"]{color:var(--theme-success)}.system-settings .settings-storage-risk[data-risk="warning"]{color:var(--theme-warning)}.system-settings .settings-storage-risk[data-risk="critical"]{color:var(--theme-danger)}.system-settings .settings-storage-risk[data-risk="unknown"]{color:var(--theme-muted)}
@media(max-width:900px){.system-settings{grid-template-columns:1fr}.system-settings__tabs{position:static;display:flex;overflow-x:auto}.system-settings__tab{flex:0 0 auto;border-right:1px solid var(--aegis-border);border-bottom:0}.settings-form-grid{grid-template-columns:1fr}}
.playback-bulk-actions { display:flex; align-items:center; justify-content:space-between; gap:18px; margin:10px 0 16px; padding:14px 16px; border:1px solid var(--aegis-border); background:var(--theme-panel); }
.playback-bulk-actions[hidden] { display:none; }
.playback-bulk-actions > div { display:grid; gap:4px; }
.playback-bulk-actions small { color:var(--theme-muted); }
.playback-bulk-actions label { display:flex; align-items:center; gap:8px; margin-left:auto; white-space:nowrap; }
.playback-bulk-actions button { min-height:40px; border:1px solid var(--theme-danger); background:transparent; color:var(--theme-danger); }
.playback-bulk-actions button:not(:disabled) { background:var(--theme-danger); color:#fff; cursor:pointer; }
.playback-bulk-actions button:disabled { opacity:.4; cursor:not-allowed; }
@media (max-width:900px) { .playback-bulk-actions { align-items:stretch; flex-direction:column; } .playback-bulk-actions label { margin-left:0; } }
.event-filter-grid{display:grid;grid-template-columns:repeat(5,minmax(150px,1fr)) auto;gap:12px;align-items:end;padding:14px;margin-bottom:16px}.event-filter-grid label{display:grid;gap:7px}.event-filter-grid input,.event-filter-grid select{min-height:40px}.event-detail-row>td{padding:18px!important;background:var(--panel,#17191c)}.event-pipeline-summary{margin-bottom:14px;color:var(--muted,#98a0ad)}.event-summary-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:10px;margin-bottom:14px}.event-summary-card{display:grid;gap:5px;padding:12px;border:1px solid var(--border,#30343a)}.event-summary-card span{color:var(--accent,#ffa51f)}.event-frame-list{display:grid;gap:8px}.event-frame-result{padding:10px 12px;border:1px solid var(--border,#30343a)}.event-frame-result summary{cursor:pointer}.event-frame-result li{margin:7px 0}.event-severity-critical{color:#ff4545}.event-severity-warning{color:#ffab24}.event-severity-info{color:#00d99a}@media(max-width:1100px){.event-filter-grid{grid-template-columns:repeat(2,minmax(180px,1fr))}}

/* AI segment event feed */
.event-page-heading{align-items:flex-end}.event-page-status{display:grid;gap:5px;text-align:right}.event-page-status small,.event-muted{color:var(--theme-muted,#9298a2)}
.event-status-legend{display:flex;align-items:center;gap:18px;flex-wrap:wrap;margin:14px 0;padding:11px 14px;border:1px solid var(--aegis-border);background:var(--theme-panel);font-size:12px}.event-status-legend span{display:flex;align-items:center;gap:7px}.event-auto-refresh{margin-left:auto;color:var(--theme-muted)}.event-dot{width:8px;height:8px;border-radius:50%}.event-dot-info{background:var(--theme-success,#00d99a)}.event-dot-warning{background:var(--theme-warning,#ffab24)}.event-dot-critical{background:var(--theme-danger,#ff4545)}
.event-filter-grid label{color:var(--theme-muted);font:700 10px var(--aegis-mono);letter-spacing:.8px}.event-filter-grid input,.event-filter-grid select{width:100%;padding:0 11px;border:1px solid var(--aegis-border);background:var(--theme-input);color:var(--theme-text)}.event-filter-submit{min-height:40px}.event-table-wrap{overflow:auto;border:1px solid var(--aegis-border)}.event-table{min-width:1260px}.event-table thead th{position:sticky;top:0;z-index:1;background:var(--theme-panel-2)}.event-table td{vertical-align:top}.event-table code{color:var(--theme-accent)}
.event-description{max-width:430px;margin:5px 0;color:var(--theme-text);font-size:12px;line-height:1.45}.event-error-text{color:var(--theme-danger)}.event-stats{display:block;margin-top:7px;color:var(--theme-muted);font:10px var(--aegis-mono)}.event-severity{display:inline-flex;padding:3px 7px;border:1px solid currentColor;font:700 9px var(--aegis-mono);letter-spacing:.6px;text-transform:uppercase}.event-pipeline-state{display:inline-flex;max-width:150px;line-height:1.35}.event-pipeline-failed{color:var(--theme-danger)}.event-pipeline-processing,.event-pipeline-pending{color:var(--theme-warning)}
.event-detail-panel{display:grid;gap:20px}.event-detail-panel h3{margin:0 0 10px;font-size:14px}.event-pipeline-summary{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0;padding:11px 12px;border-left:3px solid var(--theme-accent);background:var(--theme-panel-2)}.event-pipeline-summary span{padding-left:10px;border-left:1px solid var(--aegis-border);color:var(--theme-muted);font-size:12px}
.event-analysis-windows{padding:14px;border:1px solid var(--aegis-border);background:var(--theme-panel-2)}.event-analysis-windows ol{display:grid;gap:8px;margin:12px 0 0;padding:0;list-style:none}.event-analysis-windows li{display:grid;gap:6px;padding:10px 12px;border-left:2px solid var(--theme-success,#00d99a);background:var(--theme-input)}.event-analysis-windows li>div{display:flex;align-items:center;gap:10px}.event-analysis-windows li p{margin:0;color:var(--theme-text);font-size:12px;line-height:1.5}
.event-summary-card{background:var(--theme-panel-2)}.event-summary-card header{display:flex;align-items:center;justify-content:space-between;gap:10px}.event-summary-card>small{color:var(--theme-muted)}.event-summary-metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:4px}.event-summary-metrics span{display:grid;gap:3px;color:var(--theme-muted);font-size:10px}.event-summary-metrics b{color:var(--theme-text);font-size:12px}
.event-frame-result{padding:0;background:var(--theme-panel-2)}.event-frame-result.is-representative-frame{border-color:var(--theme-accent);box-shadow:inset 3px 0 var(--theme-accent)}.event-frame-result summary{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 14px;font-size:12px}.event-frame-result summary span:last-child{color:var(--theme-muted)}.event-frame-body{display:grid;grid-template-columns:minmax(220px,.75fr) minmax(300px,1.25fr);gap:18px;padding:0 14px 14px;border-top:1px solid var(--aegis-border)}.event-frame-body h4{margin:13px 0 9px;font-size:11px}.event-detection-list{display:flex;gap:7px;flex-wrap:wrap}.event-detection-chip{padding:5px 8px;border:1px solid var(--aegis-border);background:var(--theme-input);font-size:11px}.event-detection-chip b{color:var(--theme-accent)}.event-occurrence-list{display:grid;gap:8px;margin:0;padding:0;list-style:none}.event-occurrence-list li{margin:0;padding:9px 10px;border-left:2px solid var(--aegis-border);background:var(--theme-input)}.event-occurrence-list li.is-representative{border-left-color:var(--theme-accent)}.event-occurrence-list small{color:var(--theme-muted)}.event-job-errors{padding:12px;border:1px solid var(--theme-danger);color:var(--theme-danger)}
@media(max-width:1100px){.event-auto-refresh{margin-left:0}.event-frame-body{grid-template-columns:1fr}.event-summary-metrics{grid-template-columns:1fr}.event-page-heading{align-items:flex-start}.event-page-status{text-align:left}}

/* Semantic severity badges used by the AI event feed. */
.event-severity{align-items:center;justify-content:center;min-height:22px;border-radius:4px;line-height:1;white-space:nowrap;vertical-align:middle}
.event-severity-critical{color:var(--theme-danger,#ff4545);background:rgba(255,69,69,.1)}
.event-severity-warning{color:var(--theme-warning,#ffab24);background:rgba(255,171,36,.1)}
.event-severity-info{color:var(--theme-success,#00d99a);background:rgba(0,217,154,.1)}
.event-table tr[data-simulated="true"] [data-segment-insight]::before {
  content: "VIDEO GIẢ ĐỊNH";
  display: inline-block;
  margin: 0 8px 4px 0;
  padding: 3px 7px;
  border: 1px solid var(--accent, #f5a623);
  color: var(--accent, #f5a623);
  font: 700 10px/1 monospace;
  letter-spacing: .08em;
}
.simulated-video-form { max-width: 900px; display: grid; gap: 22px; padding: 28px; }
.simulated-video-form label { display: grid; gap: 9px; color: var(--theme-muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.simulated-video-form select, .simulated-video-form input[type="file"] { width: 100%; min-height: 46px; padding: 12px; border: 1px solid var(--aegis-border); background: var(--theme-input); color: var(--theme-text); }
.simulated-video-actions { display: flex; justify-content: flex-end; }
.simulated-video-actions .btn-primary { display: inline-flex; align-items: center; gap: 8px; }
.simulated-video-status[data-state="success"] { color: var(--success, #00d99b); }
.simulated-video-status[data-state="error"] { color: var(--danger, #ff424f); }

.aegis-icon-fallback { display: inline-grid; width: 18px; height: 18px; place-items: center; font-size: 17px; line-height: 1; }
.lucide-ready .aegis-icon-fallback { display: none; }

/* Alert operations */
.alert-page { padding-bottom: 48px; }
.alert-page-head { align-items: flex-end; }
.alert-total { color: var(--text-muted, #98a0ad); font-family: var(--font-mono, monospace); }
.alert-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 20px 0 16px; }
.alert-summary-card { position: relative; overflow: hidden; min-height: 92px; padding: 18px 20px; border: 1px solid var(--border, #2b3038); background: var(--panel, #17191d); }
.alert-summary-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: currentColor; }
.alert-summary-card span { display: block; color: var(--text-muted, #9299a5); font-size: 12px; letter-spacing: .13em; text-transform: uppercase; }
.alert-summary-card strong { display: block; margin-top: 8px; color: currentColor; font: 700 28px/1 var(--font-mono, monospace); }
.alert-summary-card.is-open { color: #ff4545; }
.alert-summary-card.is-acknowledged { color: #ffa31a; }
.alert-summary-card.is-closed { color: #00d99b; }
.alert-toolbar { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) auto; gap: 12px; align-items: end; padding: 14px 16px; margin-bottom: 16px; }
.alert-toolbar label span { display: block; margin-bottom: 7px; color: var(--text-muted, #9299a5); font-size: 11px; letter-spacing: .15em; text-transform: uppercase; }
.alert-toolbar select { width: 100%; min-height: 42px; }
.alert-toolbar .btn-sm { min-height: 42px; padding-inline: 20px; }
.alert-table-shell { overflow: hidden; padding: 0; }
.alert-table-scroll { overflow-x: auto; }
.alert-table { width: 100%; min-width: 980px; border-collapse: collapse; table-layout: fixed; }
.alert-table th { padding: 15px 16px; border-bottom: 1px solid var(--border, #292d34); color: var(--text-muted, #9299a5); font-size: 11px; letter-spacing: .16em; text-align: left; text-transform: uppercase; }
.alert-table th:nth-child(1) { width: 175px; }
.alert-table th:nth-child(3) { width: 270px; }
.alert-table th:nth-child(4) { width: 155px; }
.alert-table th:nth-child(5) { width: 190px; text-align: right; }
.alert-table td { padding: 16px; border-bottom: 1px solid var(--border, #292d34); vertical-align: middle; }
.alert-table tbody tr:last-child td { border-bottom: 0; }
.alert-table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.alert-table td:last-child { text-align: right; }
.alert-time { color: var(--text-muted, #a0a7b2); font-family: var(--font-mono, monospace); }
.alert-event-title { display: flex; align-items: center; gap: 10px; }
.alert-table p, .alert-table small { display: block; margin: 5px 0 0; color: var(--text-muted, #9299a5); }
.alert-severity-badge, .alert-status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border: 1px solid currentColor; border-radius: 4px; font: 700 10px/1 var(--font-mono, monospace); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.alert-severity-critical, .alert-status-open { color: #ff4545; background: rgba(255, 69, 69, .1); }
.alert-severity-warning, .alert-status-acknowledged { color: #ffa31a; background: rgba(255, 163, 26, .1); }
.alert-severity-info, .alert-status-closed { color: #00d99b; background: rgba(0, 217, 155, .1); }
.alert-severity-unknown, .alert-status-unknown { color: var(--text-muted, #9299a5); }
.alert-actions { display: flex; justify-content: flex-end; gap: 8px; }
.alert-action { min-height: 34px; padding: 0 11px; border: 1px solid var(--border, #343942); background: transparent; color: var(--text-main, #f2f4f7); cursor: pointer; font: 700 11px/1 var(--font-mono, monospace); text-transform: uppercase; }
.alert-action:hover { border-color: currentColor; }
.alert-action.is-acknowledge { color: #ffa31a; }
.alert-action.is-close, .alert-action-done { color: #00d99b; }
.alert-action:disabled { cursor: wait; opacity: .45; }
.alert-message { padding: 42px 20px; color: var(--text-muted, #9299a5); text-align: center; }
[data-error-state].alert-message { color: #ff6262; }
.aegis-alert-indicator { display: inline-grid; flex: 0 0 20px; width: 20px; height: 20px; margin-left: auto; place-items: center; border: 1px solid #ff4545; border-radius: 50%; background: rgba(255, 69, 69, .16); color: #ff4545; font: 800 12px/1 var(--font-mono, monospace); animation: aegis-alert-shake 1.8s ease-in-out infinite; }
@keyframes aegis-alert-shake { 0%, 72%, 100% { transform: rotate(0); } 76% { transform: rotate(-13deg); } 82% { transform: rotate(12deg); } 88% { transform: rotate(-8deg); } 94% { transform: rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .aegis-alert-indicator { animation: none; } }
@media (max-width: 900px) { .alert-summary { grid-template-columns: 1fr; } .alert-toolbar { grid-template-columns: 1fr; } }
