:root {
    --bg: #08090b; --surface: #121418; --surface-raised: #171a1f; --surface-soft: #1b1e24;
    --ink: #f5f6f8; --ink-soft: #a6abb5; --ink-faint: #6f7580;
    --line: #292d34; --line-soft: #20242a; --brand: #ff2438; --brand-dark: #df172b;
    --brand-soft: rgba(255,36,56,.12); --brand-ink: #fff;
    --ok: #35c978; --ok-soft: rgba(53,201,120,.12); --warn: #f4ad35; --warn-soft: rgba(244,173,53,.12);
    --bad: #ff6271; --bad-soft: rgba(255,98,113,.12); --sidebar: #0d0f12;
    --sidebar-line: rgba(255,255,255,.08); --sidebar-ink: #b5bac4; --sidebar-ink-dim: #727986;
    --radius: 16px; --radius-sm: 10px; --shadow-xs: 0 1px 2px rgba(0,0,0,.22);
    --shadow-sm: 0 12px 34px -24px rgba(0,0,0,.9); --shadow-md: 0 28px 80px -28px rgba(0,0,0,.8);
    --ease: .18s cubic-bezier(.4,0,.2,1);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { font: 14px/1.55 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: #ff6472; }
h1 { font-size: clamp(24px, 2.2vw, 32px); line-height: 1.2; font-weight: 750; letter-spacing: -.035em; margin: 0; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em; }
p { line-height: 1.65; }
code { background: var(--surface-soft); border: 1px solid var(--line); padding: 2px 7px; border-radius: 7px; color: #ffd0d5; font-size: 12.5px; }
::selection { color: #fff; background: rgba(255,36,56,.45); }

/* Shell */
.shell { min-height: 100vh; }
.panel-shell { display: flex; background: radial-gradient(900px 500px at 90% -10%, rgba(255,36,56,.07), transparent 60%), var(--bg); }
.sidebar { width: 264px; flex-shrink: 0; padding: 24px 16px 18px; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; background: rgba(13,15,18,.96); border-right: 1px solid var(--sidebar-line); box-shadow: 18px 0 50px -38px #000; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; position: relative; overflow: hidden; color: #fff; font-weight: 850; font-size: 13px; letter-spacing: -.04em; background: linear-gradient(145deg, #ff3347, #d70f24); border: 1px solid rgba(255,255,255,.13); box-shadow: 0 10px 25px -12px rgba(255,36,56,.9); }
.brand-mark::after { content: ""; position: absolute; width: 30px; height: 3px; background: rgba(255,255,255,.2); rotate: -45deg; translate: 13px -13px; }
.brand-mark.lg { width: 54px; height: 54px; border-radius: 15px; font-size: 17px; }
.brand-name { color: #fff; font-size: 15.5px; font-weight: 750; letter-spacing: -.015em; }
.brand-sub { color: var(--sidebar-ink-dim); font-size: 11px; margin-top: 1px; }
.workspace-label, .nav-section-label { color: #5f6672; font-size: 9.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.workspace-label { padding: 0 10px 9px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 3px; }
.nav-section-label { padding: 15px 10px 5px; }
.nav-section-label:first-child { padding-top: 3px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; border: 1px solid transparent; border-radius: 11px; color: var(--sidebar-ink); font-size: 13.5px; font-weight: 550; position: relative; transition: background-color var(--ease), color var(--ease), border-color var(--ease), transform var(--ease); }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.05); transform: translateX(2px); }
.nav-item.active { color: #fff; background: var(--brand-soft); border-color: rgba(255,36,56,.22); font-weight: 650; }
.nav-item.active::before { content: ""; position: absolute; left: -17px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 4px 4px 0; background: var(--brand); box-shadow: 0 0 14px var(--brand); }
.ni-icon { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; color: #858c98; }
.nav-item:hover .ni-icon, .nav-item.active .ni-icon { color: var(--brand); }
.sidebar-foot { border-top: 1px solid var(--sidebar-line); padding: 16px 6px 0; margin-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-soft); border: 1px solid var(--line); color: #fff; font-weight: 750; }
.who-name { color: #fff; font-weight: 650; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 155px; }
.who-role { color: var(--sidebar-ink-dim); font-size: 11px; }
.logout-button { width: 100%; justify-content: center; }
.panel-main { flex: 1; min-width: 0; }
.panel-topbar { height: 78px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 4; background: rgba(8,9,11,.82); border-bottom: 1px solid var(--line-soft); backdrop-filter: blur(16px) saturate(145%); }
.topbar-kicker, .eyebrow { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.topbar-title { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12.5px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.content { width: 100%; max-width: 1500px; padding: 34px clamp(22px, 3.2vw, 52px) 60px; }

/* Page heads and dashboard */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.page-head::before { content: ""; width: 4px; align-self: stretch; min-height: 30px; border-radius: 5px; background: var(--brand); box-shadow: 0 0 18px rgba(255,36,56,.35); }
.page-head h1 { flex: 1; }
.page-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.dashboard-welcome { display: flex; justify-content: space-between; gap: 30px; align-items: center; margin-bottom: 18px; padding: 24px 26px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; position: relative; background: linear-gradient(110deg, #16191e 0%, #111318 62%, rgba(255,36,56,.11) 100%); }
.dashboard-welcome::after { content: ""; position: absolute; right: -55px; top: -80px; width: 220px; height: 220px; border: 42px solid rgba(255,36,56,.07); rotate: 25deg; }
.dashboard-welcome h2 { font-size: 22px; margin: 5px 0 3px; }
.dashboard-welcome p { margin: 0; color: var(--ink-soft); }
.live-badge { white-space: nowrap; z-index: 1; padding: 8px 12px; border-radius: 999px; background: var(--ok-soft); color: #75e4a6; font-size: 12px; font-weight: 650; border: 1px solid rgba(53,201,120,.22); }
.live-badge span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 7px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { min-height: 112px; display: flex; align-items: center; gap: 15px; padding: 18px; background: linear-gradient(145deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform var(--ease), border-color var(--ease), background var(--ease); }
.kpi:hover { transform: translateY(-2px); border-color: #3a3f48; background: var(--surface-raised); }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); border: 1px solid rgba(255,36,56,.16); }
.kpi-icon.ok { color: var(--ok); background: var(--ok-soft); border-color: rgba(53,201,120,.2); }
.kpi-icon.warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(244,173,53,.2); }
.kpi-label { color: var(--ink-soft); font-size: 12px; font-weight: 550; }
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 760; letter-spacing: -.04em; margin-top: 5px; }
.kpi-value.ok { color: var(--ok); }
.kpi-value.warn { color: var(--warn); }

/* Cards, tables, forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 18px; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; gap: 16px; }
.card-head h2 { margin: 3px 0 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); gap: 18px; align-items: start; }
.form-card { max-width: 780px; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13.5px; }
.table th { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink-faint); font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--ease); }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table .num { text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
label { display: block; margin-bottom: 13px; }
label > span { display: block; color: var(--ink-soft); font-size: 11.5px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; color: var(--ink); background: #0d0f12; transition: border-color var(--ease), box-shadow var(--ease), background var(--ease); }
input:hover, select:hover, textarea:hover { border-color: #444a54; background: #101216; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] { width: 17px; min-height: 17px; accent-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.inline-form { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.inline-form select, .inline-form input { width: auto; }
.inline { display: inline; }
.filter-row { margin-bottom: 14px; }
.filter-row select { width: auto; }
.upload-form { border: 1px dashed #434953; border-radius: var(--radius-sm); padding: 17px; margin-bottom: 16px; background: rgba(255,255,255,.018); }
fieldset.modules { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 15px; margin: 12px 0; }
fieldset.modules legend { color: var(--ink-soft); font-size: 11.5px; font-weight: 600; padding: 0 7px; }
.chk { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.module-list { display: flex; flex-direction: column; gap: 5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--ink); font: inherit; font-weight: 650; cursor: pointer; transition: background-color var(--ease), border-color var(--ease), transform .1s ease, box-shadow var(--ease); }
.btn:hover { color: #fff; background: var(--surface-soft); border-color: #414650; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, #ff3044, #e2152a); border-color: #ff3044; box-shadow: 0 10px 26px -14px rgba(255,36,56,.95); }
.btn-primary:hover { color: #fff; background: linear-gradient(135deg, #ff4557, #ec1e33); border-color: #ff4557; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #17120a; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.045); }
.btn-ghost-dark { background: transparent; border-color: rgba(255,255,255,.2); color: #fff; }
.btn-ghost-dark:hover { background: rgba(255,255,255,.07); }
.btn-sm { min-height: 33px; padding: 6px 11px; font-size: 12px; }
.btn-lg { min-height: 47px; padding: 11px 20px; font-size: 14.5px; }
.btn.danger, .btn-ghost.danger { color: var(--bad); }
.btn.danger:hover, .btn-ghost.danger:hover { background: var(--bad-soft); border-color: rgba(255,98,113,.25); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 13px 0; }
button:disabled { opacity: .42; cursor: default; }

/* Utility and feedback */
.muted { color: var(--ink-soft); }
.hint { color: var(--ink-faint); font-size: 12px; }
.note { background: var(--warn-soft); border: 1px solid rgba(244,173,53,.22); border-radius: var(--radius-sm); padding: 11px 13px; color: #eac98e; font-size: 13px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 11px 14px; margin: 0; }
.kv dt { color: var(--ink-soft); font-size: 12px; font-weight: 550; }
.kv dd { margin: 0; }
.license-key { font: 700 20px/1.3 "Cascadia Mono", Consolas, monospace; letter-spacing: 1px; color: #ff8792; background: var(--brand-soft); border: 1px solid rgba(255,36,56,.22); border-radius: var(--radius-sm); padding: 15px; text-align: center; margin-bottom: 12px; }
.pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; margin-right: 4px; }
.pill-ok { color: #6fe5a3; background: var(--ok-soft); border: 1px solid rgba(53,201,120,.18); }
.pill-warn { color: #f5c670; background: var(--warn-soft); border: 1px solid rgba(244,173,53,.18); }
.pill-bad { color: #ff8994; background: var(--bad-soft); border: 1px solid rgba(255,98,113,.18); }
.pill-mut { color: var(--ink-soft); background: var(--surface-soft); border: 1px solid var(--line); }
.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 15px; font-size: 13.5px; }
.alert-error { color: #ff9aa4; background: var(--bad-soft); border: 1px solid rgba(255,98,113,.22); }
.alert-ok { color: #7ce2a9; background: var(--ok-soft); border: 1px solid rgba(53,201,120,.22); }

/* Login */
.login-wrap { min-height: 100vh; padding: 28px; display: grid; place-items: center; background: radial-gradient(900px 600px at 15% 15%, rgba(255,36,56,.13), transparent 58%), #08090b; }
.login-shell { width: min(1040px, 100%); min-height: 650px; display: grid; grid-template-columns: 1.08fr .92fr; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-md); }
.login-showcase { padding: 44px; display: flex; flex-direction: column; position: relative; overflow: hidden; background: linear-gradient(145deg, #15171c, #0b0c0f); border-right: 1px solid var(--line); }
.login-showcase::before { content: ""; position: absolute; right: -100px; top: 80px; width: 330px; height: 330px; border: 65px solid rgba(255,36,56,.07); border-radius: 32px; rotate: 34deg; }
.login-logo { display: flex; align-items: center; gap: 13px; font-size: 17px; z-index: 1; }
.login-logo > span:last-child { display: grid; }
.login-logo small { color: var(--ink-faint); font-size: 10px; font-weight: 600; margin-top: 1px; }
.login-copy { margin: auto 0; max-width: 460px; z-index: 1; }
.login-eyebrow { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.login-copy h2 { font-size: clamp(36px, 4vw, 54px); line-height: 1.05; letter-spacing: -.045em; margin: 14px 0 18px; }
.login-copy h2 span { color: var(--brand); }
.login-copy p { color: var(--ink-soft); font-size: 16px; max-width: 42ch; }
.login-benefits { display: grid; gap: 10px; margin-top: 28px; color: #d8dbe0; font-size: 13.5px; }
.login-trust { z-index: 1; color: var(--ink-faint); font-size: 11.5px; }
.login-card { align-self: center; padding: 56px; text-align: left; }
.login-card h1 { margin: 9px 0 6px; font-size: 32px; }
.login-card .stack { display: flex; flex-direction: column; gap: 4px; margin-top: 26px; }
.login-card .stack label { margin-bottom: 10px; }
.login-card .btn { width: 100%; margin-top: 7px; }
.login-mobile-brand { display: none; }
.login-help { margin-top: 20px; text-align: center; color: var(--ink-faint); font-size: 12px; }

/* Hardware product images */
.hardware-image-field { display: grid; grid-template-columns: 180px 1fr; gap: 22px; align-items: center; margin-bottom: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.018); }
.hardware-image-preview, .hardware-image-placeholder { width: 180px; height: 130px; border-radius: 11px; border: 1px solid var(--line); background: #0b0d10; }
.hardware-image-preview { display: block; object-fit: contain; padding: 8px; }
.hardware-image-placeholder { display: grid; place-items: center; color: var(--ink-faint); font-size: 12px; }
.hardware-image-field p { margin: 3px 0 9px; }
.hardware-file-button { position: relative; overflow: hidden; }
.hardware-file-button input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.hardware-file-selected { margin-top: 8px; color: #76dfa3; font-size: 12px; }
.hardware-list-thumb { width: 58px; height: 42px; display: block; object-fit: contain; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #0b0d10; }
.hardware-list-thumb.empty { display: grid; place-items: center; color: var(--ink-faint); }

@media (max-width: 1080px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
    .panel-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0 4px 12px; }
    .brand-mark { width: 36px; height: 36px; }
    .workspace-label, .nav-section-label, .sidebar-foot { display: none; }
    .nav { flex-direction: row; overflow-x: auto; padding: 0 0 2px; }
    .nav-item { min-width: max-content; min-height: 38px; padding: 8px 11px; }
    .nav-item.active::before { left: 10px; right: 10px; top: auto; bottom: -2px; width: auto; height: 2px; }
    .panel-topbar { position: static; height: 64px; padding: 0 20px; }
    .topbar-user { display: none; }
    .content { padding: 24px 18px 45px; }
    .grid-2 { grid-template-columns: 1fr; }
    .login-shell { grid-template-columns: 1fr; min-height: 0; max-width: 500px; }
    .login-showcase { display: none; }
    .login-card { padding: 42px; }
    .login-mobile-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; font-weight: 750; }
}
@media (max-width: 560px) {
    .panel-topbar { display: none; }
    .content { padding: 22px 14px 40px; }
    .page-head { align-items: flex-start; flex-wrap: wrap; }
    .page-actions { width: 100%; }
    .dashboard-welcome { align-items: flex-start; padding: 20px; }
    .live-badge { display: none; }
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi { min-height: 94px; }
    .card { padding: 16px; }
    .kv { grid-template-columns: 1fr; gap: 3px; }
    .kv dd { margin-bottom: 9px; }
    .login-wrap { padding: 12px; }
    .login-card { padding: 30px 24px; }
    .hardware-image-field { grid-template-columns: 1fr; }
    .hardware-image-preview, .hardware-image-placeholder { width: 100%; height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
