:root {
  color-scheme: dark;
  --bg: #0e1512;
  --surface: #151f1a;
  --surface-raised: #1b2822;
  --surface-soft: #111a16;
  --line: #314139;
  --text: #e1e9e4;
  --muted: #93a49b;
  --accent: #8ab39a;
  --accent-strong: #b7d2c1;
  --warning: #c7ad72;
  --danger: #d08e86;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 15% -20%, #1b2c24 0, transparent 34rem), var(--bg);
  color: var(--text);
  font: 16px/1.55 Inter, "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button {
  min-height: 46px;
  padding: .7rem 1.1rem;
  border: 1px solid #91b6a0;
  border-radius: .65rem;
  background: var(--accent);
  color: #102018;
  font-weight: 750;
  cursor: pointer;
}
button:hover { filter: brightness(1.07); }
button:disabled { cursor: wait; opacity: .55; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: transparent; border-color: var(--danger); color: #e1aaa4; }
button.compact { min-height: 36px; padding: .35rem .7rem; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #d5dfda;
  outline-offset: 3px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.3rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: #111a16e8;
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 680; }
.eyebrow { margin: 0 0 .25rem; color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .16em; }
.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .75rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: #0e1512f2;
  scrollbar-width: thin;
}
.tabs a {
  padding: .58rem .85rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { background: var(--surface-raised); color: var(--text); }
.tabs a.active { border-color: #456052; background: #203129; color: var(--accent-strong); }

main { width: min(1560px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.4rem); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.page-heading h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.15rem); font-weight: 680; }
.page-heading p:last-child { margin: .35rem 0 0; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: .8rem; margin-bottom: 1rem; }
.metric, .panel { border: 1px solid var(--line); border-radius: .85rem; background: linear-gradient(150deg, var(--surface-raised), var(--surface)); }
.metric { padding: 1rem; }
.metric strong { display: block; color: var(--accent-strong); font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 650; }
.metric span, .hint, .status-line { color: var(--muted); }
.panel { margin-bottom: 1rem; padding: 1rem; }
.panel h3 { margin: 0 0 .8rem; color: #cad7d0; font-size: 1.08rem; font-weight: 650; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.panel-heading h3 { margin: 0; }
.panel-heading span { color: var(--muted); font-size: .86rem; }
.panel-heading a { color: var(--accent); text-decoration: none; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.forms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.forms-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split-layout { display: grid; grid-template-columns: minmax(270px, 360px) minmax(0, 1fr); gap: 1rem; }
.compact-form { align-self: start; }
.narrow-panel { max-width: 980px; }
form { display: grid; gap: .75rem; }
label { display: grid; gap: .32rem; color: var(--muted); font-size: .9rem; }
input, select {
  min-height: 44px;
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--surface-soft);
  color: var(--text);
}
.settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.settings-grid button { justify-self: start; min-width: 150px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .72rem; border-bottom: 1px solid #2b3832; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .78rem; font-weight: 650; }
td { color: #d2dad6; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { padding: 2rem; color: var(--muted); text-align: center; }
.status-badge { display: inline-block; padding: .15rem .45rem; border-radius: 999px; background: #26332d; font-size: .82rem; }
.status-online, .status-active, .status-available { color: #a8cfb7; }
.status-waiting, .status-unused { color: var(--warning); }
.status-offline, .status-expired, .status-disabled, .status-released { color: var(--danger); }
.status-line { margin: .25rem 0 0; font-size: .84rem; }
.error { color: #e0a09a !important; }

.login-page { display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(460px, 100%); padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.login-card h1 { margin: 0; }
.login-card p { color: var(--muted); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .overview-grid, .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .forms-grid.two-columns, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; padding: 1rem; }
  main { padding: .8rem; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .page-heading { align-items: flex-start; }
}
@media (min-width: 1800px) {
  body { font-size: 18px; }
  button { min-height: 52px; }
}
