:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-2: #1b1f26;
  --line: #2a3038;
  --text: #f1f4f8;
  --muted: #8d96a3;
  --accent: #7cc7a1;
  --accent-strong: #45b47f;
  --danger: #f07178;
  --shadow: rgba(0, 0, 0, 0.28);
}

:root.light {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #dce1e7;
  --text: #171b21;
  --muted: #66717f;
  --accent: #24785a;
  --accent-strong: #176849;
  --danger: #c94545;
  --shadow: rgba(35, 45, 60, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }

button, input, textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6d8cff);
  display: inline-block;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); margin-top: 2px; }

.nav {
  display: grid;
  gap: 6px;
}

.nav a {
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 7px;
}

.nav a:hover { background: var(--surface-2); color: var(--text); }

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.main {
  padding: 30px;
  max-width: 1480px;
  width: 100%;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow, .muted, small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.15; }
h2 { margin-bottom: 16px; font-size: 16px; }
h3 { margin-bottom: 5px; font-size: 15px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics div, .panel, .device {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px var(--shadow);
}

.metrics div { padding: 16px; }
.metrics span { display: block; font-size: 22px; font-weight: 700; }

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.panel { padding: 18px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.search input { min-width: 240px; }

.table { display: grid; }
.row {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) 1fr 120px 140px;
  gap: 14px;
  align-items: center;
  padding: 13px 10px;
  border-top: 1px solid var(--line);
}
.row:hover:not(.table-head) { background: var(--surface-2); }
.table-head { color: var(--muted); font-size: 12px; font-weight: 700; }
.row strong, .row small { display: block; }
.row small { margin-top: 3px; }

.form-stack {
  display: grid;
  gap: 14px;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.help-text {
  color: var(--muted);
  margin: -4px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.check-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 0 12px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.check-row span {
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 7px;
  padding: 10px 11px;
  outline: none;
}

input:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

input:focus, textarea:focus {
  border-color: var(--accent);
}

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .theme-btn, .icon-btn {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 38px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.primary-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #08120d;
  font-weight: 700;
}

.secondary-btn:hover, .ghost-btn:hover, .theme-btn:hover, .icon-btn:hover {
  border-color: var(--accent);
}

.danger-btn {
  color: var(--danger);
}

.back-link {
  display: inline-block;
  color: var(--muted);
  margin-bottom: 10px;
}

.head-actions {
  display: flex;
  gap: 8px;
}

.pill, .status {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface);
}

.status.active { color: var(--accent); }
.status.disabled { color: var(--danger); }

.device-list {
  display: grid;
  gap: 12px;
}

.device { padding: 16px; box-shadow: none; }
.device-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.device-main p { color: var(--muted); margin-bottom: 0; }

.device-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 15px 0;
}
.device-metrics span {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--surface-2);
}
.device-metrics small { display: block; margin-bottom: 4px; }

.link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  margin: -2px 0 14px;
}

.progress span {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--accent);
}

.copy-stack {
  display: grid;
  gap: 8px;
}

.copy-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 7px;
  padding: 10px;
}

.copy-row.compact {
  background: transparent;
}

.copy-row strong, .copy-row small {
  display: block;
}

.copy-row small {
  margin-top: 3px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  padding: 30px 10px;
  text-align: center;
  border-top: 1px solid var(--line);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-brand { margin-bottom: 24px; }
.form-error { color: var(--danger); margin: 0; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .work-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row { grid-template-columns: 1fr; }
}
