/* ================= tokens ================= */
:root {
  --ink: #10233f;
  --ink-2: #2b3a52;
  --muted: #5f6b7d;
  --line: rgba(29, 90, 166, .12);
  --primary: #1d5aa6;
  --primary-dark: #174b8c;
  --primary-soft: #e8f1fb;
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-border: rgba(255, 255, 255, .85);
  --green: #16a34a;  --green-soft: #dcf7e6;
  --blue: #2a78d6;   --blue-soft: #e0edff;
  --amber: #d98a00;  --amber-soft: #fff1d6;
  --red: #d03b3b;    --red-soft: #fde4e4;
  --violet: #7c3aed; --violet-soft: #f0e8ff;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(18, 61, 115, .13);
  --shadow-sm: 0 6px 20px rgba(18, 61, 115, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 "Segoe UI", "Inter", system-ui, -apple-system, Arial, sans-serif; color: var(--ink);
  background: linear-gradient(135deg, #e6e3ff 0%, #f1f5fa 35%, #f1f5fa 65%, #e3e9ff 100%) fixed;
}
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.backdrop i:nth-child(1) { width: 520px; height: 520px; background: #c7bfff; top: -160px; left: -120px; }
.backdrop i:nth-child(2) { width: 460px; height: 460px; background: #bfd5ff; bottom: -160px; right: -80px; }
.backdrop i:nth-child(3) { width: 340px; height: 340px; background: #f3d1ff; top: 30%; left: 45%; opacity: .35; }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h2 { font-size: 16px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
code { background: var(--primary-soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.faint { color: #a9b4c4; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.sub { color: var(--muted); margin: 6px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.center { text-align: center !important; }
.req { color: var(--red); }
small { font-size: 12px; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ================= layout ================= */
.app { display: flex; gap: 18px; padding: 18px; min-height: 100vh; }
.rail {
  width: 76px; flex: none; border-radius: 26px; padding: 16px 0;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  position: sticky; top: 18px; height: calc(100vh - 36px); z-index: 30;   /* above the panel so tooltips are not cut */
  transition: width .2s ease;
}
.rail-head { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.rail nav { display: flex; flex-direction: column; gap: 8px; align-items: center; overflow-y: auto; padding: 2px 0; flex: 1; width: 100%; scrollbar-width: none; }
.rail a {
  width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #4a5b75; position: relative; transition: background .15s, color .15s; flex: none; font-weight: 550;
}
.rail a .icon { width: 21px; height: 21px; }
.rail a:hover { background: rgba(255, 255, 255, .8); color: var(--primary); text-decoration: none; }
.rail a.on { background: linear-gradient(135deg, #e8f1fb, #d5e5f6); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(29, 90, 166, .15), var(--shadow-sm); }
.rail a.sub { height: 38px; }
.rail a.sub .icon { width: 17px; height: 17px; }
.rail .lbl { display: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* tooltip for the collapsed rail: one floating label positioned by script, so the menu can scroll */
.rail-tip {
  position: fixed; z-index: 100; transform: translateY(-50%); white-space: nowrap; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-sm);
}
.rail nav { overflow-y: auto; overflow-x: hidden; min-height: 0; }
.rail-bottom { flex: none; }
/* collapsible groups: parent link + chevron, sub-links hidden until opened */
.nav-group { display: flex; flex-direction: column; align-items: center; width: 100%; }
.nav-row { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; }
.sub-toggle {
  position: absolute; right: 4px; bottom: -2px; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #a3a0c8; display: grid; place-items: center; cursor: pointer; z-index: 1;
  transition: background .15s, color .15s, opacity .15s;
}
.sub-toggle:hover { color: var(--primary); background: rgba(29, 90, 166, .1); }
.sub-toggle .icon { width: 12px; height: 12px; stroke-width: 2.4; transition: transform .25s ease; }
.nav-group.is-open .sub-toggle .icon { transform: rotate(90deg); }
/* smooth open / close: rows animate from 0fr to 1fr */
.subs { display: grid; grid-template-rows: 0fr; width: 100%; transition: grid-template-rows .25s ease, opacity .2s, visibility .25s; opacity: 0; visibility: hidden; }
.nav-group.is-open .subs { grid-template-rows: 1fr; opacity: 1; visibility: visible; }
.subs-in { min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-group.is-open .subs-in { padding-top: 6px; }
.rail a.sub { height: 36px; }
/* collapsed rail: open sub-items sit in a soft tray under their parent */
.nav-group.is-open .subs-in { margin: 0 auto; width: 54px; padding-bottom: 4px; border-radius: 16px; background: rgba(29, 90, 166, .06); }
.nav-group.is-open .subs-in a.sub { width: 42px; }
.rail-logo:hover { background: none !important; }
.rail-toggle {
  width: 30px; height: 30px; border-radius: 10px; border: 1px solid rgba(29, 90, 166, .16); background: rgba(255, 255, 255, .8);
  color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: transform .2s, color .15s;
}
.rail-toggle:hover { color: var(--primary); border-color: var(--primary); }
.rail-toggle .icon { width: 16px; height: 16px; }
.rail-bottom { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 100%; }
.rail .me { padding: 0; }
.rail .me .lbl b { display: block; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.rail .me .lbl small { display: block; color: var(--muted); font-weight: 500; }
.logo-mark { display: grid; grid-template-columns: 9px 9px; gap: 3px; flex: none; }
.logo-mark i { width: 9px; height: 9px; border-radius: 3px; background: var(--primary); }
.logo-mark i:nth-child(2) { background: #ec4899; }
.logo-mark i:nth-child(3) { background: #22c3ee; }
.logo-mark i:nth-child(4) { background: #22c55e; }
.logo-mark.big { grid-template-columns: 14px 14px; gap: 4px; margin: 0 auto 6px; }
.logo-mark.big i { width: 14px; height: 14px; border-radius: 4px; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--ink); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #1d5aa6, #22c3ee); color: #fff; font-weight: 700; font-size: 15px;
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }

/* expanded sidebar */
.rail-open .rail { width: 236px; padding: 16px 14px; align-items: stretch; }
.rail-open .rail-head { flex-direction: row; justify-content: space-between; }
.rail-open .rail-toggle { transform: rotate(180deg); }
.rail-open .rail a { width: 100%; justify-content: flex-start; padding: 0 13px; }
.rail-open .rail a.sub { padding-left: 30px; font-size: 13px; }
.rail-open .rail .rail-logo { width: auto; padding: 0 8px; }
.rail-open .rail .me { height: 52px; padding: 0 6px; }
.rail-open .rail .lbl { display: block; min-width: 0; }
.rail-open .nav-row a { padding-right: 40px; }
.rail-open .sub-toggle { right: 8px; bottom: auto; top: 50%; margin-top: -14px; width: 28px; height: 28px; }
.rail-open .sub-toggle .icon { width: 15px; height: 15px; }
/* expanded: sub-items hang from a thin guide line under the parent icon */
.rail-open .nav-group.is-open .subs-in { width: auto; margin: 2px 0 0 23px; padding: 2px 0 2px 10px; background: none; border-radius: 0;
                                         border-left: 1.5px solid rgba(29, 90, 166, .16); align-items: stretch; gap: 2px; }
.rail-open .rail .subs-in a.sub { width: 100%; height: 34px; padding: 0 10px; gap: 10px; font-size: 13px; border-radius: 10px; }
.rail-open .rail .subs-in a.sub .icon { width: 16px; height: 16px; }
.rail-open .rail .subs-in a.sub.on { background: rgba(29, 90, 166, .1); box-shadow: none; }
.rail-open .rail .subs-in a.sub.on::before { content: ""; position: absolute; left: -11.5px; top: 9px; bottom: 9px; width: 2px;
                                             border-radius: 2px; background: var(--primary); }

.panel { flex: 1; min-width: 0; border-radius: 30px; padding: 30px 34px 40px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.header-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-tools form { margin: 0; }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 14px; color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 40px; min-width: 280px; height: 42px; border-radius: 14px; }
.search.wide { flex: 1; }
.search.wide input { min-width: 0; width: 100%; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 14px; font-weight: 500; }

/* ================= controls ================= */
input, select, textarea {
  font: inherit; color: var(--ink); width: 100%; padding: 9px 12px; min-height: 40px;
  border: 1px solid rgba(29, 90, 166, .16); border-radius: 12px; background: rgba(255, 255, 255, .85);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 90, 166, .15); }
input::placeholder, textarea::placeholder { color: #94a0b2; }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; min-height: 0; accent-color: var(--primary); padding: 0; }
input.order { width: 72px; text-align: right; min-height: 34px; padding: 5px 8px; }
textarea { resize: vertical; }
select { cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: rgba(255, 255, 255, .5); color: var(--ink-2); }

.btn {
  font: inherit; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; min-height: 40px; border-radius: 13px; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  background: linear-gradient(135deg, #1d5aa6, #1f7f8c); color: #fff; box-shadow: 0 6px 16px rgba(29, 90, 166, .28);
}
.btn:hover { background: linear-gradient(135deg, #174b8c, #1a6c78); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn.ghost { background: rgba(255, 255, 255, .85); color: var(--primary-dark); border-color: rgba(29, 90, 166, .16); box-shadow: none; font-weight: 550; }
.btn.ghost:hover { background: #fff; border-color: var(--primary); }
.btn.danger { background: rgba(255, 255, 255, .85); color: var(--red); border-color: #f3c4c4; box-shadow: none; }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.danger-text { color: var(--red); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; min-height: 46px; }
.upload { display: flex; gap: 8px; }
.file-btn { position: relative; max-width: 240px; overflow: hidden; }
.file-btn span { overflow: hidden; text-overflow: ellipsis; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.inline-filter select { min-width: 190px; height: 42px; border-radius: 14px; }

.flash { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; margin-bottom: 18px; font-weight: 500; }
.flash.ok { background: var(--green-soft); color: #166534; }
.flash.error { background: var(--red-soft); color: #991b1b; }

/* ================= cards & grids ================= */
.card {
  background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px 22px; margin-bottom: 20px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 13px; }
.chev { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.chev:hover { background: var(--primary-soft); color: var(--primary); }
.link { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 13px; }
.link .icon { width: 15px; height: 15px; }
.empty { color: var(--muted); text-align: center; padding: 26px 8px; margin: 0; }
.empty.ok { color: var(--green); font-weight: 500; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.row-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.narrow { max-width: 760px; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > label, .login label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
label.check { flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: 500 !important; cursor: pointer; }
.help { color: var(--muted); margin: -6px 0 12px; }
.sub-head { margin: 22px 0 12px; font-size: 15px; }

/* ================= dashboard ================= */
.kpis { display: grid; grid-template-columns: 1.15fr repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.kpi {
  background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px 22px; display: flex; flex-direction: column; gap: 2px; color: var(--ink);
}
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow); }
.kpi.total { flex-direction: row; align-items: center; gap: 18px; }
.kpi strong { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.kpi span { color: var(--muted); font-weight: 500; }
.kpi-top { height: 22px; }
.kpi-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex: none;
            background: linear-gradient(135deg, #e8f1fb, #dcd5ff); color: var(--primary); }
.kpi-icon .icon { width: 26px; height: 26px; }
.dot-lg { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }
.dot-lg.green { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.dot-lg.blue { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.dot-lg.amber { background: #eda100; box-shadow: 0 0 0 4px var(--amber-soft); }
.meter { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.meter b { font-size: 12.5px; color: var(--ink-2); min-width: 34px; text-align: right; }
.meter-track { flex: 1; height: 6px; border-radius: 3px; background: rgba(29, 90, 166, .1); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; }
.meter-fill.green { background: var(--green); }
.meter-fill.blue { background: var(--blue); }
.meter-fill.amber { background: #eda100; }
.meter-fill.grey { background: #8c8aa8; }
.dot-lg.grey { background: #8c8aa8; box-shadow: 0 0 0 4px #edf1f6; }
a.kpi { color: inherit; text-decoration: none; transition: transform .15s; }
a.kpi:hover { transform: translateY(-2px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .kpi-note { font-size: 11.5px; color: var(--muted); }
.live-note { margin: -8px 4px 20px; }

/* Live state from the heartbeat */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.live svg { width: 14px; height: 14px; }
.live small { font-weight: 500; color: var(--muted); }
.live-unlocked { color: #166534; }
.live-locked, .live-signed-out { color: #8a5a00; }
.live-shutdown, .live-offline, .live-sleep, .live-restart { color: var(--muted); }


.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut { width: 150px; height: 150px; flex: none; }
.donut .seg { transition: stroke-width .15s; cursor: default; }
.donut .seg:hover { stroke-width: 7; }
.donut-num { font-size: 7px; font-weight: 700; text-anchor: middle; fill: var(--ink); }
.donut-label { font-size: 3.4px; text-anchor: middle; fill: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.legend li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend span { flex: 1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 600; font-variant-numeric: tabular-nums; }

.sw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sw-list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sw-list li:last-child { border-bottom: 0; }
.sw-list li > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sw-list b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-list span { color: var(--muted); font-size: 12.5px; }
.sw-badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.sw-1 { background: linear-gradient(135deg, #f25022, #ffb900); }
.sw-2 { background: linear-gradient(135deg, #4285f4, #34a853); }
.sw-3 { background: linear-gradient(135deg, #24292f, #57606a); }
.sw-4 { background: linear-gradient(135deg, #7c3aed, #c084fc); }
.sw-5 { background: linear-gradient(135deg, #0ea5e9, #22d3ee); }

.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.mini-stats a { background: rgba(29, 90, 166, .06); border-radius: 14px; padding: 12px 14px; color: var(--ink); display: flex; flex-direction: column; }
.mini-stats a:hover { background: var(--primary-soft); text-decoration: none; }
.mini-stats b { font-size: 22px; }
.mini-stats span { color: var(--muted); font-size: 12.5px; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.bars li { display: grid; grid-template-columns: minmax(100px, 40%) 1fr 64px; align-items: center; gap: 12px; }
.bar-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 9px; background: rgba(29, 90, 166, .08); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #1d5aa6, var(--primary)); border-radius: 0 4px 4px 0; }
.bars li:hover .bar-fill { background: var(--primary-dark); }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-value small { color: var(--muted); font-weight: 400; }

.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.alerts li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: rgba(29, 90, 166, .05); }
.alerts li > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.alerts li > div span { color: var(--muted); font-size: 13px; }
.alert-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.alerts .critical .alert-icon { background: var(--red-soft); color: var(--red); }
.alerts .warning .alert-icon { background: var(--amber-soft); color: var(--amber); }
.level { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.critical .level { background: var(--red-soft); color: #a52020; }
.warning .level { background: var(--amber-soft); color: #8a5300; }
.more { margin: 10px 0 0; text-align: right; }

/* ================= tables ================= */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.filters select { width: auto; min-width: 150px; }
.filters input[type=date] { width: auto; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: rgba(29, 90, 166, .04);
}
.table thead tr th:first-child { border-radius: 12px 0 0 12px; }
.table thead tr th:last-child { border-radius: 0 12px 12px 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.compact td { padding: 9px 12px; }
.table.compact th { padding: 8px 12px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: rgba(29, 90, 166, .05); }
.table tr.stale td { background: rgba(208, 59, 59, .05); }
.table tr.hidden-row td { opacity: .55; }
.table td a { color: var(--ink); font-weight: 600; }
.table td.actions { display: flex; gap: 6px; justify-content: flex-end; }
.table td.actions form { margin: 0; }
.table .icon-col { width: 50px; }
.fields-table td { white-space: normal; }
.table td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.fields-table td:nth-child(2) { min-width: 180px; }
.cell-main { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }
.cell-sub.wrap { white-space: normal; max-width: 320px; }
.device-cell { display: flex; align-items: center; gap: 12px; }

.device { width: 38px; height: 38px; border-radius: 12px; display: inline-grid; place-items: center; flex: none;
          background: linear-gradient(135deg, #f1f5fa, #e1e4ff); color: #4b4fc7; }
.device .icon { width: 20px; height: 20px; }
.device.lg { width: 60px; height: 60px; border-radius: 18px; }
.device.lg .icon { width: 30px; height: 30px; }
.device.d-laptop { background: linear-gradient(135deg, #eaf6e2, #d6efd9); color: #2b8a4e; }
.device.d-desktop, .device.d-workstation { background: linear-gradient(135deg, #e0edff, #cfe0ff); color: #1f63c2; }
.device.d-all-in-one { background: linear-gradient(135deg, #dcf7ef, #c9efe3); color: #0f8a62; }
.device.d-server { background: linear-gradient(135deg, #fff0dc, #ffe3bd); color: #a35f00; }
.device.d-virtual-machine { background: linear-gradient(135deg, #fde7f1, #fbd3e5); color: #b02a68; }
.device.d-tablet { background: linear-gradient(135deg, #e6f7fb, #cdeef7); color: #0b7a94; }
.device.d-mobile-phone { background: linear-gradient(135deg, #eef7e2, #ddefc6); color: #4d7c0f; }
.device.d-unknown { background: #f1f4f8; color: #8d8bab; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; vertical-align: middle; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.off { background: #b4bdcb; }
.dot.stale { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: #b4bdcb; }
.pill.l-in-use i, .pill.s-ok i { background: var(--green); }
.pill.l-in-stock i, .pill.s-spare i { background: var(--blue); }
.pill.l-in-repair i, .pill.s-in-repair i { background: #eda100; }
.pill.l-retired i, .pill.s-scrapped i, .pill.s-not-ok i { background: var(--red); }
h1 .pill { font-size: 13px; padding: 4px 10px; background: var(--glass-strong); border-radius: 20px; }

.tagpill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 8px; background: rgba(29, 90, 166, .08); color: var(--ink-2); }
.tagpill.w-active { background: var(--green-soft); color: #166534; }
.tagpill.w-expiring-soon { background: var(--amber-soft); color: #8a5300; }
.tagpill.w-expired { background: var(--red-soft); color: #a52020; }
.tagpill.role { background: var(--primary-soft); color: var(--primary-dark); }

.count { display: inline-block; min-width: 24px; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; text-align: center; background: var(--primary-soft); color: var(--primary-dark); }
.count.warn { background: var(--amber-soft); color: #8a5300; }
.count.ok { background: var(--green-soft); color: #166534; }

.legend-line { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.legend-line > span { display: inline-flex; align-items: center; gap: 6px; }

/* history / audit */
.who { font-weight: 600; }
.who.agent { color: #0f8a62; }
.act { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 8px; background: rgba(29, 90, 166, .08); color: var(--ink-2); }
.act.a-create, .act.a-import-create { background: var(--green-soft); color: #166534; }
.act.a-update, .act.a-import-update { background: var(--blue-soft); color: #1d4f9a; }
.act.a-agent-update { background: #dcf7ef; color: #0f6e4f; }
.act.a-delete, .act.a-login-failed { background: var(--red-soft); color: #a52020; }
.act.a-export { background: var(--violet-soft); color: #5b21b6; }
.history td.old span { background: #fdecec; color: #8f1d1d; padding: 2px 7px; border-radius: 6px; text-decoration: line-through; text-decoration-color: rgba(143, 29, 29, .4); white-space: pre-wrap; }
.history td.new span { background: #e3f8ea; color: #14532d; padding: 2px 7px; border-radius: 6px; white-space: pre-wrap; }
.history td.old, .history td.new { white-space: normal; max-width: 320px; overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.pager-pages { display: flex; gap: 4px; }
.pager-pages a, .pager-pages span { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 600; color: var(--ink-2); background: rgba(29, 90, 166, .06); font-variant-numeric: tabular-nums; }
.pager-pages a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.pager-pages .on { background: var(--primary); color: #fff; }
.pager-pages .off { opacity: .4; }
.pager-pages .gap { background: none; }
.pager-size { display: flex; align-items: center; gap: 8px; }
.pager-size select { width: auto; min-height: 34px; padding: 4px 28px 4px 10px; }

/* ================= tabs ================= */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding: 5px; border-radius: 16px; background: rgba(255, 255, 255, .55); border: 1px solid var(--glass-border); width: fit-content; max-width: 100%; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 12px; border: 0; background: none;
  font: inherit; font-weight: 550; color: var(--muted); cursor: pointer;
}
.tabs a:hover, .tabs button:hover { color: var(--primary); text-decoration: none; }
.tabs .on { background: #fff; color: var(--primary-dark); box-shadow: var(--shadow-sm); }
.tabs .icon { width: 16px; height: 16px; }

/* ================= asset detail ================= */
.hero { display: flex; flex-direction: column; gap: 20px; }
.hero-main { display: flex; gap: 18px; align-items: center; }
.hero h1 { font-size: 26px; }
.facts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0; }
.facts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.facts div { background: rgba(29, 90, 166, .05); border-radius: 14px; padding: 11px 14px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.facts dd { margin: 3px 0 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field.missing > label > span:first-child::after { content: " •"; color: var(--amber); }
.field.missing input, .field.missing select, .field.missing textarea { border-color: #f2d49a; background: #fffcf4; }
.detected { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 6px; font-weight: 700; letter-spacing: .03em; flex: none; }
.tag.auto { background: var(--green-soft); color: #166534; }
.tag.both { background: var(--amber-soft); color: #8a5300; }
.tag.manual { background: var(--violet-soft); color: #5b21b6; }

.save-bar {
  position: sticky; bottom: 14px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
  border-radius: 16px; box-shadow: 0 10px 30px rgba(16, 35, 63, .14); padding: 10px 12px 10px 20px; margin-bottom: 20px;
}
.danger-zone { display: flex; justify-content: flex-end; margin-top: 4px; }
pre { overflow: auto; max-height: 480px; font-size: 12px; background: rgba(29, 90, 166, .05); border-radius: 12px; padding: 14px; margin: 0; }

/* ================= modules / reports / admin ================= */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.tile { display: flex; flex-direction: column; gap: 14px; color: var(--ink); margin: 0; }
a.tile:hover { text-decoration: none; box-shadow: var(--shadow); }
.tile p { margin: 4px 0 0; }
.tile strong { font-size: 26px; }
.tile strong small { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile-actions { display: flex; gap: 8px; margin-top: auto; }
.empty-state { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 46px 24px; }
.empty-state p { max-width: 560px; margin: 0; }

.module-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 12px; background: rgba(255, 255, 255, .7); border: 1px solid var(--glass-border); color: var(--ink-2); font-weight: 550; }
.chip:hover { text-decoration: none; color: var(--primary); }
.chip.on { background: var(--primary); color: #fff; }
.chip.add { border-style: dashed; border-color: rgba(29, 90, 166, .35); color: var(--primary); }
.chip .icon { width: 16px; height: 16px; }

.module-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.module-rows details { border-radius: 14px; background: rgba(29, 90, 166, .04); }
.module-rows summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.module-rows summary::-webkit-details-marker { display: none; }
.module-rows summary > div { flex: 1; min-width: 0; }
.inline-edit { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 4px 14px 14px; }
.inline-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.inline-edit .grow { flex: 1; min-width: 200px; }
.danger-line { border-top: 1px dashed #f3c4c4; padding-top: 12px; }
.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-picker label { cursor: pointer; }
.icon-picker input { position: absolute; opacity: 0; }
.icon-picker span { display: grid; place-items: center; height: 40px; border-radius: 11px; background: rgba(29, 90, 166, .06); color: var(--ink-2); border: 1px solid transparent; }
.icon-picker input:checked + span { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.icon-picker input:focus-visible + span { box-shadow: 0 0 0 3px rgba(29, 90, 166, .25); }

.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.link-list a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 550; }
.link-list a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }

.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.perm { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: rgba(29, 90, 166, .05); cursor: pointer; }
.perm span { display: flex; flex-direction: column; }
.perm small { color: var(--muted); }
.perm-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.perm-list li { display: flex; align-items: center; gap: 8px; }
.perm-list li.yes .icon { color: var(--green); }
.perm-list li.no { color: var(--muted); }
.matrix .yes { color: var(--green); }
.matrix .no { color: #c4c2dc; }
.matrix th a { color: var(--ink); }

/* ================= dashboard & analytics ================= */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px; color: var(--ink);
  background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm); min-width: 0; }
a.stat { transition: transform .15s, box-shadow .15s; }
a.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.stat > div { display: flex; flex-direction: column; min-width: 0; }
.stat strong { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-weight: 600; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.stat-icon .icon { width: 22px; height: 22px; }
.st-violet .stat-icon { background: var(--violet-soft); color: var(--primary); }
.st-green .stat-icon { background: var(--green-soft); color: var(--green); }
.st-amber .stat-icon { background: var(--amber-soft); color: var(--amber); }
.st-grey .stat-icon { background: #edf1f6; color: #6c6a8c; }
.st-red .stat-icon { background: var(--red-soft); color: var(--red); }
.st-blue .stat-icon { background: var(--blue-soft); color: var(--blue); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 0 20px; }

.stackbar { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: rgba(29, 90, 166, .08); margin: 4px 0 12px; }
.stackbar > * { display: block; min-width: 6px; }
.stackbar > a:hover { filter: brightness(.9); }
.stackbar-empty { flex: 1; }
.stack-legend { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; }
.stack-legend a { color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.stack-legend i, .legend-rows i, .legend-inline i { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.stack-legend b { color: var(--ink); }

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
        max-height: 470px; overflow-y: auto; overflow-x: hidden; padding-right: 4px; align-content: start; }
.wall-item[hidden] { display: none; }
.wall-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.wall-search { position: relative; flex: 1 1 220px; max-width: 320px; }
.wall-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.wall-search input { width: 100%; height: 36px; padding: 0 12px 0 34px; border-radius: 11px; font-size: 13px; }
.wall-tools .seg a { padding: 5px 10px; font-size: 12.5px; }
.wall-tools .seg small { margin-left: 4px; color: var(--muted); font-weight: 600; }
.wall-tools .seg a.on small { color: var(--primary); }
.wall-item .wall-ip { font-variant-numeric: tabular-nums; color: #7b8799; font-size: 11.5px; }
.wall-item { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 11px; row-gap: 6px;
  padding: 11px 12px; border-radius: 14px; background: rgba(255, 255, 255, .6); border: 1px solid var(--line); color: var(--ink);
  border-left: 4px solid #dcdaf0; }
.wall-item:hover { text-decoration: none; background: #fff; }
.wall-item .device { width: 34px; height: 34px; }
.wall-item { min-width: 0; }
.wall-item > div { display: flex; flex-direction: column; min-width: 0; }
.wall-item b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wall-item > div span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wall-item > .live, .wall-item > .muted { grid-column: 2; font-size: 12px; }
.w-unlocked { border-left-color: #16a34a; }
.w-locked, .w-signed-out { border-left-color: #eda100; }
.w-shutdown, .w-offline, .w-sleep, .w-restart { border-left-color: #8c8aa8; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed li > div { display: flex; flex-direction: column; min-width: 0; }
.feed li > div a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li > div span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-icon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: rgba(29, 90, 166, .07); color: var(--ink-2); }
.feed-icon .icon { width: 15px; height: 15px; }
.f-unlocked .feed-icon { background: var(--green-soft); color: var(--green); }
.f-locked .feed-icon, .f-signed-out .feed-icon { background: var(--amber-soft); color: var(--amber); }
.f-change .feed-icon { background: var(--blue-soft); color: var(--blue); }

.type-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.type-list a { display: grid; grid-template-columns: auto minmax(70px, 34%) 1fr 34px; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 12px; color: var(--ink-2); }
.type-list a:hover { background: rgba(29, 90, 166, .06); text-decoration: none; }
.type-list .device { width: 32px; height: 32px; border-radius: 10px; }
.type-list .device .icon { width: 17px; height: 17px; }
.type-list b { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }
.type-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.legend-rows { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.legend-rows li { display: grid; grid-template-columns: auto 1fr auto 44px; gap: 10px; align-items: center; font-size: 13.5px; }
.legend-rows span { color: var(--ink-2); }
.legend-rows small { color: var(--muted); text-align: right; }

.score { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.score strong { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.score strong small { font-size: 18px; color: var(--muted); }
.score span { color: var(--muted); font-size: 13px; }

.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: rgba(29, 90, 166, .07); }
.seg a { padding: 6px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.seg a:hover { text-decoration: none; color: var(--primary); }
.seg a.on { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

.usage { margin-bottom: 8px; }
.columns { display: flex; align-items: stretch; gap: 6px; height: 170px; padding: 0 2px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.col-track { flex: 1; width: min(46px, 100%); display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); }
.col-fill { display: block; width: 100%; background: linear-gradient(180deg, #1d5aa6, var(--primary)); border-radius: 4px 4px 0 0; }
.col:hover .col-fill { background: var(--primary-dark); }
.col-value { font-size: 12px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.col-label { font-size: 12px; color: var(--muted); }
.split { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.split-bar { flex: 1; display: flex; gap: 2px; height: 9px; border-radius: 5px; overflow: hidden; background: rgba(29, 90, 166, .08); }
.split-bar .a, .sw.a { background: #16a34a; }
.split-bar .l, .sw.l { background: #eda100; }
.split small { color: var(--muted); white-space: nowrap; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.compo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 32px; }
.compo h3 { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.compo .stackbar { margin-bottom: 8px; }
.legend-inline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend-inline li { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline small { color: var(--muted); }

/* ================= login ================= */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 94vw); border-radius: 28px; padding: 38px 34px; display: flex; flex-direction: column; gap: 15px; text-align: center; }
.login h1 { justify-content: center; font-size: 26px; }
.login .sub { justify-content: center; margin: -8px 0 6px; }
.login label { text-align: left; }
.login .flash { margin: 0; }

/* ================= responsive ================= */
@media (max-width: 1400px) {
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1400px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
  .row-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .compo { grid-template-columns: 1fr; }
  .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sections, .row-side { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app { flex-direction: column; padding: 10px; gap: 10px; }
  .rail { width: auto; height: auto; position: static; flex-direction: row; padding: 8px 12px; border-radius: 20px; }
  .rail, .rail-open .rail { width: auto; padding: 8px 12px; }
  .rail nav, .nav-group, .subs-in, .nav-group.is-open .subs-in { flex-direction: row; width: auto; }
  .subs { width: auto; }
  .rail nav { overflow-x: auto; }
  .sub-toggle { display: none; }
  .rail-tip, .rail-toggle, .rail .lbl { display: none !important; }
  .rail-head { width: auto; }
  .rail-open .rail a { width: 46px; padding: 0; justify-content: center; }
  .rail-bottom { flex-direction: row; width: auto; }
  .panel { padding: 20px 16px; border-radius: 22px; }
  .row-2, .row-3, .kpis, .perm-grid { grid-template-columns: 1fr; }
  .stats, .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search input { min-width: 0; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut { margin: 0 auto; }
}

/* ================= agents ================= */
.stat.picked { outline: 2px solid var(--primary); }
.ver, .cmd { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 8px; background: rgba(29, 90, 166, .08); color: var(--ink-2); }
.ver.v-current, .cmd.c-done { background: var(--green-soft); color: #166534; }
.ver.v-outdated, .cmd.c-pending, .cmd.c-sent { background: var(--amber-soft); color: #8a5a00; }
.ver.v-no-heartbeat, .cmd.c-failed, .cmd.c-no-reply { background: var(--red-soft); color: #a12a2a; }
td.actions-col { white-space: nowrap; text-align: right; }
td.actions-col form { display: inline-block; margin-left: 4px; }
th.last-action { width: 30%; }
.cmd-error { display: flex; gap: 6px; align-items: flex-start; margin-top: 5px; font-size: 12.5px; color: #a12a2a; line-height: 1.4; }
.cmd-error .icon { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.cmd-wait { display: flex; gap: 6px; align-items: flex-start; margin-top: 5px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.cmd-wait .icon { width: 14px; height: 14px; flex: none; margin-top: 1px; }
             border: 1px solid var(--border, #e6e3f5); border-radius: 12px; }
.uptime { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.uptime b { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.uptime .icon { width: 13px; height: 13px; }
.facts .uptime { font-size: inherit; }
/* status + up time use the tile's full width (under the icon too) and wrap instead of spilling out */
.wall-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
             gap: 4px 8px; min-width: 0; padding-top: 6px; border-top: 1px dashed var(--line); }
.wall-foot .uptime { margin-left: auto; }
.wall-foot .live { font-size: 12px; }

/* detected (agent) value under a form field: real text, selectable and copyable */
.detected { display: flex; align-items: flex-start; gap: 6px; margin-top: -1px; font-size: 12.5px; line-height: 1.45; min-width: 0; }
.detected-label { color: var(--muted); flex: none; }
.detected-value { color: var(--ink); font-weight: 550; user-select: text; word-break: break-word; min-width: 0; }
.detected.overridden .detected-value { color: var(--muted); font-weight: 500; text-decoration: line-through; }
.copy-btn { flex: none; width: 22px; height: 22px; margin-top: -2px; padding: 0; border: 0; border-radius: 6px; background: transparent;
            color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.copy-btn:hover { background: rgba(29, 90, 166, .1); color: var(--primary); }
.copy-btn .icon { width: 14px; height: 14px; }
.copy-btn.copied { color: #16a34a; }

/* pick-or-type box (e.g. Department): list of existing values, or type a new one */
.combo { position: relative; }
.combo input { width: 100%; padding-right: 38px; }
.combo input::-webkit-calendar-picker-indicator { opacity: 0; }   /* the browser's own arrow; ours replaces it */
.combo-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; padding: 0;
             border: 0; border-radius: 8px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.combo-btn:hover { background: rgba(29, 90, 166, .1); color: var(--primary); }
.combo-btn .icon { width: 15px; height: 15px; transform: rotate(90deg); }

/* remote connect */
.hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.remote-connect { display: flex; flex-direction: column; gap: 10px; }
.remote-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.remote-host { position: relative; flex: 1 1 320px; max-width: 520px; }
.remote-host .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.remote-host input { width: 100%; height: 44px; padding-left: 40px; font-size: 15px; }
.remote-connect .hint { margin: 0; }

/* remote screen viewer */
.rv { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 110px); min-height: 420px; }
.rv-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rv-bar .back { margin: 0; }
.rv-title { display: flex; flex-direction: column; min-width: 0; }
.rv-title b { font-size: 18px; color: var(--ink); }
.rv-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.rv-dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; display: inline-block; }
.rv-status.s-live .rv-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.rv-status.s-ended .rv-dot { background: #9ca3af; }
.rv-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-screen { position: relative; flex: 1; min-height: 0; overflow: auto; border-radius: 16px; background: #0f1d33;
             display: flex; align-items: flex-start; justify-content: flex-start; }
.rv-screen.fit { align-items: center; justify-content: center; overflow: hidden; }
.rv-screen canvas { display: block; outline: none; cursor: default; }
.rv-screen.fit canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.rv-screen:fullscreen { border-radius: 0; }
.rv-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
          color: #e3ebf6; text-align: center; background: #0f1d33; }
.rv-msg[hidden] { display: none; }
.rv-msg small { color: #9fb0c8; }
.rv-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .15); border-top-color: #2f7fc4;
           animation: rv-spin 1s linear infinite; }
@keyframes rv-spin { to { transform: rotate(360deg); } }
.rv-help { margin: 0; }

.rv-ready.r-ready { background: #dcfce7; color: #15803d; }
.rv-ready.r-setup { background: #fee2e2; color: #b91c1c; }
.rv-ready.r-starting { background: #fef3c7; color: #b45309; }
.rv-ready.r-off { background: #eef1f6; color: #5f6b7d; }
.rv-screen.active { box-shadow: 0 0 0 3px #2f7fc4; }

/* two-step sign-in */
.login .code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.login-links { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13.5px; }
.linkish { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.login .hint { margin: 0; text-align: center; }
.twofa-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #dcfce7; color: #15803d; }
.login > form { display: flex; flex-direction: column; gap: 15px; }

/* ================= sign-in (IMT brand) ================= */
.auth-page { min-height: 100vh; background: #f4f6fb; }
.auth-page .backdrop { display: none; }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
              padding: 48px 56px; color: #fff;
              background: radial-gradient(1200px 600px at -10% 110%, rgba(140, 198, 63, .35), transparent 60%),
                          linear-gradient(150deg, #123d73 0%, #1d5aa6 55%, #1f7a7a 100%); }
.auth-logo { align-self: flex-start; background: #fff; border-radius: 18px; padding: 16px 22px; box-shadow: 0 18px 40px rgba(6, 25, 56, .25); position: relative; z-index: 1; }
.auth-logo img { display: block; height: 52px; width: auto; }
.auth-pitch { position: relative; z-index: 1; max-width: 520px; }
.auth-pitch h1 { font-size: 40px; line-height: 1.1; margin: 0 0 14px; color: #fff; letter-spacing: -.5px; }
.auth-pitch > p { font-size: 17px; line-height: 1.55; color: rgba(255, 255, 255, .86); margin: 0 0 30px; }
.auth-pitch ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.auth-pitch li { display: flex; gap: 14px; align-items: flex-start; font-size: 14.5px; line-height: 1.45; color: rgba(255, 255, 255, .82); }
.auth-pitch li span { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
                      background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); }
.auth-pitch li span .icon { width: 20px; height: 20px; color: #b7f07a; }
.auth-pitch li b { display: block; color: #fff; font-size: 15px; margin-bottom: 2px; }
.auth-foot { position: relative; z-index: 1; margin: 0; font-size: 13px; color: rgba(255, 255, 255, .65); }
.auth-shape { position: absolute; border-radius: 40px; transform: rotate(-28deg); opacity: .16; pointer-events: none; }
.auth-shape.s1 { width: 160px; height: 520px; right: 70px; top: -140px; background: #8cc63f; }
.auth-shape.s2 { width: 120px; height: 420px; right: -20px; top: 40px; background: #2fa36b; }
.auth-shape.s3 { width: 90px; height: 300px; right: 190px; bottom: -120px; background: #fff; opacity: .08; }

.auth-panel { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 40px 20px; min-width: 0; }
.auth-card { width: 100%; max-width: 420px; box-sizing: border-box; min-width: 0; background: #fff; border-radius: 24px; padding: 40px 36px;
             box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 24px 60px rgba(18, 61, 115, .12); display: flex; flex-direction: column; gap: 16px; }
.auth-card h2 { margin: 0; font-size: 28px; color: #10233f; letter-spacing: -.3px; }
.auth-sub { margin: -8px 0 4px; color: #5f6b7d; line-height: 1.5; }
.auth-mobile-logo { display: none; height: 40px; width: auto; align-self: flex-start; }
.auth-card .flash { margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; font-weight: 600; color: #2b3a52; }
.auth-input { position: relative; display: block; }
.auth-input > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #8a96a8; pointer-events: none; }
.auth-input input { width: 100%; height: 48px; padding: 0 44px 0 44px; border-radius: 12px; border: 1.5px solid #dfe5ee; background: #f8fafc;
                    font-size: 15px; transition: border-color .15s, box-shadow .15s, background .15s; }
.auth-input input:focus { outline: none; border-color: #1d5aa6; background: #fff; box-shadow: 0 0 0 4px rgba(29, 90, 166, .12); }
.auth-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 9px;
            background: transparent; color: #8a96a8; display: grid; place-items: center; cursor: pointer; }
.auth-eye:hover, .auth-eye.on { color: #1d5aa6; background: rgba(29, 90, 166, .08); }
.auth-eye .icon { width: 18px; height: 18px; }
.auth-btn { height: 50px; font-size: 15.5px; border-radius: 12px; margin-top: 4px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
            background: linear-gradient(135deg, #1d5aa6, #2fa36b); box-shadow: 0 10px 24px rgba(29, 90, 166, .28); }
.auth-btn:hover { filter: brightness(1.06); }
.auth-btn .icon { width: 16px; height: 16px; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 0; font-size: 12.5px; color: #8a96a8; text-align: center; }
.auth-note .icon { width: 14px; height: 14px; }
.auth-badge { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: #e8f1fb; color: #1d5aa6; }
.auth-badge .icon { width: 26px; height: 26px; }
.auth-card .code-input { height: 58px; border-radius: 12px; border: 1.5px solid #dfe5ee; background: #f8fafc; font-size: 28px; letter-spacing: 12px;
                         text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.auth-card .code-input:focus { outline: none; border-color: #1d5aa6; background: #fff; box-shadow: 0 0 0 4px rgba(29, 90, 166, .12); }
.auth-card .login-links a, .auth-card .linkish { color: #1d5aa6; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-logo { display: block; }
  .auth-card { padding: 30px 24px; }
}

/* idle sign-out warning */
.idle-warn { position: fixed; right: 22px; bottom: 22px; z-index: 200; width: 340px; background: #fff; border-radius: 16px; padding: 18px;
             box-shadow: 0 20px 50px rgba(18, 30, 60, .25); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.idle-warn[hidden] { display: none; }
.idle-warn b { font-size: 15px; color: var(--ink); }
.idle-warn p { margin: 0; color: var(--muted); font-size: 13.5px; }
.idle-warn .row { display: flex; gap: 8px; justify-content: flex-end; }

/* ================= IMT theme for the app (matches the sign-in page) ================= */
:root { --violet: #123d73; --violet-soft: #e6edf7; --shadow: 0 10px 30px rgba(18, 61, 115, .08); --shadow-sm: 0 2px 10px rgba(18, 61, 115, .06); }
body { background: #f2f5f9; }
.backdrop { display: none; }
.glass { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; border: 1px solid #e3e9f1; }
.panel.glass { background: transparent; border: 0; box-shadow: none; padding: 26px 30px 40px; }
.card { background: #fff; border: 1px solid #e3e9f1; box-shadow: var(--shadow-sm); }
.stat { background: #fff; border: 1px solid #e3e9f1; box-shadow: var(--shadow-sm); }
input, select, textarea { background: #fff; border-color: #dbe3ee; }
.btn.ghost, .btn.danger { background: #fff; }
.tabs { background: #fff; border: 1px solid #e3e9f1; }
.tabs .on { background: #e8f1fb; box-shadow: none; }
.table th { background: #f5f8fc; }

/* sidebar: the sign-in page's navy -> teal panel */
.rail.glass { background: radial-gradient(500px 300px at -20% 110%, rgba(140, 198, 63, .28), transparent 60%),
                          linear-gradient(170deg, #123d73 0%, #1d5aa6 58%, #1f7a7a 100%);
              border: 0; box-shadow: 0 14px 34px rgba(18, 61, 115, .25); }
.rail a { color: rgba(255, 255, 255, .78); }
.rail a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.rail a.on { background: #fff; color: #123d73; box-shadow: 0 6px 16px rgba(6, 25, 56, .2); }
.rail .me .lbl b { color: #fff; }
.rail .me .lbl small { color: rgba(255, 255, 255, .65); }
.rail .avatar { background: linear-gradient(135deg, #8cc63f, #2fa36b); }
.rail-toggle { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.rail-toggle:hover { color: #fff; border-color: #fff; background: rgba(255, 255, 255, .22); }
.sub-toggle { color: rgba(255, 255, 255, .7); }
.sub-toggle:hover { color: #fff; background: rgba(255, 255, 255, .16); }
.nav-group.is-open .subs-in { background: rgba(255, 255, 255, .1); }
.rail-open .nav-group.is-open .subs-in { background: none; border-left-color: rgba(255, 255, 255, .25); }
.rail-open .rail .subs-in a.sub.on { background: rgba(255, 255, 255, .95); color: #123d73; }
.rail-open .rail .subs-in a.sub.on::before { background: #8cc63f; }
/* brand logo: white tile with the full logo when open, the "M" mark when collapsed */
.rail-logo { padding: 0 !important; }
.brand-tile { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: #fff;
              box-shadow: 0 6px 16px rgba(6, 25, 56, .2); }
.brand-tile img { display: block; }
.brand-tile .mark { width: 34px; height: 34px; }
.brand-tile .full { display: none; height: 36px; width: auto; }
.rail-open .rail .brand-tile { width: auto; height: 50px; padding: 0 14px; }
.rail-open .rail .brand-tile .mark { display: none; }
.rail-open .rail .brand-tile .full { display: block; }
.rail-open .rail .rail-head { align-items: center; }
.rail-brand-sub { display: none; }
.rail-open .rail .rail-brand-sub { display: block; margin: -2px 0 2px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .4px;
                                   text-transform: uppercase; color: rgba(255, 255, 255, .7); }
@media (max-width: 860px) { .rail.glass { border-radius: 18px; } }
/* the group arrow sits on the white "current page" pill: draw it navy there */
.rail .nav-row a.on ~ .sub-toggle { color: #123d73; }
.rail .nav-row a.on ~ .sub-toggle:hover { background: rgba(18, 61, 115, .1); color: #123d73; }
/* list changes (e.g. licensed software): removed on the left, current list on the right with additions marked */
.history td.old span, .history td.new.list span { display: inline-block; margin: 0 4px 4px 0; }
.history td.new.list span.kept { background: #f1f5fa; color: var(--ink-2); }
.history td.new.list span.added { background: #dcfce7; color: #14532d; font-weight: 600; }

/* Admin settings -> Server */
.restart-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.restart-card .help { margin: 6px 0 0; max-width: 820px; }
.restart-card.pending { border-color: #f5c56b; background: #fffaf0; }
.restart-card.pending h2 { color: #8a5300; }
.env-key { font-size: 11px; margin-left: 6px; color: var(--muted); background: #f1f5fa; }
.pending-note { display: inline-flex; align-items: center; gap: 5px; color: #8a5300; font-weight: 600; }
.pending-note .icon { width: 13px; height: 13px; }
.env-grid { align-items: start; }
.restarting { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 20px; text-align: center; }
.restarting .rv-spin { border-color: #e3e9f1; border-top-color: var(--primary); }
.history td.old, .history td.new { min-width: 200px; }
.history td.new.list { min-width: 260px; }
.history td.field-col { width: 220px; min-width: 150px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.history td.field-col .cell-sub { white-space: normal; }
.history td.field-col .fc { max-width: 240px; }
