:root {
    --bg: #07101f;
    --bg-deep: #050b16;
    --sidebar: #081222;
    --panel: #0d192b;
    --panel-2: #101f33;
    --line: #203149;
    --line-soft: rgba(148, 163, 184, .13);
    --text: #eef5ff;
    --muted: #8ea0b8;
    --muted-2: #61728a;
    --blue: #4b8dff;
    --blue-bright: #63a0ff;
    --teal: #27d3bd;
    --green: #39d98a;
    --violet: #9b7bff;
    --amber: #f4b84a;
    --rose: #ff718f;
    --danger: #ff647c;
    --radius: 15px;
    --shadow: 0 18px 50px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue-bright); outline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(28px, 4vw, 40px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 18px; letter-spacing: -.015em; }
small { color: var(--muted); }
.muted-pad { color: var(--muted); padding: 12px 22px 22px; }
.block-muted { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.eyebrow { display: block; margin-bottom: 9px; color: var(--blue-bright); font-size: 11px; font-weight: 800; letter-spacing: .16em; }

.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 258px; display: flex; flex-direction: column; padding: 25px 18px 18px; background: linear-gradient(180deg, #091526 0%, #07101e 100%); border-right: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand > span:last-child, .auth-brand > div { min-width: 0; }
.brand strong, .auth-brand strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small, .auth-brand small { display: block; margin-top: 1px; font-size: 11px; }
.brand-mark { width: 36px; height: 36px; flex: 0 0 36px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 8px; border: 1px solid rgba(99,160,255,.35); border-radius: 11px; background: linear-gradient(145deg, rgba(75,141,255,.2), rgba(39,211,189,.08)); box-shadow: inset 0 0 18px rgba(75,141,255,.08); }
.brand-mark span { width: 4px; border-radius: 4px; background: linear-gradient(180deg, var(--teal), var(--blue)); box-shadow: 0 0 8px rgba(75,141,255,.55); }
.brand-mark span:nth-child(1) { height: 9px; }
.brand-mark span:nth-child(2) { height: 17px; }
.brand-mark span:nth-child(3) { height: 13px; }
.brand-mark.large { width: 47px; height: 47px; flex-basis: 47px; padding: 10px; border-radius: 14px; }
.brand-mark.large span { width: 5px; }
.brand-mark.large span:nth-child(1) { height: 12px; }
.brand-mark.large span:nth-child(2) { height: 23px; }
.brand-mark.large span:nth-child(3) { height: 17px; }
.main-nav { display: grid; gap: 4px; }
.main-nav a { display: flex; align-items: center; gap: 11px; padding: 11px 12px; color: var(--muted); border: 1px solid transparent; border-radius: 10px; font-weight: 650; transition: .18s ease; }
.main-nav a:hover { color: var(--text); background: rgba(255,255,255,.035); }
.main-nav a.active { color: #fff; background: linear-gradient(90deg, rgba(75,141,255,.19), rgba(75,141,255,.06)); border-color: rgba(75,141,255,.16); box-shadow: inset 3px 0 0 var(--blue); }
.nav-icon { width: 20px; text-align: center; color: currentColor; font-size: 17px; }
.readonly-card { display: flex; gap: 10px; margin-top: auto; padding: 13px; border: 1px solid rgba(39,211,189,.16); border-radius: 12px; background: rgba(39,211,189,.055); }
.readonly-card strong { font-size: 12px; }
.readonly-card p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.shield { width: 24px; height: 24px; flex: 0 0 24px; display: inline-grid; place-items: center; color: var(--teal); background: rgba(39,211,189,.1); border: 1px solid rgba(39,211,189,.22); border-radius: 8px 8px 11px 11px; font-weight: 900; }
.sidebar-footer { display: flex; align-items: center; gap: 9px; margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line-soft); }
.user-avatar { width: 33px; height: 33px; flex: 0 0 33px; display: grid; place-items: center; color: #cfe2ff; background: #172a43; border: 1px solid #29415f; border-radius: 50%; font-weight: 800; }
.user-meta { min-width: 0; flex: 1; }
.user-meta strong, .user-meta small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta strong { font-size: 12px; }
.user-meta small { font-size: 10px; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }

.main-area { min-height: 100vh; margin-left: 258px; background: radial-gradient(circle at 20% -10%, rgba(75,141,255,.08), transparent 32%), var(--bg); }
.page-wrap { width: min(1450px, 100%); margin: 0 auto; padding: 39px 38px 70px; }
.narrow-wrap { width: min(930px, 100%); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header p { margin: 0; color: var(--muted); font-size: 14px; }
.mobile-header { display: none; }
.mobile-overlay { display: none; }

.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; color: #dbe8f8; background: #14243a; border: 1px solid #2a3d58; border-radius: 9px; font-weight: 700; cursor: pointer; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); background: #192c46; border-color: #3d587a; }
.button.primary { color: #fff; background: linear-gradient(135deg, #347df4, #4b8dff); border-color: #5896ff; box-shadow: 0 8px 22px rgba(52,125,244,.2); }
.button.primary:hover { background: linear-gradient(135deg, #438bff, #63a0ff); }
.button.quiet { background: #101d30; }
.button.danger { color: #ffdce2; background: rgba(255,100,124,.1); border-color: rgba(255,100,124,.32); }
.button.icon-only { width: 39px; padding: 8px; }
.button.wide { width: 100%; }
.panel { background: linear-gradient(155deg, rgba(16,31,51,.97), rgba(11,23,40,.97)); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.panel-heading { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 21px; border-bottom: 1px solid var(--line-soft); }
.panel-heading h2 { margin: 0; }
.panel-heading span { color: var(--muted); font-size: 11px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { min-height: 116px; display: flex; align-items: center; gap: 16px; padding: 18px; background: linear-gradient(145deg, rgba(16,31,51,.9), rgba(10,21,37,.9)); border: 1px solid var(--line-soft); border-radius: 14px; }
.stat-icon { width: 41px; height: 41px; flex: 0 0 41px; display: grid; place-items: center; border-radius: 11px; font-size: 18px; font-weight: 900; }
.stat-icon.blue { color: var(--blue-bright); background: rgba(75,141,255,.12); }
.stat-icon.green { color: var(--green); background: rgba(57,217,138,.1); }
.stat-icon.violet { color: var(--violet); background: rgba(155,123,255,.11); }
.stat-icon.amber { color: var(--amber); background: rgba(244,184,74,.1); }
.stat-card small, .stat-card strong, .stat-card span { display: block; }
.stat-card small { font-size: 11px; }
.stat-card strong { margin: 2px 0 0; font-size: 26px; line-height: 1.15; }
.stat-card div > span { color: var(--muted-2); font-size: 10px; }

.site-summary-row { display: flex; gap: 9px; margin-bottom: 18px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: thin; }
.site-pill { min-width: 150px; display: flex; align-items: center; gap: 10px; padding: 11px 13px; background: #0b1728; border: 1px solid var(--line-soft); border-radius: 11px; transition: .16s ease; }
.site-pill:hover, .site-pill.selected { background: #11213a; border-color: #355071; }
.site-pill.selected { box-shadow: inset 0 -2px 0 var(--blue); }
.site-pill strong, .site-pill small { display: block; white-space: nowrap; }
.site-pill strong { font-size: 11px; }
.site-pill small { font-size: 9px; }
.site-pill.add-site { min-width: 122px; color: var(--blue-bright); border-style: dashed; }
.site-orb { width: 8px; height: 8px; flex: 0 0 8px; display: inline-block; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.accent-blue, .accent-border-blue::before { color: #5b9bff; background: #5b9bff; }
.accent-teal, .accent-border-teal::before { color: #29d4bd; background: #29d4bd; }
.accent-violet, .accent-border-violet::before { color: #a386ff; background: #a386ff; }
.accent-amber, .accent-border-amber::before { color: #f5bd55; background: #f5bd55; }
.accent-rose, .accent-border-rose::before { color: #ff7593; background: #ff7593; }
.accent-slate, .accent-border-slate::before { color: #91a0b6; background: #91a0b6; }

.device-panel { overflow: hidden; }
.device-toolbar > div:first-child { display: flex; align-items: baseline; gap: 10px; }
.filter-form { display: flex; gap: 9px; }
.search-box { min-width: 230px; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; background: #091525; border: 1px solid var(--line); border-radius: 9px; }
.search-box span { color: var(--muted); font-size: 17px; }
.search-box input { width: 100%; padding: 0; color: var(--text); background: transparent; border: 0; outline: 0; }
.search-box input::placeholder { color: var(--muted-2); }
select, input, textarea { width: 100%; color: var(--text); background: #091525; border: 1px solid #263b55; border-radius: 9px; }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { padding: 11px; resize: vertical; }
select { min-width: 135px; color-scheme: dark; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(75,141,255,.11); }
.device-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; padding: 15px; }
.device-card { position: relative; min-width: 0; padding: 16px; background: #0b1728; border: 1px solid var(--line-soft); border-radius: 12px; transition: transform .17s ease, border-color .17s ease, background .17s ease; overflow: hidden; }
.device-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: var(--muted-2); }
.device-card.status-online::before { background: var(--green); }
.device-card.status-offline::before { background: var(--danger); }
.device-card:hover { transform: translateY(-2px); background: #0e1c30; border-color: #2c4260; }
.device-card-head { display: flex; align-items: center; gap: 10px; }
.device-card-head > div { min-width: 0; flex: 1; }
.device-card-head strong, .device-card-head small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-card-head strong { font-size: 13px; }
.device-card-head small { margin-top: 2px; font-size: 10px; }
.device-card-head small .site-orb { width: 5px; height: 5px; margin-right: 5px; }
.device-glyph { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; color: #8fbaff; background: linear-gradient(145deg, #162c48, #11223a); border: 1px solid #2b4668; border-radius: 9px; font-size: 13px; font-weight: 900; }
.device-glyph.small { width: 30px; height: 30px; flex-basis: 30px; }
.device-glyph.large { width: 50px; height: 50px; flex-basis: 50px; border-radius: 13px; font-size: 18px; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; color: #aebed1; background: rgba(148,163,184,.08); border: 1px solid rgba(148,163,184,.16); border-radius: 99px; font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-badge i { width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.status-badge.online { color: var(--green); background: rgba(57,217,138,.08); border-color: rgba(57,217,138,.17); }
.status-badge.offline { color: var(--danger); background: rgba(255,100,124,.08); border-color: rgba(255,100,124,.17); }
.device-identity { min-height: 45px; margin: 14px 0 11px; padding-bottom: 11px; border-bottom: 1px solid var(--line-soft); }
.device-identity strong, .device-identity span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-identity strong { font-size: 12px; }
.device-identity span { color: var(--muted); font-size: 10px; }
.metric-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 14px; }
.metric-pair span { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.metric-pair b { color: #ced9e8; }
progress { width: 100%; height: 4px; display: block; margin-top: 6px; overflow: hidden; appearance: none; border: 0; border-radius: 10px; background: #1d2c42; }
progress::-webkit-progress-bar { background: #1d2c42; border-radius: 10px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 10px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 10px; }
.device-card-foot { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.device-card-foot span { min-width: 0; }
.device-card-foot small, .device-card-foot strong { display: block; }
.device-card-foot small { font-size: 8px; }
.device-card-foot strong { margin-top: 2px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state { min-height: 330px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 45px 20px; text-align: center; }
.empty-state h3 { margin: 4px 0; font-size: 20px; }
.empty-state p { max-width: 430px; color: var(--muted); }
.empty-illustration { width: 55px; height: 55px; display: grid; place-items: center; margin-bottom: 14px; color: var(--blue-bright); background: rgba(75,141,255,.1); border: 1px solid rgba(75,141,255,.22); border-radius: 16px; font-size: 25px; }
.error-state { margin-top: 50px; }

.site-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.site-card { position: relative; padding: 21px; background: linear-gradient(150deg, var(--panel-2), var(--panel)); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.site-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; }
.site-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.site-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 11px; color: #06111e; font-weight: 900; }
.site-card h2 { font-size: 19px; }
.site-card > p { min-height: 42px; color: var(--muted); font-size: 12px; }
.site-card .site-location { min-height: 0; margin-bottom: 13px; color: #c3d0e0; }
.site-counts { display: flex; gap: 25px; margin: 18px 0; padding: 15px 0; border-block: 1px solid var(--line-soft); }
.site-counts span { color: var(--muted); font-size: 10px; }
.site-counts strong { display: block; color: var(--text); font-size: 18px; }
.card-actions { display: flex; gap: 8px; }
.card-actions .button:first-child { flex: 1; }

.back-link, .breadcrumbs { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.back-link:hover, .breadcrumbs a:hover { color: var(--blue-bright); }
.breadcrumbs strong { color: #cbd7e6; }
.detail-form { padding: 24px; }
.detail-form > h2 { margin-top: 0; }
.detail-form label, .install-form label, .stack-form label { display: grid; gap: 7px; color: #c6d4e4; font-size: 11px; font-weight: 700; }
.detail-form label > small, .install-form label > small { font-weight: 400; }
.form-grid { display: grid; gap: 15px; margin-bottom: 16px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.host-grid { grid-template-columns: minmax(0,1fr) 150px; }
.host-grid label > small { color: var(--muted); font-size: 9px; font-weight: 400; }
.cloud-dns-guidance { display: flex; align-items: flex-start; gap: 12px; margin: -2px 0 18px; padding: 13px 14px; color: #cbd9ea; background: rgba(75,141,255,.055); border: 1px solid rgba(75,141,255,.18); border-radius: 11px; }
.cloud-dns-guidance strong { display: block; font-size: 11px; }
.cloud-dns-guidance p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.cloud-dns-icon { min-width: 35px; padding: 6px 5px; color: var(--blue-bright); background: rgba(75,141,255,.12); border: 1px solid rgba(75,141,255,.24); border-radius: 8px; font-size: 8px; font-weight: 900; letter-spacing: .08em; text-align: center; }
.detail-form > label { margin-bottom: 16px; }
.detail-form hr { height: 1px; margin: 23px 0; background: var(--line-soft); border: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 58px; }
.password-field button { position: absolute; inset: 5px 5px 5px auto; padding: 0 9px; color: var(--blue-bright); background: transparent; border: 0; border-radius: 6px; font-size: 10px; font-weight: 800; cursor: pointer; }
.password-field.with-tools input { padding-right: 132px; }
.password-field .password-tools { position: absolute; inset: 5px 5px 5px auto; display: flex; align-items: stretch; border-left: 1px solid var(--line); }
.password-field .password-tools button { position: static; inset: auto; padding: 0 8px; }
.password-field .password-tools button + button { border-left: 1px solid var(--line-soft); }
.toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0 18px; }
.toggle { display: grid !important; grid-template-columns: 39px 1fr; gap: 0 11px !important; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle > span { position: relative; width: 39px; height: 22px; grid-row: 1; background: #26364c; border: 1px solid #3a4c65; border-radius: 99px; transition: .18s ease; }
.toggle > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: #91a3ba; border-radius: 50%; transition: .18s ease; }
.toggle input:checked + span { background: rgba(75,141,255,.34); border-color: var(--blue); }
.toggle input:checked + span::after { left: 20px; background: #fff; }
.toggle div { grid-column: 2; grid-row: 1; }
.toggle strong, .toggle small { display: block; }
.toggle small { margin-top: 1px; font-weight: 400; }
.toggle.standalone { margin: 20px 0; }
.readonly-guidance { display: flex; gap: 12px; margin-top: 20px; padding: 14px; background: rgba(39,211,189,.055); border: 1px solid rgba(39,211,189,.15); border-radius: 11px; }
.readonly-guidance p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
code { color: #b7d3ff; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.router-script-card { margin: 23px 0 20px; padding: 18px; background: linear-gradient(145deg, rgba(8,20,35,.95), rgba(8,17,30,.95)); border: 1px solid rgba(75,141,255,.22); border-radius: 13px; box-shadow: inset 0 1px 0 rgba(255,255,255,.025); }
.router-script-head { display: flex; align-items: center; gap: 12px; }
.router-script-head > div { min-width: 0; flex: 1; }
.router-script-head h2 { margin: 0; font-size: 16px; }
.router-script-head p { margin: 2px 0 0; color: var(--muted); font-size: 10px; }
.router-script-head p strong { color: #d7e5f6; }
.setup-steps { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; margin: 16px 0 11px; }
.setup-steps span { display: flex; align-items: center; gap: 7px; padding: 8px; color: var(--muted); background: rgba(19,37,61,.55); border: 1px solid var(--line-soft); border-radius: 8px; font-size: 9px; }
.setup-steps b { width: 19px; height: 19px; display: grid; place-items: center; flex: 0 0 19px; color: var(--blue-bright); background: rgba(75,141,255,.11); border-radius: 6px; font-size: 9px; }
.router-script-output { min-height: 380px; padding: 14px; color: #bdd3ee; background: #040b14; border-color: #1e3550; border-radius: 9px; resize: vertical; font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; tab-size: 4; }
.router-script-output:focus { border-color: #31577f; box-shadow: none; }
.router-script-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 11px; }
.router-script-actions > span { color: var(--muted); font-size: 10px; }
.router-script-actions .button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.router-script-note { margin: 13px 0 0; padding-top: 12px; color: var(--muted-2); border-top: 1px solid var(--line-soft); font-size: 9px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding: 18px 20px; background: rgba(255,100,124,.045); border: 1px solid rgba(255,100,124,.16); border-radius: 12px; }
.danger-zone p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.color-field { margin: 8px 0 0; padding: 0; border: 0; }
.color-field legend { margin-bottom: 9px; color: #c6d4e4; font-size: 11px; font-weight: 700; }
.color-choices { display: flex; gap: 10px; }
.color-choice { display: block !important; cursor: pointer; }
.color-choice input { position: absolute; opacity: 0; }
.color-choice span { width: 31px; height: 31px; display: block; background: currentColor; border: 5px solid #0d192b; border-radius: 50%; box-shadow: 0 0 0 1px #2e425d; }
.color-choice input:checked + span { box-shadow: 0 0 0 2px #fff; }

.table-panel { overflow: hidden; }
.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 16px; color: var(--muted); background: rgba(5,12,22,.34); border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 9px; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); color: #c7d4e3; font-size: 11px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(75,141,255,.025); }
.table-primary { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.table-primary strong, .table-primary small { display: block; }
.table-primary small { margin-top: 2px; font-size: 9px; }
.empty-row { padding: 45px 20px; color: var(--muted); text-align: center; }
.source-tag { padding: 3px 7px; color: #a8c9f5; background: #162840; border: 1px solid #293f5d; border-radius: 6px; font-size: 9px; }

.device-hero { display: flex; align-items: center; justify-content: space-between; gap: 25px; margin-bottom: 20px; }
.device-hero-main, .hero-title-row, .hero-actions { display: flex; align-items: center; gap: 13px; }
.device-hero h1 { margin: 0; font-size: 29px; }
.device-hero p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.site-dot-text { display: inline-flex; align-items: center; gap: 5px; }
.connection-alert { display: flex; gap: 12px; margin-bottom: 18px; padding: 13px 15px; color: #ffd6dc; background: rgba(255,100,124,.07); border: 1px solid rgba(255,100,124,.2); border-radius: 11px; }
.connection-alert > span { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 24px; background: rgba(255,100,124,.14); border-radius: 50%; font-weight: 900; }
.connection-alert p { margin: 2px 0 0; color: #d6a8b0; font-size: 11px; }
.device-stat-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 11px; margin-bottom: 12px; }
.device-stat-grid article { min-width: 0; padding: 15px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 12px; }
.device-stat-grid small, .device-stat-grid strong, .device-stat-grid span { display: block; }
.device-stat-grid small { font-size: 9px; }
.device-stat-grid strong { margin: 2px 0; font-size: 20px; }
.device-stat-grid span { color: var(--muted-2); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; margin-bottom: 12px; }
.chart-card { padding: 15px 15px 8px; overflow: hidden; }
.chart-card > div { display: flex; align-items: baseline; justify-content: space-between; }
.chart-card span { color: var(--muted); font-size: 10px; }
.chart-card strong { font-size: 18px; }
.chart-card canvas { width: 100%; height: 105px; display: block; margin-top: 8px; }
.detail-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 11px; }
.device-info-card, .address-card { overflow: hidden; }
.info-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; padding: 9px 21px 17px; }
.info-list div { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.info-list div:nth-last-child(-n+2) { border-bottom: 0; }
.info-list dt { color: var(--muted); font-size: 9px; }
.info-list dd { margin: 2px 0 0; color: #d8e4f1; font-size: 11px; font-weight: 700; }
.address-list { display: grid; gap: 7px; padding: 13px 17px 17px; }
.address-list div { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 9px 11px; background: #0a1627; border: 1px solid var(--line-soft); border-radius: 9px; }
.address-list span { color: #cee0f7; font-family: ui-monospace, monospace; font-size: 11px; }
.address-list strong { text-align: right; font-size: 10px; }
.address-list small { grid-column: 1 / -1; font-size: 8px; }
.section-gap { margin-top: 12px; }
.notes-panel { padding: 20px; }
.notes-panel p { margin: 0; color: var(--muted); }

.cron-panel, .security-panel { padding: 20px; }
.cron-panel .panel-heading { min-height: 0; margin: -20px -20px 18px; }
.cron-panel > p { color: var(--muted); }
.code-copy { display: flex; align-items: stretch; background: #06101d; border: 1px solid #233852; border-radius: 9px; overflow: hidden; }
.code-copy code { flex: 1; padding: 12px; overflow-x: auto; white-space: nowrap; font-size: 10px; }
.code-copy button { padding: 0 15px; color: var(--blue-bright); background: #101f33; border: 0; border-left: 1px solid #233852; font-weight: 800; cursor: pointer; }
.cron-example { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; align-items: center; margin-top: 13px; color: var(--muted); font-size: 10px; }
.cron-example strong { padding: 3px 8px; color: #d5e4f7; background: #12243a; border-radius: 6px; font-family: ui-monospace, monospace; }
.cron-example small { text-align: right; }
.security-panel { display: flex; gap: 13px; background: rgba(39,211,189,.045); border-color: rgba(39,211,189,.15); }
.security-panel h2 { margin: 0; }
.security-panel p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.flash-stack { position: fixed; z-index: 60; top: 18px; right: 20px; width: min(430px, calc(100vw - 40px)); display: grid; gap: 8px; }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; color: #d8e6f7; background: #13233a; border: 1px solid #2a405f; border-radius: 10px; box-shadow: var(--shadow); font-size: 11px; }
.flash > span { width: 21px; height: 21px; display: grid; place-items: center; flex: 0 0 21px; border-radius: 50%; font-weight: 900; }
.flash-success { border-color: rgba(57,217,138,.26); }
.flash-success > span { color: var(--green); background: rgba(57,217,138,.11); }
.flash-error { border-color: rgba(255,100,124,.3); }
.flash-error > span { color: var(--danger); background: rgba(255,100,124,.12); }
.flash-info > span { color: var(--blue-bright); background: rgba(75,141,255,.12); }

.auth-page, .install-page { display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 20% 15%, rgba(75,141,255,.12), transparent 30%), radial-gradient(circle at 85% 80%, rgba(39,211,189,.08), transparent 28%), var(--bg-deep); }
.auth-backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.auth-backdrop span { position: absolute; width: 1px; height: 1px; border-radius: 50%; box-shadow: 15vw 20vh 0 1px rgba(99,160,255,.35), 72vw 15vh 0 1px rgba(39,211,189,.22), 89vw 64vh 0 1px rgba(99,160,255,.2), 31vw 77vh 0 1px rgba(155,123,255,.2), 55vw 47vh 0 1px rgba(255,255,255,.18); }
.auth-card { position: relative; width: min(430px, 100%); padding: 29px; background: rgba(11,23,40,.92); border: 1px solid #223753; border-radius: 19px; box-shadow: 0 30px 90px rgba(0,0,0,.45); backdrop-filter: blur(16px); }
.auth-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 23px; border-bottom: 1px solid var(--line-soft); }
.auth-heading { margin: 29px 0 22px; }
.auth-heading h1 { font-size: 30px; }
.auth-heading p { color: var(--muted); }
.stack-form { display: grid; gap: 16px; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 21px; color: var(--muted); font-size: 10px; }
.auth-note .shield { width: 19px; height: 19px; flex-basis: 19px; font-size: 9px; }

.install-page { display: block; }
.install-wrap { width: min(890px, 100%); margin: 0 auto; }
.install-header { display: flex; align-items: center; gap: 16px; margin: 18px 0 25px; }
.install-header h1 { margin: 0; font-size: 31px; }
.install-header p { margin: 3px 0 0; color: var(--muted); }
.requirement-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 13px; }
.requirement-strip span { display: flex; align-items: center; gap: 5px; padding: 5px 8px; color: var(--muted); background: #0b1728; border: 1px solid var(--line-soft); border-radius: 7px; font-size: 9px; }
.requirement-strip i { font-style: normal; }
.requirement-strip .passed i { color: var(--green); }
.requirement-strip .failed { color: #ffc2cc; border-color: rgba(255,100,124,.3); }
.install-form { display: grid; gap: 12px; }
.form-section { display: grid; grid-template-columns: 44px 1fr; gap: 15px; padding: 23px; }
.section-number { width: 37px; height: 37px; display: grid; place-items: center; color: var(--blue-bright); background: rgba(75,141,255,.1); border: 1px solid rgba(75,141,255,.22); border-radius: 10px; font-weight: 900; }
.section-content > p { margin-bottom: 18px; color: var(--muted); font-size: 11px; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.choice-card { display: block !important; }
.choice-card input { position: absolute; opacity: 0; }
.choice-card span { display: block; padding: 12px; background: #091525; border: 1px solid #263b55; border-radius: 9px; cursor: pointer; }
.choice-card strong, .choice-card small { display: block; }
.choice-card input:checked + span { background: rgba(75,141,255,.1); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(75,141,255,.08); }
.mysql-fields { display: none; padding: 15px; background: rgba(3,9,17,.25); border: 1px solid var(--line-soft); border-radius: 10px; }
.mysql-fields.visible { display: block; }
.install-button { justify-self: end; min-width: 190px; }
.install-footnote { margin: 17px 0 0; color: var(--muted-2); text-align: center; font-size: 10px; }

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(2,1fr); }
    .device-card-grid { grid-template-columns: repeat(2,1fr); }
    .site-card-grid { grid-template-columns: repeat(2,1fr); }
    .device-stat-grid { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-101%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.35); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .mobile-overlay { position: fixed; z-index: 20; inset: 0; display: block; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
    .main-area { margin-left: 0; }
    .mobile-header { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: rgba(8,18,34,.92); border-bottom: 1px solid var(--line-soft); position: sticky; z-index: 15; top: 0; backdrop-filter: blur(14px); }
    .mobile-header strong { font-size: 12px; }
    .live-dot { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
    .live-dot i { width: 6px; height: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); }
    .page-wrap { padding: 27px 20px 60px; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .page-header { align-items: flex-start; flex-direction: column; }
    .page-header .button { width: 100%; }
    .stat-grid, .device-card-grid, .site-card-grid, .chart-grid { grid-template-columns: 1fr; }
    .device-card-grid { padding: 11px; }
    .device-toolbar { align-items: stretch; flex-direction: column; }
    .filter-form { flex-direction: column; }
    .search-box { min-width: 0; width: 100%; }
    .form-grid.two, .host-grid, .toggle-row, .choice-row { grid-template-columns: 1fr; }
    .device-hero { align-items: flex-start; flex-direction: column; }
    .hero-actions { width: 100%; }
    .hero-actions > *, .hero-actions .button { flex: 1; }
    .device-stat-grid { grid-template-columns: repeat(2,1fr); }
    .form-section { grid-template-columns: 1fr; padding: 18px; }
    .cron-example { grid-template-columns: 1fr; }
    .cron-example small { text-align: left; }
    .danger-zone { align-items: flex-start; flex-direction: column; }
    .danger-zone .button { width: 100%; }
    .setup-steps { grid-template-columns: 1fr 1fr; }
    .router-script-head { align-items: flex-start; flex-wrap: wrap; }
    .router-script-actions { align-items: stretch; flex-direction: column; }
    .router-script-actions .button { width: 100%; }
    .install-page { padding: 18px 13px; }
    .install-header { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
