/* Ismart RedShift admin theme — ported from the SmartCollect design system, re-themed for a
   power/CCMS monitoring product (electric blue + amber accents instead of green/amber). */
:root{
  --bg:#f4f6f8;
  --surface:#ffffff;
  --surface-2:#eef1f5;
  --ink:#141c26;
  --ink-soft:#57677a;
  --line:#dde3ea;
  --brand:#2461a8;
  --brand-dark:#1a4577;
  --brand-soft:#e5eef9;
  --amber:#e0a52e;
  --amber-soft:#fbf1dc;
  --amber-text:#8a5b12;
  --red:#c1463d;
  --red-soft:#fbe7e5;
  --green:#2f8f5b;
  --green-soft:#e3f3ea;
  --radius:14px;
  --shadow: 0 1px 2px rgba(20,28,38,.04), 0 8px 24px -12px rgba(20,28,38,.14);
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"]{
  --bg:#0d1420; --surface:#141d2b; --surface-2:#1a2534; --ink:#eaf0f7; --ink-soft:#9fb0c3;
  --line:#28374a; --brand:#5b9fe0; --brand-dark:#3b7fc4; --brand-soft:#1b3350;
  --amber:#e8b25a; --amber-soft:#3a2f17; --amber-text:#e8b25a; --red:#e2796a; --red-soft:#3b211d;
  --green:#5cbf8b; --green-soft:#1a3527;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -14px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0d1420; --surface:#141d2b; --surface-2:#1a2534; --ink:#eaf0f7; --ink-soft:#9fb0c3;
    --line:#28374a; --brand:#5b9fe0; --brand-dark:#3b7fc4; --brand-soft:#1b3350;
    --amber:#e8b25a; --amber-soft:#3a2f17; --amber-text:#e8b25a; --red:#e2796a; --red-soft:#3b211d;
    --green:#5cbf8b; --green-soft:#1a3527;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 30px -14px rgba(0,0,0,.6);
  }
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg); color:var(--ink); font-family:var(--font-body);
  font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased;
}
::selection{ background:var(--brand); color:#fff; }
a{color:inherit;}
button{font-family:inherit;}
h1,h2,h3,h4{ text-wrap:balance; }
.app{ display:flex; min-height:100vh; }

/* ---------- Sidebar (subnav) ---------- */
.subnav{
  width:230px; flex:none; background:var(--surface); border-right:1px solid var(--line);
  padding:22px 14px; position:sticky; top:0; height:100vh; overflow-y:auto;
}
.subnav-brand{ display:flex; align-items:center; gap:9px; padding:0 8px 16px; text-decoration:none; }
.subnav-brand .badge{
  width:28px; height:28px; display:flex; align-items:center; justify-content:center; flex:none;
  color:var(--amber);
}
.subnav-brand .badge svg{ width:100%; height:100%; display:block; }
.subnav-brand span{ font-weight:700; font-size:15px; letter-spacing:-.01em; }
.subnav-org{ padding:0 8px 16px; margin-bottom:12px; border-bottom:1px solid var(--line); }
.subnav-org .name{ font-family:var(--font-display); font-weight:700; font-size:15px; }
.subnav-org .role{ font-size:11.5px; color:var(--ink-soft); text-transform:uppercase; letter-spacing:.05em; }
.subnav-group{ margin-bottom:16px; }
.subnav-group h4{ font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--ink-soft); margin:0 0 6px; padding:0 8px; font-weight:700;}
.subnav-link{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:9px; font-size:13.5px;
  color:var(--ink-soft); cursor:pointer; font-weight:600; margin-bottom:2px; border:none; background:none;
  width:100%; text-align:left; text-decoration:none;
}
.subnav-link svg{ width:16px; height:16px; flex:none; }
.subnav-link:hover{ background:var(--surface-2); color:var(--ink); }
.subnav-link.active{ background:var(--brand-soft); color:var(--brand); }

/* ---------- Shell ---------- */
.shell{ flex:1; min-width:0; display:flex; flex-direction:column; }
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:18px 32px; border-bottom:1px solid var(--line); background:var(--surface);
  position:sticky; top:0; z-index:5;
}
.topbar-titles{ min-width:0; }
.topbar-actions{ display:flex; align-items:center; gap:10px; flex:none; }
.breadcrumb{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-soft); flex-wrap:wrap; }
.breadcrumb b{ color:var(--ink); font-weight:600; }
.page-title{ font-family:var(--font-display); font-size:22px; font-weight:700; letter-spacing:-.01em; }
.context-pill{
  display:flex; align-items:center; gap:8px; background:var(--surface-2); border:1px solid var(--line);
  border-radius:999px; padding:6px 14px 6px 6px; font-size:12.5px; color:var(--ink-soft); white-space:nowrap;
}
.context-pill .dot{ width:22px;height:22px;border-radius:50%; background:var(--brand-soft); color:var(--brand);
  display:flex;align-items:center;justify-content:center; font-size:11px; font-weight:700; flex:none; }
.main{ flex:1; padding:28px 32px 60px; max-width:1240px; width:100%; margin:0 auto; }

.theme-toggle{
  width:36px;height:36px;border-radius:50%;border:1px solid var(--line);
  background:var(--surface);color:var(--ink);cursor:pointer;display:flex;align-items:center;justify-content:center;
  box-shadow:var(--shadow); flex:none;
}
.theme-toggle svg{width:16px;height:16px;}
.menu-toggle{
  display:none; width:36px; height:36px; border-radius:9px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink); cursor:pointer; align-items:center; justify-content:center;
  flex:none; margin-right:4px;
}
.menu-toggle svg{ width:18px; height:18px; }

/* ---------- Generic building blocks ---------- */
.grid{ display:grid; gap:18px; }
.cols-4{ grid-template-columns:repeat(4,1fr); }
.cols-3{ grid-template-columns:repeat(3,1fr); }
.cols-2{ grid-template-columns:1.3fr .8fr; }
@media (max-width:1000px){ .cols-4{grid-template-columns:repeat(2,1fr);} .cols-3{grid-template-columns:1fr;} .cols-2{grid-template-columns:1fr;} }

.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px;
}
.card-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:14px; gap:10px;}
.card-head h3{ margin:0; font-size:14.5px; font-weight:700; }
.card-head .hint{ font-size:12px; color:var(--ink-soft); white-space:nowrap; }
.eyebrow{ text-transform:uppercase; letter-spacing:.08em; font-size:10.5px; font-weight:700; color:var(--brand); }

.stat{ display:flex; flex-direction:column; gap:6px; }
.stat .num{ font-family:var(--font-display); font-size:30px; font-weight:700; font-variant-numeric:tabular-nums; }
.stat .label{ font-size:12.5px; color:var(--ink-soft); }
.stat .delta{ font-size:12px; font-weight:600; display:inline-flex; align-items:center; gap:4px; }
.delta.up{ color:var(--green); }
.delta.down{ color:var(--red); }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius:10px; border:1px solid var(--line); background:var(--surface);
  color:var(--ink); font-weight:600; font-size:13.5px; padding:10px 16px; cursor:pointer;
  transition:transform .08s ease, background .15s, border-color .15s; text-decoration:none;
}
.btn:hover{ background:var(--surface-2); }
.btn:active{ transform:scale(.98); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .subnav-link:focus-visible{ outline:2px solid var(--amber); outline-offset:2px; }
.btn-primary{ background:var(--brand); border-color:var(--brand); color:#fff; }
.btn-primary:hover{ background:var(--brand-dark); }
.btn-amber{ background:var(--amber); border-color:var(--amber); color:#3a2a08; }
.btn-ghost{ border-color:transparent; background:transparent; }
.btn-danger{ background:var(--red-soft); border-color:var(--red-soft); color:var(--red); }
.btn-block{ width:100%; }
.btn-sm{ padding:6px 12px; font-size:12.5px; border-radius:8px; }
.btn-lg{ padding:14px 20px; font-size:15px; border-radius:12px; }
.btn[disabled]{ opacity:.45; cursor:not-allowed; }

.pill{ display:inline-flex; align-items:center; gap:6px; font-size:11.5px; font-weight:700; padding:4px 10px; border-radius:999px; letter-spacing:.01em; white-space:nowrap;}
.pill-green{ background:var(--green-soft); color:var(--green); }
.pill-amber{ background:var(--amber-soft); color:var(--amber-text); }
.pill-red{ background:var(--red-soft); color:var(--red); }
.pill-blue{ background:var(--brand-soft); color:var(--brand); }

table{ width:100%; border-collapse:collapse; font-size:13.5px; }
th{ text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-soft); font-weight:700; padding:8px 10px; border-bottom:1px solid var(--line); white-space:nowrap;}
td{ padding:11px 10px; border-bottom:1px solid var(--line); vertical-align:middle; }
tr:last-child td{ border-bottom:none; }
tbody tr:hover td{ background:var(--surface-2); }
.table-wrap{ overflow-x:auto; }
.num-cell{ font-variant-numeric:tabular-nums; text-align:right; }

.field{ display:flex; flex-direction:column; gap:6px; }
.field label{ font-size:12.5px; font-weight:600; color:var(--ink-soft); }
.field input, .field select, .field textarea{
  border:1px solid var(--line); border-radius:9px; padding:10px 12px; font-size:14px;
  background:var(--surface); color:var(--ink); font-family:inherit; width:100%;
}
.field input:focus, .field select:focus, .field textarea:focus{ outline:2px solid var(--brand); outline-offset:-1px; }
.field-row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
@media (max-width:640px){ .field-row{ grid-template-columns:1fr; } }
.field-hint{ font-size:11.5px; color:var(--ink-soft); }
.field-error{ font-size:11.5px; color:var(--red); font-weight:600; }

/* ---------- Segmented control (e.g. dashboard time-window switcher) ---------- */
.segmented{
  display:inline-flex; align-items:center; gap:2px; padding:3px; background:var(--surface-2);
  border:1px solid var(--line); border-radius:10px;
}
.segmented-item{
  display:inline-flex; align-items:center; justify-content:center; min-width:44px; padding:6px 12px;
  border-radius:7px; font-size:12.5px; font-weight:700; letter-spacing:.02em; color:var(--ink-soft);
  text-decoration:none; transition:background .12s ease, color .12s ease;
}
.segmented-item:hover{ color:var(--ink); }
.segmented-item.active{ background:var(--surface); color:var(--brand); box-shadow:var(--shadow); }

.section-title{ font-family:var(--font-display); font-size:19px; font-weight:700; margin:0 0 4px; letter-spacing:-.01em; }
.section-sub{ color:var(--ink-soft); font-size:13.5px; margin:0 0 18px; max-width:62ch; }

.divider{ height:1px; background:var(--line); margin:18px 0; border:none; }

.list-item{ display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--line); border-radius:12px; padding:10px 12px; }
.list-item.clickable{ cursor:pointer; }
.list-item.clickable:hover{ border-color:var(--brand); }
.avatar{ width:36px; height:36px; border-radius:9px; background:var(--brand-soft); color:var(--brand); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; flex:none; }
.list-item .meta{ flex:1; min-width:0; }
.list-item .meta .name{ font-size:13.5px; font-weight:600; }
.list-item .meta .sub{ font-size:11.5px; color:var(--ink-soft); }

.tabs{ display:flex; gap:6px; border-bottom:1px solid var(--line); margin-bottom:18px; flex-wrap:wrap; }
.tab-btn{ border:none; background:none; padding:10px 14px; font-size:13px; font-weight:600; color:var(--ink-soft); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; }
.tab-btn:hover{ color:var(--ink); }
.tab-btn.active{ color:var(--brand); border-bottom-color:var(--brand); }
.tab-panel{ display:none; }
.tab-panel.active{ display:block; }

.kv{ display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--line); font-size:13.5px; gap:12px;}
.kv:last-child{ border-bottom:none; }
.kv span:first-child{ color:var(--ink-soft); }
.kv span:last-child{ text-align:right; font-weight:600; }

.empty-state{ text-align:center; padding:36px 20px; color:var(--ink-soft); border:1px dashed var(--line); border-radius:12px; }

.alert{ border-radius:12px; padding:12px 16px; font-size:13.5px; margin-bottom:16px; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.alert-success{ background:var(--green-soft); color:var(--green); }
.alert-danger{ background:var(--red-soft); color:var(--red); }
.alert-warning{ background:var(--amber-soft); color:var(--amber-text); }
.alert ul{ margin:0; padding-left:18px; }
.alert-close{ background:none; border:none; color:inherit; cursor:pointer; font-size:14px; line-height:1; flex:none; opacity:.7; }
.alert-close:hover{ opacity:1; }

.badge-credential{ display:inline-flex; align-items:center; gap:6px; }
.credential-card{ border:1px solid var(--line); border-radius:12px; padding:14px; margin-bottom:10px; }
.credential-card .row{ display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.credential-actions{ display:flex; gap:6px; flex:none; }

/* ---------- Filter bar ---------- */
.filter-bar{ display:flex; gap:14px; flex-wrap:wrap; align-items:flex-end; }
.filter-bar .field{ width:200px; }
.filter-bar .field.grow{ width:260px; }
@media (max-width:640px){ .filter-bar .field, .filter-bar .field.grow{ width:100%; } }

/* ---------- Sortable table headers ---------- */
th.sortable a{ display:inline-flex; align-items:center; gap:4px; color:inherit; text-decoration:none; }
th.sortable a:hover{ color:var(--ink); }
th.sortable .sort-arrow{ font-size:10px; opacity:.5; }
th.sortable.active .sort-arrow{ opacity:1; color:var(--brand); }

/* ---------- Row actions kebab menu ---------- */
.kebab-menu{ position:relative; display:inline-block; }
.kebab-btn{
  width:30px; height:30px; border-radius:8px; border:1px solid transparent; background:none;
  color:var(--ink-soft); cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.kebab-btn:hover{ background:var(--surface-2); color:var(--ink); }
.kebab-panel{
  display:none; position:absolute; top:calc(100% + 4px); right:0; min-width:180px; z-index:20;
  background:var(--surface); border:1px solid var(--line); border-radius:10px; box-shadow:var(--shadow);
  padding:6px;
}
.kebab-panel.open{ display:block; }
.kebab-item{
  display:flex; align-items:center; gap:8px; width:100%; text-align:left; border:none; background:none;
  padding:8px 10px; border-radius:7px; font-size:13px; font-weight:600; color:var(--ink); cursor:pointer;
}
.kebab-item:hover{ background:var(--surface-2); }
.kebab-item.danger{ color:var(--red); }
.kebab-item svg{ width:14px; height:14px; flex:none; }

/* ---------- JSON disclosure ---------- */
.json-toggle{ font-size:12px; font-weight:600; color:var(--brand); background:none; border:none; cursor:pointer; padding:0; }
.json-toggle:hover{ text-decoration:underline; }
.json-view{
  display:none; margin-top:8px; background:var(--surface-2); border:1px solid var(--line); border-radius:8px;
  padding:10px 12px; font-family:SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size:11.5px;
  white-space:pre-wrap; word-break:break-word; max-height:320px; overflow:auto;
}
.json-view.open{ display:block; }

/* ---------- JSON modal ---------- */
.json-icon-btn{
  width:28px; height:28px; border-radius:7px; border:1px solid var(--line); background:var(--surface);
  color:var(--ink-soft); cursor:pointer; display:inline-flex; align-items:center; justify-content:center;
}
.json-icon-btn:hover{ background:var(--surface-2); color:var(--brand); border-color:var(--brand); }
.json-icon-btn svg{ width:15px; height:15px; }
.modal-backdrop{
  display:none; position:fixed; inset:0; z-index:100; background:rgba(0,0,0,.45);
  align-items:center; justify-content:center; padding:24px;
}
.modal-backdrop.open{ display:flex; }
.modal-box{
  background:var(--surface); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow);
  width:100%; max-width:640px; max-height:80vh; display:flex; flex-direction:column;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding:14px 18px;
  border-bottom:1px solid var(--line);
}
.modal-head h4{ margin:0; font-size:14px; }
.modal-close{
  width:28px; height:28px; border-radius:7px; border:none; background:none; color:var(--ink-soft);
  cursor:pointer; font-size:18px; line-height:1; display:flex; align-items:center; justify-content:center;
}
.modal-close:hover{ background:var(--surface-2); color:var(--ink); }
.modal-body{ padding:16px 18px; overflow:auto; }
.modal-body pre{
  margin:0; font-family:SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size:12px;
  white-space:pre-wrap; word-break:break-word;
}

/* ---------- Reading detail grid ---------- */
.reading-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
@media (max-width:900px){ .reading-grid{ grid-template-columns:repeat(2,1fr); } }
@media (max-width:480px){ .reading-grid{ grid-template-columns:1fr; } }
.reading-field{ background:var(--surface-2); border-radius:10px; padding:12px 14px; }
.reading-field .label{ font-size:11px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-soft); margin-bottom:4px; }
.reading-field .value{ font-size:17px; font-weight:700; font-variant-numeric:tabular-nums; }
.reading-field .value.muted{ color:var(--ink-soft); font-size:14px; font-weight:600; }

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-thumb{ background:var(--line); border-radius:6px; }

/* ---------- Mobile ---------- */
@media (max-width:900px){
  html{ -webkit-text-size-adjust:100%; }
  body{ overflow-x:hidden; }
  .app{ flex-direction:column; }
  .menu-toggle{ display:inline-flex; }
  .subnav{
    position:fixed; top:0; left:0; height:100vh; width:min(280px,82vw);
    transform:translateX(-100%); transition:transform .25s ease; z-index:50;
    box-shadow:0 20px 50px -12px rgba(0,0,0,.35);
  }
  .subnav.open{ transform:translateX(0); }
  .nav-backdrop{ display:none; position:fixed; inset:0; background:rgba(10,17,26,.45); z-index:45; }
  .nav-backdrop.open{ display:block; }
  .topbar{ padding:12px 16px; gap:10px; }
  .topbar-titles{ flex:1; min-width:0; }
  .page-title{ font-size:18px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .breadcrumb{ display:none; }
  .context-pill{ max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .main{ padding:18px 14px 40px; }
  .card{ padding:16px; }
  .field input, .field select, .field textarea{ font-size:16px; }
}
@media (max-width:480px){
  .cols-4, .cols-3{ grid-template-columns:1fr; }
}

/* ---------- Login page ---------- */
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card{ max-width:380px; width:100%; }
.login-brand{ text-align:center; margin-bottom:20px; }
.login-brand .badge{ width:44px; height:44px; margin:0 auto 10px; color:var(--amber); }
.login-brand .badge svg{ width:100%; height:100%; display:block; }
.login-brand h1{ font-size:19px; margin:6px 0 2px; }
.login-brand p{ color:var(--ink-soft); font-size:13px; margin:0; }
.checkbox-row{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-soft); }
.checkbox-row input{ width:auto; }
