:root {
  color-scheme: dark;
  --bg: #0c1421;
  --nav: #0e1929;
  --surface: #142237;
  --hover: #1b2e46;
  --stroke: #30425a;
  --text: #f0f5fc;
  --muted: #a7b9d1;
  --accent: #6de0ed;
  --accent-dark: #143747;
  --warning: #ffcd8d;
  --danger: #ffc1c4;
  --ok: #8fe6b4;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--bg); min-height: 100vh; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.topbar {
  min-height: 72px; padding: 12px clamp(1rem, 3vw, 2.5rem); background: var(--nav);
  border-bottom: 1px solid var(--stroke); display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .75rem; font-size: 1.3rem; font-weight: 720; }
.brand-accent { color: var(--accent); }
.brand-mark {
  display: flex; gap: 3px; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: var(--accent-dark); border-radius: 9px;
}
.brand-mark i { width: 3px; height: 11px; border-radius: 3px; background: var(--accent); transform: rotate(20deg); }
.brand-mark i:nth-child(2) { height: 17px; }
.brand-product { border-left: 1px solid var(--stroke); padding-left: .75rem; color: var(--muted); font-size: .92rem; font-weight: 550; }
.account { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.button {
  padding: .55rem .85rem; min-height: 42px; border: 1px solid transparent;
  border-radius: .55rem; font-weight: 650; color: var(--text); white-space: nowrap;
}
.button:disabled { opacity: .65; cursor: wait; }
.secondary { background: var(--surface); border-color: var(--stroke); }
.secondary:hover { background: var(--hover); }
.primary { background: var(--accent); color: #0b2632; }
.primary:hover { background: #98e9f2; }
input {
  width: 100%; padding: .65rem .75rem; min-height: 44px; border-radius: .55rem; border: 1px solid var(--stroke);
  background: #101d2e; color: var(--text);
}
input::placeholder { color: var(--muted); opacity: .9; }
label { display: block; font-size: .875rem; color: var(--muted); margin: 0 0 .35rem; }
.welcome-state { padding: 2.5rem clamp(1rem, 4vw, 3rem); color: var(--muted); }
.login-view {
  min-height: calc(100vh - 72px); display: grid; align-items: start; justify-items: center;
  padding: clamp(2rem, 10vh, 7rem) 1rem 2rem;
  background: radial-gradient(ellipse at 50% 0, #122d42 0%, transparent 58%);
}
.login-card {
  width: min(100%, 440px); background: var(--surface); border: 1px solid var(--stroke);
  border-radius: 1rem; padding: clamp(1.25rem, 6vw, 2.25rem);
}
.login-card h1 { font-size: clamp(1.55rem, 6vw, 2rem); margin-bottom: .45rem; line-height: 1.15; }
.login-card > p { color: var(--muted); margin-bottom: 1.75rem; }
#login-form input { margin-bottom: 1.1rem; }
#login-form .button { width: 100%; margin-top: .25rem; }
.error { color: var(--danger); padding: .65rem .75rem; background: #3a202d; border-radius: .5rem; overflow-wrap: anywhere; }
#login-error { margin-top: .9rem; }
.shell { max-width: 1540px; margin: auto; display: grid; grid-template-columns: minmax(255px, 320px) minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { padding: clamp(1rem, 2.5vw, 1.8rem) 1.1rem; border-right: 1px solid var(--stroke); }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.sidebar h1 { font-size: 1.2rem; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .875rem; }
#device-list { display: grid; gap: .25rem; overflow: auto; max-height: max(250px, calc(100vh - 234px)); margin-top: .6rem; padding: 4px; }
.device-button {
  display: grid; gap: .1rem; text-align: left; width: 100%; padding: .65rem .7rem;
  background: transparent; border: 1px solid transparent; border-radius: .55rem; color: var(--text);
}
.device-button:hover { background: var(--hover); }
.device-button[aria-current="true"] { background: var(--accent-dark); border-color: #427083; }
.device-button span { overflow-wrap: anywhere; min-width: 0; }
.device-button span:first-child { font-weight: 650; }
.device-button span:last-child { color: var(--muted); font-size: .8125rem; }
#list-state:not(:empty) { margin-top: .6rem; }
.workspace { padding: clamp(1rem, 3vw, 2.25rem); min-width: 0; }
.device-header { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.device-heading { min-width: 0; overflow-wrap: anywhere; }
.device-heading h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); line-height: 1.16; margin-bottom: .35rem; }
.empty { padding: 1.25rem 0; color: var(--muted); }
.muted { color: var(--muted); }
#detail-state:not(:empty), #page-error { margin-bottom: 1rem; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 242px), 1fr)); gap: .85rem; }
.panel {
  background: var(--surface); border: 1px solid var(--stroke); border-radius: .85rem;
  padding: 1rem; min-width: 0;
}
.panel h3 { font-size: 1.06rem; margin-bottom: .65rem; }
.badge { display: inline-flex; background: var(--accent-dark); color: var(--accent); border-radius: .35rem; padding: .16rem .45rem; font-size: .8125rem; font-weight: 650; }
.badge[data-tone="warning"] { background: #3a3027; color: var(--warning); }
.badge[data-tone="error"] { background: #3a202d; color: var(--danger); }
.badge[data-tone="ok"] { background: #203b39; color: var(--ok); }
dl { margin: .55rem 0 0; }
dl div { display: grid; gap: .075rem; padding: .48rem 0; }
dl div + div { border-top: 1px solid var(--stroke); }
dt { color: var(--muted); font-size: .875rem; }
dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.errors-panel { margin-top: .85rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; text-align: left; border-collapse: collapse; }
th, td { padding: .55rem .65rem .55rem 0; border-top: 1px solid var(--stroke); vertical-align: top; }
th { color: var(--muted); font-size: .875rem; font-weight: 600; }
td { font-size: .875rem; }
td:first-child, td:nth-child(3) { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--stroke); }
  #device-list { max-height: 208px; }
  .topbar { gap: .5rem; }
  .account { row-gap: .35rem; }
}
