:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-2: #091722;
  --panel: #0d1d29;
  --panel-2: #102633;
  --panel-3: #132d3a;
  --line: rgba(150, 202, 216, .14);
  --line-strong: rgba(150, 220, 228, .23);
  --text: #f2f7f8;
  --muted: #8aa5af;
  --muted-2: #64808b;
  --accent: #39ddcf;
  --accent-2: #57c8f1;
  --accent-soft: rgba(57, 221, 207, .13);
  --success: #4fe09b;
  --warning: #ffc85a;
  --danger: #ff6d7f;
  --info: #6ec7ff;
  --sidebar: 276px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 80% -10%, rgba(58, 203, 221, .08), transparent 33%),
    linear-gradient(180deg, #071018 0%, #09131c 100%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #183442; border: 2px solid transparent; background-clip: padding-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #24505f; border: 2px solid transparent; background-clip: padding-box; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.muted { color: var(--muted); }

/* LOGIN */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(420px, .75fr);
}
.login-visual {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 54px 64px;
  background:
    radial-gradient(circle at 60% 45%, rgba(48, 193, 213, .15), transparent 24%),
    linear-gradient(145deg, #07131d, #0b202b 58%, #07131d);
  border-right: 1px solid var(--line);
}
.visual-grid {
  position: absolute;
  inset: 0;
  opacity: .23;
  background-image:
    linear-gradient(rgba(84, 218, 221, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 218, 221, .08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, black, transparent 92%);
}
.visual-glow { position: absolute; width: 440px; height: 440px; border-radius: 50%; filter: blur(70px); opacity: .2; }
.visual-glow-a { background: var(--accent); right: 12%; top: 18%; }
.visual-glow-b { background: #2863ff; left: -15%; bottom: -20%; opacity: .1; }
.brand-lockup { display: flex; align-items: center; gap: 12px; position: relative; z-index: 2; }
.brand-lockup strong { display: block; font-size: 15px; letter-spacing: .08em; }
.brand-lockup span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; letter-spacing: .05em; }
.brand-mark {
  width: 43px; height: 43px; display: grid; place-items: center;
  border: 1px solid rgba(86, 231, 218, .4); border-radius: 12px;
  color: var(--accent); font-size: 14px; font-weight: 900; letter-spacing: -.06em;
  background: linear-gradient(145deg, rgba(57, 221, 207, .16), rgba(57, 221, 207, .03));
  box-shadow: inset 0 0 18px rgba(57, 221, 207, .08), 0 0 26px rgba(57, 221, 207, .08);
}
.brand-lockup-large .brand-mark { width: 50px; height: 50px; border-radius: 14px; font-size: 16px; }
.brand-lockup-large strong { font-size: 17px; }
.visual-copy { position: absolute; z-index: 2; left: 64px; bottom: 76px; max-width: 650px; }
.visual-copy h1 { margin: 0 0 20px; max-width: 620px; font-size: clamp(40px, 5vw, 72px); line-height: 1.02; letter-spacing: -.045em; }
.visual-copy > p:last-child { max-width: 570px; margin: 0; color: #aac0c8; font-size: 17px; line-height: 1.7; }
.signal-orbit { position: absolute; border: 1px solid rgba(81, 218, 221, .16); border-radius: 50%; }
.signal-orbit i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px var(--accent); }
.orbit-one { width: 360px; height: 360px; right: 10%; top: 18%; animation: spin 24s linear infinite; }
.orbit-one i { left: 10%; top: 20%; }
.orbit-two { width: 250px; height: 250px; right: 18%; top: 25%; animation: spin-reverse 18s linear infinite; }
.orbit-two i { right: 4%; top: 47%; background: var(--accent-2); box-shadow: 0 0 18px var(--accent-2); }
.device-node {
  position: absolute; z-index: 2; min-width: 100px; padding: 12px 16px; border: 1px solid var(--line-strong);
  border-radius: 12px; background: rgba(10, 27, 38, .72); backdrop-filter: blur(12px);
  color: #b9d0d6; font-size: 12px; font-weight: 750; letter-spacing: .08em;
  box-shadow: var(--shadow);
}
.device-node span { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px rgba(79, 224, 155, .75); }
.node-a { right: 10%; top: 16%; }
.node-b { right: 34%; top: 36%; }
.node-c { right: 9%; top: 53%; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-reverse { to { transform: rotate(-360deg); } }

.login-panel { display: grid; place-items: center; min-height: 100vh; padding: 46px; background: rgba(5, 12, 18, .52); }
.login-card { width: min(100%, 440px); }
.brand-lockup-mobile { display: none; margin-bottom: 38px; }
.login-card h2 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.03em; }
.login-card > .muted { margin: 0 0 34px; line-height: 1.6; }
.field-label { display: block; margin: 18px 0 8px; color: #b8cbd1; font-size: 12px; font-weight: 750; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 54px; padding: 0 48px 0 46px; border: 1px solid var(--line-strong); border-radius: 13px;
  outline: none; background: #0a1822; color: var(--text); transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrap input::placeholder { color: #526e79; }
.input-wrap input:focus { border-color: rgba(57, 221, 207, .65); box-shadow: 0 0 0 4px rgba(57, 221, 207, .09); background: #0b1c27; }
.input-icon { position: absolute; z-index: 1; left: 16px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.input-action { position: absolute !important; right: 7px; top: 50%; transform: translateY(-50%); }
.form-error { margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(255, 109, 127, .3); border-radius: 10px; color: #ff9aa7; background: rgba(255, 109, 127, .08); font-size: 13px; }
.primary-button, .secondary-button, .ghost-button, .danger-button {
  border: 0; border-radius: 12px; cursor: pointer; font-weight: 800; transition: transform .16s, opacity .16s, box-shadow .16s, background .16s;
}
.primary-button { background: linear-gradient(135deg, #25d8ca, #55c9e8); color: #061319; box-shadow: 0 14px 34px rgba(46, 216, 205, .18); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 18px 38px rgba(46, 216, 205, .23); }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled, .danger-button:disabled { cursor: not-allowed; opacity: .45; transform: none; box-shadow: none; }
.login-button { width: 100%; height: 54px; margin-top: 24px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; }
.button-arrow { font-size: 20px; }
.security-note { display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 24px; color: var(--muted); font-size: 12px; }

/* APP SHELL */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50; width: var(--sidebar); display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(10, 25, 36, .98), rgba(7, 18, 26, .99));
  box-shadow: 12px 0 36px rgba(0, 0, 0, .12);
}
.sidebar-head { min-height: 84px; display: flex; align-items: center; justify-content: space-between; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand span { font-size: 10px; }
.main-nav { padding: 18px 13px; overflow-y: auto; }
.nav-group-label { margin: 14px 13px 8px; color: #526d78; font-size: 9px; font-weight: 850; letter-spacing: .19em; }
.nav-item {
  position: relative; width: 100%; min-height: 46px; margin: 3px 0; padding: 0 13px; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: #90a9b2; cursor: pointer; text-align: left; transition: background .18s, color .18s, border-color .18s;
}
.nav-item:hover { color: #d9e8ec; background: rgba(255, 255, 255, .025); }
.nav-item.active { color: #eafffc; border-color: rgba(57, 221, 207, .13); background: linear-gradient(90deg, rgba(57, 221, 207, .13), rgba(57, 221, 207, .035)); }
.nav-item.active::before { content: ""; position: absolute; left: -1px; width: 3px; height: 24px; border-radius: 0 5px 5px 0; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.nav-item > span { width: 19px; height: 19px; }
.nav-item b { font-size: 13px; font-weight: 700; }
.nav-item em { min-width: 23px; height: 21px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: rgba(255,255,255,.055); color: #a9c0c7; font-size: 10px; font-style: normal; }
.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
.cloud-status-card { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.02); }
.cloud-status-card strong, .cloud-status-card small { display: block; }
.cloud-status-card strong { font-size: 11px; }
.cloud-status-card small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.version-line { margin-top: 11px; color: #48636d; font-size: 9px; text-align: center; }
.workspace { min-width: 0; grid-column: 2; }
.topbar {
  position: sticky; top: 0; z-index: 35; min-height: 84px; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--line); background: rgba(7, 16, 24, .84); backdrop-filter: blur(18px);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; }
.topbar-left { gap: 14px; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.topbar .eyebrow { margin-bottom: 4px; font-size: 9px; }
.topbar-actions { position: relative; gap: 9px; }
.icon-button {
  position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 11px;
  background: rgba(255,255,255,.025); color: #9eb4bb; cursor: pointer; transition: color .16s, border-color .16s, background .16s, transform .16s;
}
.icon-button:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255,255,255,.045); transform: translateY(-1px); }
.icon-button svg { width: 18px; height: 18px; }
.live-pill { height: 38px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid rgba(79,224,155,.16); border-radius: 999px; color: #aee9cc; background: rgba(79,224,155,.055); font-size: 11px; font-weight: 750; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.status-online { background: var(--success); box-shadow: 0 0 12px rgba(79,224,155,.68); }
.status-warning { background: var(--warning); box-shadow: 0 0 12px rgba(255,200,90,.58); }
.status-offline { background: #58737e; box-shadow: none; }
.status-danger { background: var(--danger); box-shadow: 0 0 12px rgba(255,109,127,.55); }
.notification-badge { position: absolute; right: -4px; top: -5px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; border: 2px solid #071018; border-radius: 999px; background: var(--danger); color: white; font-size: 9px; font-weight: 900; }
.user-chip { min-width: 190px; height: 46px; padding: 0 12px 0 7px; display: grid; grid-template-columns: 34px minmax(0,1fr) 16px; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); cursor: pointer; text-align: left; }
.user-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(145deg, rgba(57,221,207,.2), rgba(87,200,241,.09)); color: var(--accent); font-size: 11px; font-weight: 900; }
.user-chip-copy { min-width: 0; }
.user-chip-copy strong, .user-chip-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-chip-copy strong { font-size: 11px; }
.user-chip-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.user-chip > span:last-child { width: 14px; height: 14px; color: var(--muted); }
.user-menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 210px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 13px; background: #0d1d29; box-shadow: var(--shadow); }
.user-menu button { width: 100%; padding: 11px 12px; border: 0; border-radius: 9px; background: transparent; color: #c2d4d9; cursor: pointer; text-align: left; }
.user-menu button:hover { background: rgba(255,255,255,.04); }
.danger-text { color: #ff9ba8 !important; }
.page-content { min-height: calc(100vh - 84px); padding: 28px; outline: none; }

/* PAGE ELEMENTS */
.page-grid { display: grid; gap: 18px; }
.page-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.page-grid.sidebar-layout { grid-template-columns: minmax(0, 1.55fr) minmax(310px, .65fr); }
.hero-panel {
  position: relative; overflow: hidden; min-height: 190px; padding: 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  border: 1px solid var(--line); border-radius: var(--radius); background:
    radial-gradient(circle at 80% 10%, rgba(57,221,207,.13), transparent 33%),
    linear-gradient(135deg, #0d202c, #0b1a24 70%);
  box-shadow: 0 20px 60px rgba(0,0,0,.16);
}
.hero-panel::after { content: ""; position: absolute; inset: 0; opacity: .12; background-image: linear-gradient(rgba(86,219,222,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(86,219,222,.12) 1px, transparent 1px); background-size: 35px 35px; mask-image: linear-gradient(90deg, transparent, black); }
.hero-copy, .hero-status { position: relative; z-index: 1; }
.hero-copy h2 { max-width: 700px; margin: 0 0 11px; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.04em; }
.hero-copy p { max-width: 680px; margin: 0; color: #9bb4bc; line-height: 1.65; }
.hero-status { min-width: 210px; padding: 17px; border: 1px solid rgba(93,224,214,.18); border-radius: 14px; background: rgba(6,20,28,.55); backdrop-filter: blur(10px); }
.hero-status-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; color: var(--muted); font-size: 11px; }
.hero-status-row strong { color: #dff4f3; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.kpi-card { position: relative; overflow: hidden; min-height: 128px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(16,38,51,.92), rgba(10,25,35,.92)); }
.kpi-card::after { content: ""; position: absolute; right: -26px; top: -28px; width: 95px; height: 95px; border-radius: 50%; background: var(--kpi-color, var(--accent)); opacity: .055; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(57,221,207,.09); color: var(--accent); }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-trend { padding: 5px 7px; border-radius: 999px; background: rgba(79,224,155,.08); color: #8de1b7; font-size: 9px; font-weight: 800; }
.kpi-value { margin-top: 16px; font-size: 28px; font-weight: 850; letter-spacing: -.04em; }
.kpi-label { margin-top: 4px; color: var(--muted); font-size: 11px; }
.panel-card { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(14,31,43,.95), rgba(9,23,33,.96)); box-shadow: 0 14px 44px rgba(0,0,0,.09); }
.panel-head { min-height: 64px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 18px; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 3px 0 13px; }
.section-title-row h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.section-title-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.secondary-button, .ghost-button, .danger-button { min-height: 38px; padding: 0 14px; }
.secondary-button { border: 1px solid rgba(57,221,207,.22); background: rgba(57,221,207,.08); color: #baf5ef; }
.secondary-button:hover { background: rgba(57,221,207,.14); }
.ghost-button { border: 1px solid var(--line); background: rgba(255,255,255,.02); color: #b6c9cf; }
.ghost-button:hover { background: rgba(255,255,255,.05); }
.danger-button { border: 1px solid rgba(255,109,127,.26); background: rgba(255,109,127,.08); color: #ff9aa7; }
.small-button { min-height: 32px; padding: 0 11px; border-radius: 9px; font-size: 10px; }

.data-table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th { padding: 10px 12px; color: #58727c; font-size: 9px; font-weight: 850; letter-spacing: .1em; text-align: left; border-bottom: 1px solid var(--line); }
.data-table td { padding: 13px 12px; color: #bfd0d5; font-size: 11px; border-bottom: 1px solid rgba(142,197,209,.08); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .16s; }
.data-table tbody tr:hover { background: rgba(255,255,255,.02); }
.table-main { display: flex; align-items: center; gap: 10px; }
.table-icon { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 9px; background: rgba(57,221,207,.08); color: var(--accent); }
.table-icon svg { width: 16px; height: 16px; }
.table-main strong, .table-main small { display: block; }
.table-main strong { color: #e8f3f5; font-size: 11px; }
.table-main small { margin-top: 2px; color: var(--muted-2); font-size: 9px; }
.status-badge, .type-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 9px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.status-badge.online { color: #9de7c1; background: rgba(79,224,155,.08); border: 1px solid rgba(79,224,155,.16); }
.status-badge.offline { color: #8ca2aa; background: rgba(120,148,158,.07); border: 1px solid rgba(120,148,158,.12); }
.status-badge.alarm { color: #ff9aa7; background: rgba(255,109,127,.08); border: 1px solid rgba(255,109,127,.18); }
.type-badge { color: #a9c9d2; background: rgba(110,199,255,.07); border: 1px solid rgba(110,199,255,.13); }
.row-action { min-width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.row-action:hover { color: var(--text); background: rgba(255,255,255,.04); }
.row-action svg { width: 15px; height: 15px; }

.search-toolbar { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input { width: 100%; height: 42px; padding: 0 14px 0 42px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: rgba(255,255,255,.025); color: var(--text); }
.search-box input:focus { border-color: rgba(57,221,207,.45); box-shadow: 0 0 0 3px rgba(57,221,207,.07); }
.search-box > span { position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-chip { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; }
.filter-chip.active { border-color: rgba(57,221,207,.23); background: rgba(57,221,207,.09); color: #bdf2ed; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.entity-card { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(15,35,47,.95), rgba(9,24,34,.96)); cursor: pointer; transition: transform .17s, border-color .17s, background .17s; }
.entity-card:hover { transform: translateY(-2px); border-color: rgba(57,221,207,.23); background: linear-gradient(145deg, rgba(17,41,54,.98), rgba(10,27,38,.98)); }
.entity-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.entity-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--accent); background: rgba(57,221,207,.09); }
.entity-icon svg { width: 20px; height: 20px; }
.entity-card h3 { margin: 15px 0 5px; font-size: 14px; }
.entity-card > p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.entity-meta { margin-top: 17px; padding-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); color: #79939c; font-size: 9px; }
.entity-meta span { display: flex; align-items: center; gap: 6px; }
.entity-meta svg { width: 13px; height: 13px; }

.structure-tree { display: grid; gap: 9px; }
.tree-row { position: relative; min-height: 48px; padding: 10px 12px 10px 14px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.02); }
.tree-row.level-1 { margin-left: 22px; }
.tree-row.level-2 { margin-left: 44px; }
.tree-row.level-3 { margin-left: 66px; }
.tree-row.level-1::before, .tree-row.level-2::before, .tree-row.level-3::before { content: ""; position: absolute; left: -14px; width: 13px; height: 1px; background: var(--line-strong); }
.tree-row-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(57,221,207,.075); color: var(--accent); }
.tree-row-icon svg { width: 15px; height: 15px; }
.tree-row strong, .tree-row small { display: block; }
.tree-row strong { font-size: 10px; }
.tree-row small { margin-top: 2px; color: var(--muted); font-size: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 11px; }
.metric-card { min-height: 105px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.018); }
.metric-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric-card-label { color: var(--muted); font-size: 9px; }
.metric-card-unit { color: #55717b; font-size: 8px; }
.metric-value { margin-top: 13px; color: #eaf8f8; font-size: 21px; font-weight: 850; letter-spacing: -.03em; }
.metric-spark { width: 100%; height: 30px; margin-top: 8px; overflow: visible; }
.metric-spark path.area { fill: rgba(57,221,207,.06); }
.metric-spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.7; vector-effect: non-scaling-stroke; }

.device-detail-head { margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.device-title-row { display: flex; align-items: center; gap: 14px; }
.device-title-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: rgba(57,221,207,.11); color: var(--accent); }
.device-title-icon svg { width: 24px; height: 24px; }
.device-detail-head h2 { margin: 0 0 6px; font-size: 22px; }
.device-detail-head p { margin: 0; color: var(--muted); font-size: 10px; }
.device-breadcrumb { margin-top: 8px !important; color: #8fb2ba !important; }
.device-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.definition-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.definition-item { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.definition-item span, .definition-item strong { display: block; }
.definition-item span { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .09em; }
.definition-item strong { margin-top: 5px; font-size: 10px; word-break: break-word; }
.control-lock { padding: 13px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid rgba(255,200,90,.17); border-radius: 11px; background: rgba(255,200,90,.055); }
.control-lock > span { width: 20px; height: 20px; color: var(--warning); }
.control-lock strong, .control-lock small { display: block; }
.control-lock strong { color: #f5dda7; font-size: 10px; }
.control-lock small { margin-top: 4px; color: #a99061; font-size: 9px; line-height: 1.5; }
.command-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.command-chip { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; color: #86a2ab; background: rgba(255,255,255,.018); font-size: 9px; }
.command-chip.readonly { color: #9ce6df; border-color: rgba(57,221,207,.16); background: rgba(57,221,207,.055); }

.alarm-list { display: grid; gap: 10px; }
.alarm-row { padding: 13px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.alarm-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--danger); background: rgba(255,109,127,.08); }
.alarm-icon svg { width: 16px; height: 16px; }
.alarm-row strong, .alarm-row small { display: block; }
.alarm-row strong { font-size: 10px; }
.alarm-row small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.alarm-time { color: var(--muted-2); font-size: 8px; }

.empty-state { min-height: 260px; padding: 34px; display: grid; place-items: center; text-align: center; }
.empty-state-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 17px; color: var(--accent); background: rgba(57,221,207,.07); }
.empty-state-icon svg { width: 26px; height: 26px; }
.empty-state h3 { margin: 0 0 8px; font-size: 16px; }
.empty-state p { max-width: 470px; margin: 0 auto; color: var(--muted); font-size: 11px; line-height: 1.65; }
.empty-state .secondary-button { margin-top: 17px; }

.system-checks { display: grid; gap: 10px; }
.system-check { padding: 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.system-check-left { display: flex; align-items: center; gap: 11px; }
.system-check-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: rgba(57,221,207,.075); }
.system-check-icon svg { width: 16px; height: 16px; }
.system-check strong, .system-check small { display: block; }
.system-check strong { font-size: 10px; }
.system-check small { margin-top: 3px; color: var(--muted); font-size: 8px; }

.skeleton { position: relative; overflow: hidden; background: rgba(255,255,255,.04); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.055), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-line { height: 11px; border-radius: 999px; }
.skeleton-card { min-height: 128px; border-radius: 16px; }

/* MODAL */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: rgba(0,8,13,.74); backdrop-filter: blur(9px); }
.modal-card { width: min(100%, 760px); max-height: calc(100vh - 44px); overflow: auto; border: 1px solid var(--line-strong); border-radius: 18px; background: #0c1c27; box-shadow: var(--shadow); }
.modal-head { padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-field label { display: block; margin-bottom: 7px; color: #9eb5bc; font-size: 9px; font-weight: 750; }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #0a1822; color: var(--text); }
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: rgba(57,221,207,.45); box-shadow: 0 0 0 3px rgba(57,221,207,.07); }
.form-field.full { grid-column: 1 / -1; }

/* TOAST + LOADER */
.toast-root { position: fixed; z-index: 200; right: 22px; bottom: 22px; width: min(380px, calc(100vw - 44px)); display: grid; gap: 9px; }
.toast { padding: 13px 14px; display: grid; grid-template-columns: 24px minmax(0,1fr) 24px; align-items: start; gap: 10px; border: 1px solid var(--line-strong); border-radius: 12px; background: #102430; box-shadow: var(--shadow); animation: toast-in .22s ease-out; }
.toast.success { border-color: rgba(79,224,155,.22); }
.toast.error { border-color: rgba(255,109,127,.27); }
.toast-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: var(--accent); background: rgba(57,221,207,.08); }
.toast.error .toast-icon { color: var(--danger); background: rgba(255,109,127,.08); }
.toast strong, .toast small { display: block; }
.toast strong { font-size: 10px; }
.toast small { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.5; }
.toast button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.global-loader { position: fixed; z-index: 210; inset: 0; display: grid; place-items: center; background: rgba(4,11,16,.45); backdrop-filter: blur(2px); }
.global-loader span { width: 42px; height: 42px; border: 3px solid rgba(57,221,207,.16); border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }

.sidebar-backdrop { position: fixed; z-index: 45; inset: 0; background: rgba(0,7,11,.64); backdrop-filter: blur(3px); }
.mobile-only { display: none; }

@media (max-width: 1250px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .page-grid.sidebar-layout { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  :root { --sidebar: 270px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { padding: 28px; }
  .brand-lockup-mobile { display: flex; }
  .app-shell { display: block; }
  .workspace { grid-column: auto; }
  .sidebar { transform: translateX(-102%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 12px 18px; }
  .page-content { padding: 20px 18px; }
}

@media (max-width: 720px) {
  .topbar { min-height: 74px; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .live-pill { display: none; }
  .user-chip { min-width: 0; width: 44px; padding: 0 5px; grid-template-columns: 34px; }
  .user-chip-copy, .user-chip > span:last-child { display: none; }
  .page-content { min-height: calc(100vh - 74px); padding: 15px; }
  .hero-panel { min-height: 230px; padding: 21px; display: block; }
  .hero-copy h2 { font-size: 29px; }
  .hero-copy p { font-size: 12px; }
  .hero-status { margin-top: 20px; min-width: 0; }
  .kpi-grid, .card-grid, .page-grid.two, .page-grid.three { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .search-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { max-width: none; }
  .device-detail-head { flex-direction: column; }
  .device-head-actions { width: 100%; }
  .device-head-actions button { flex: 1; }
  .definition-grid, .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .modal-root { padding: 9px; }
  .modal-card { max-height: calc(100vh - 18px); border-radius: 14px; }
}

@media (max-width: 430px) {
  .login-panel { padding: 22px; }
  .login-card h2 { font-size: 27px; }
  .metric-grid { grid-template-columns: 1fr; }
  .kpi-grid { gap: 10px; }
  .kpi-card { min-height: 112px; }
  .topbar-left { gap: 8px; }
  .topbar .eyebrow { display: none; }
  .topbar-actions .icon-button:nth-of-type(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
