:root {
  --bg: #0d0e0f;
  --surface: #121416;
  --surface-2: #181b1e;
  --line: #292d31;
  --line-soft: #202327;
  --text: #f0eee8;
  --muted: #8f9498;
  --faint: #5d6267;
  --accent: #e7a22e;
  --accent-dark: #2d2314;
  --green: #4fc18a;
  --red: #e36c64;
  --blue: #6aa9d8;
  --sidebar: 232px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .18em; }

.login-shell { min-height: 100svh; display: grid; grid-template-columns: minmax(300px, 46%) 1fr; background: var(--surface); }
.login-mark { display: grid; place-items: center; overflow: hidden; border-right: 1px solid var(--line); background: radial-gradient(circle at 50% 42%, #2c2519 0, #121416 40%, #0b0c0d 76%); }
.login-mark span { font-family: Georgia, serif; font-size: clamp(220px, 35vw, 520px); line-height: .7; color: transparent; -webkit-text-stroke: 1px #80622e; opacity: .55; transform: translateY(-3%); animation: markIn 900ms cubic-bezier(.2,.8,.2,1) both; }
.login-panel { width: min(430px, calc(100% - 48px)); align-self: center; margin: auto; animation: riseIn 600ms 120ms ease both; }
.login-panel h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(46px, 6vw, 76px); font-weight: 400; letter-spacing: -.04em; }
.login-copy { max-width: 370px; margin: 20px 0 42px; color: var(--muted); line-height: 1.6; }
label { display: grid; gap: 8px; margin-bottom: 19px; color: #b8b9b7; font-size: 12px; font-weight: 650; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 4px; outline: none; background: #0e1011; color: var(--text); padding: 12px 13px; transition: border-color 150ms, box-shadow 150ms; }
input:focus, select:focus { border-color: #9d762e; box-shadow: 0 0 0 3px rgba(231,162,46,.08); }
.form-error { min-height: 20px; color: var(--red); font-size: 12px; }

.primary, .secondary, .danger, .danger-outline { border-radius: 3px; padding: 10px 15px; font-weight: 750; font-size: 12px; transition: transform 120ms, background 150ms, border-color 150ms; }
.primary { border: 1px solid var(--accent); background: var(--accent); color: #17130c; }
.primary:hover { background: #f1b347; transform: translateY(-1px); }
.secondary { border: 1px solid var(--line); background: transparent; color: var(--text); }
.secondary:hover { border-color: var(--faint); background: var(--surface-2); }
.danger { border: 1px solid var(--red); background: var(--red); color: #190b0a; }
.danger-outline { border: 1px solid #633532; background: transparent; color: #dc8a84; }
.danger-outline:hover { border-color: var(--red); background: #211514; }
.wide { width: 100%; padding-block: 13px; margin-top: 8px; }

.app-shell { min-height: 100svh; display: grid; grid-template-columns: var(--sidebar) 1fr; animation: appIn 400ms ease both; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--sidebar); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #101214; }
.brand { display: flex; align-items: center; gap: 11px; height: 84px; padding: 0 22px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #755927; color: var(--accent); font-family: Georgia, serif; font-size: 20px; }
.brand b, .brand small { display: block; }
.brand b { font-size: 12px; letter-spacing: .11em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .16em; }
nav { padding: 24px 12px; display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 10px; border: 0; border-left: 2px solid transparent; background: transparent; color: var(--muted); text-align: left; font-size: 13px; }
.nav-item span { color: var(--faint); font: 10px ui-monospace, monospace; }
.nav-item:hover { color: var(--text); }
.nav-item.active { border-left-color: var(--accent); color: var(--text); background: linear-gradient(90deg, rgba(231,162,46,.09), transparent); }
.sidebar-foot { margin-top: auto; padding: 18px 22px 24px; border-top: 1px solid var(--line-soft); }
.connection-indicator { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; color: var(--muted); font-size: 11px; }
.connection-indicator i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(231,162,46,.08); }
.connection-indicator i.live { background: var(--green); animation: pulse 2.2s infinite; }
.text-button { padding: 0; border: 0; background: transparent; color: #c4c4c1; font-size: 11px; }

.workspace { grid-column: 2; min-width: 0; padding: 0 42px 60px; }
.topbar { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between; min-height: 84px; border-bottom: 1px solid var(--line); background: rgba(13,14,15,.94); backdrop-filter: blur(14px); }
.topbar h2 { margin: 0; font: 400 25px Georgia, serif; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.freshness { margin-right: 8px; color: var(--muted); font-size: 11px; }
.view { display: none; padding-top: 30px; animation: viewIn 260ms ease both; }
.view.active { display: block; }

.system-strip { display: grid; grid-template-columns: minmax(260px, .9fr) 2fr; min-height: 138px; border-bottom: 1px solid var(--line); }
.primary-status { display: flex; align-items: center; gap: 20px; padding-bottom: 30px; }
.primary-status p { margin: 0 0 5px; color: var(--muted); font-size: 11px; }
.primary-status strong { display: block; font: 400 26px Georgia, serif; }
.primary-status small { display: block; margin-top: 5px; color: var(--faint); }
.status-orbit { display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid #3a3020; border-radius: 50%; }
.status-orbit span { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 22px rgba(227,108,100,.35); }
.status-orbit.online { border-color: #244d3b; }
.status-orbit.online span { background: var(--green); box-shadow: 0 0 22px rgba(79,193,138,.35); animation: pulse 2.2s infinite; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; }
.metrics div { padding: 27px 20px; border-left: 1px solid var(--line-soft); }
.metrics dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.metrics dd { margin: 15px 0 0; font: 400 30px Georgia, serif; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 38px 0 18px; }
.section-heading.compact { margin-top: 0; }
.section-heading h3 { margin: 0; font: 400 22px Georgia, serif; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.topology { min-height: 126px; display: flex; align-items: stretch; gap: 1px; background: var(--line-soft); border-block: 1px solid var(--line-soft); }
.topology-node { position: relative; flex: 1; min-width: 150px; padding: 22px; background: var(--surface); transition: background 160ms; }
.topology-node:hover { background: var(--surface-2); }
.topology-node small, .topology-node span { display: block; }
.topology-node small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.topology-node strong { display: block; margin: 13px 0 5px; font-size: 14px; }
.topology-node span { color: var(--faint); font-size: 11px; }
.topology-node::after { content: ""; position: absolute; top: 22px; right: 22px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.topology-node.online::after { background: var(--green); }
.split-section { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 42px; }
.plain-list { border-top: 1px solid var(--line); }
.plain-row { display: flex; align-items: center; justify-content: space-between; min-height: 58px; border-bottom: 1px solid var(--line-soft); }
.plain-row > div { display: grid; gap: 5px; }
.plain-row strong { font-size: 12px; }
.plain-row span { color: var(--muted); font-size: 11px; }
.side-value { font: 400 18px Georgia, serif !important; color: var(--text) !important; }
.side-value.long { color: var(--green) !important; }
.side-value.short { color: var(--red) !important; }

.table-tools { display: flex; gap: 8px; width: min(520px, 55%); }
.table-tools input { flex: 1; }
.table-tools select { width: 150px; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 9px; text-align: left; text-transform: uppercase; letter-spacing: .12em; }
td { padding: 15px 14px; border-bottom: 1px solid var(--line-soft); color: #cbcaca; font-size: 12px; }
tbody tr { transition: background 140ms; }
tbody tr:hover { background: #121517; }
td strong { display: block; color: var(--text); margin-bottom: 4px; }
td small { color: var(--faint); }
.state { display: inline-flex; align-items: center; gap: 7px; }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.state.online::before { background: var(--green); }
.state.warn::before { background: var(--accent); }
.position.long { color: var(--green); }
.position.short { color: var(--red); }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.row-action { padding: 5px 8px; border: 1px solid var(--line); border-radius: 3px; background: transparent; color: var(--muted); font-size: 10px; }
.row-action:hover { color: var(--text); border-color: var(--faint); }
.empty-table { padding: 50px 0; color: var(--muted); text-align: center; }

.device-lines { border-top: 1px solid var(--line); }
.device-line { display: grid; grid-template-columns: 1.2fr .8fr .8fr .8fr auto; align-items: center; gap: 20px; padding: 20px 8px; border-bottom: 1px solid var(--line-soft); }
.device-line strong, .device-line small { display: block; }
.device-line small { margin-top: 5px; color: var(--faint); }
.device-line > span { color: var(--muted); font-size: 11px; }
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.activity-grid h4 { margin: 0 0 15px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.timeline { border-top: 1px solid var(--line); }
.timeline-item { display: grid; grid-template-columns: 82px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.timeline-item time { color: var(--faint); font: 10px ui-monospace, monospace; }
.timeline-item strong { display: block; margin-bottom: 5px; font-size: 12px; }
.timeline-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; word-break: break-word; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.42); backdrop-filter: blur(2px); }
.drawer { position: fixed; z-index: 31; inset: 0 0 0 auto; width: min(460px, 100%); transform: translateX(102%); border-left: 1px solid var(--line); background: var(--surface); transition: transform 260ms cubic-bezier(.2,.8,.2,1); box-shadow: -20px 0 80px rgba(0,0,0,.35); }
.drawer.open { transform: translateX(0); }
.drawer header { display: flex; align-items: center; justify-content: space-between; height: 84px; padding: 0 25px; border-bottom: 1px solid var(--line); }
.drawer h3 { margin: 0; font: 400 22px Georgia, serif; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--text); font-size: 22px; }
.drawer-body { padding: 25px; overflow: auto; max-height: calc(100svh - 84px); }
.drawer-section { padding: 18px 0 24px; border-bottom: 1px solid var(--line); }
.drawer-section:first-child { padding-top: 0; }
.drawer-section h4 { margin: 0 0 17px; font-size: 12px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 24px; }
.enrollment-code { padding: 20px; border: 1px solid #5c4723; background: var(--accent-dark); color: #f3c878; font: 17px ui-monospace, monospace; word-break: break-all; }
.help { color: var(--muted); font-size: 11px; line-height: 1.6; }

dialog { width: min(430px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0,0,0,.64); backdrop-filter: blur(3px); }
dialog form { padding: 12px; }
dialog h3 { margin: 0 0 12px; font: 400 25px Georgia, serif; }
dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 28px; }
.toast-region { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 13px 15px; border: 1px solid var(--line); background: #171a1c; box-shadow: 0 12px 40px rgba(0,0,0,.4); color: #d7d6d2; font-size: 12px; animation: toastIn 220ms ease both; }
.toast.error { border-color: #663b37; }

@keyframes markIn { from { opacity: 0; transform: translateY(4%) scale(.94); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } }
@keyframes appIn { from { opacity: 0; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(7px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(79,193,138,.07); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 900px) {
  :root { --sidebar: 72px; }
  .brand { padding: 0 19px; }
  .brand > span:last-child, .nav-item:not(.active) { }
  .brand b, .brand small, .nav-item { font-size: 0; }
  .nav-item span { font-size: 10px; }
  .nav-item { justify-content: center; padding: 15px 10px; }
  .sidebar-foot { padding-inline: 14px; }
  .connection-indicator span, .text-button { font-size: 0; }
  .workspace { padding-inline: 24px; }
  .system-strip { grid-template-columns: 1fr; }
  .metrics { border-top: 1px solid var(--line-soft); }
  .metrics div:first-child { border-left: 0; }
  .split-section, .activity-grid { grid-template-columns: 1fr; }
  .device-line { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-mark { display: none; }
  .topbar { align-items: flex-start; padding: 20px 0; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .freshness { width: 100%; text-align: right; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line-soft); }
  .metrics div:nth-child(4) { border-top: 1px solid var(--line-soft); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .table-tools { width: 100%; }
  .topology { overflow-x: auto; }
  .topology-node { min-width: 180px; }
  .field-grid { grid-template-columns: 1fr; }
}

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