/* ================= tokens ================= */
:root {
  --ink: #1e1b4b;
  --ink-2: #3f3d6b;
  --muted: #646489;
  --line: rgba(99, 91, 255, .12);
  --primary: #5b4cf0;
  --primary-dark: #4636d8;
  --primary-soft: #eeebff;
  --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(76, 64, 190, .13);
  --shadow-sm: 0 6px 20px rgba(76, 64, 190, .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%, #f3f0ff 35%, #eef2ff 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: #b3b0d6; }
.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: #5d5a8c; 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, #ece8ff, #ddd6ff); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(91, 76, 240, .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; }
.rail a[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; z-index: 50; background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-sm); pointer-events: none;
}
.rail nav { overflow: visible; }
.rail-logo:hover { background: none !important; }
.rail-toggle {
  width: 30px; height: 30px; border-radius: 10px; border: 1px solid rgba(99, 91, 255, .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, #7c6cff, #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 .rail a[data-tip]:hover::after { display: none; }

.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(99, 91, 255, .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(91, 76, 240, .15); }
input::placeholder, textarea::placeholder { color: #9a98bd; }
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, #6d5ef5, #5140e6); color: #fff; box-shadow: 0 6px 16px rgba(91, 76, 240, .28);
}
.btn:hover { background: linear-gradient(135deg, #5f4ff0, #4433d6); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn.ghost { background: rgba(255, 255, 255, .85); color: var(--primary-dark); border-color: rgba(99, 91, 255, .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, #ece8ff, #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(99, 91, 255, .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 #ecebf5; }
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(99, 91, 255, .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(99, 91, 255, .08); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #7c6cff, 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(99, 91, 255, .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(99, 91, 255, .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(91, 76, 240, .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, #eef0ff, #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, #ece8ff, #ddd5ff); color: #5b4cf0; }
.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: #f0f0f6; 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: #b9b7d4; }
.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: #b9b7d4; }
.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(99, 91, 255, .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(99, 91, 255, .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(99, 91, 255, .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(99, 91, 255, .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(30, 27, 75, .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(99, 91, 255, .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(91, 76, 240, .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(99, 91, 255, .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(99, 91, 255, .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(91, 76, 240, .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(99, 91, 255, .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: #ecebf5; 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(99, 91, 255, .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; }
.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 { grid-row: span 2; width: 34px; height: 34px; }
.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(99, 91, 255, .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(99, 91, 255, .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(99, 91, 255, .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, #7c6cff, 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(99, 91, 255, .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 { flex-direction: row; overflow-x: auto; }
  .rail a[data-tip]:hover::after, .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(99, 91, 255, .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; }
.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; }
.wall-foot { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.wall-foot .live { font-size: 12px; }
