:root {
  --bg: #fafafa;
  --card: #ffffff;
  --raised: #f4f4f5;
  --ink: #171717;
  --secondary: #525252;
  --muted: #737373;
  --line: rgba(23, 23, 23, 0.08);
  --red: #d93a32;
  --red-deep: #b42318;
  --red-soft: #f4f4f5;
  --navy: #171717;
  --ok: #16a34a;
  --bar: #e4e4e7;
  --side: 248px;
  --radius: 16px;
  --sans: Manrope, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.dash-body {
  font: 400 15px/22px var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.dash-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.dash-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
}
.dash-brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 500; letter-spacing: 0; font-size: 16px;
}
.dash-mark {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--red); color: #fff; font-weight: 500; font-size: 14px;
}
.dash-brand small { display: block; font-weight: 400; color: var(--muted); letter-spacing: 0; font-size: 12px; line-height: 16px; }
.dash-card h1 { margin: 24px 0 8px; font-size: 28px; font-weight: 500; letter-spacing: 0; line-height: 1.15; }
.dash-card .lede, .dash-note { margin: 0; color: var(--secondary); font-weight: 400; }
.dash-tabs { display: flex; gap: 8px; margin: 20px 0 4px; }
.dash-tabs button, .choice {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; min-height: 36px; padding: 0 12px; font-weight: 500;
}
.dash-tabs button[aria-pressed="true"], .choice[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.dash-form, .auth-form { display: grid; gap: 12px; margin-top: 16px; }
.dash-form label, .auth-form label { display: grid; gap: 8px; font-weight: 500; font-size: 13px; }
.dash-form .auth-remember { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.dash-form .auth-remember input { width: 16px; height: 16px; accent-color: var(--red); }
.dash-form input, .dash-form select, .auth-form input, .auth-form select, .search-input {
  height: 40px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); padding: 0 12px; color: var(--ink);
}
.dash-go, .btn-primary, .auth-go {
  height: 40px; border: 0; border-radius: 8px;
  background: var(--red); color: #fff; font-weight: 500;
  transition: background-color 160ms var(--ease);
}
.dash-go:hover, .btn-primary:hover, .auth-go:hover { background: var(--red-deep); }
.login-error, .status { min-height: 20px; margin: 8px 0 0; font-weight: 500; color: var(--red); }
.auth-or {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  margin: 8px 0; color: var(--muted); font-size: 13px; font-weight: 400;
}
.auth-or::before, .auth-or::after { content: ""; height: 1px; background: var(--line); }
.auth-social { display: grid; gap: 8px; }
.social {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); font-weight: 500;
}
.social svg { width: 16px; height: 16px; }
.social-apple { background: var(--ink); color: #fff; border-color: var(--ink); }

.dash-shell { min-height: 100vh; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.dash-side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 16px 12px;
  background: var(--card);
  border-right: 1px solid var(--line);
}
.dash-side nav { display: grid; gap: 2px; }
.side-label {
  margin: 24px 10px 8px;
  font-size: 12px; line-height: 16px; letter-spacing: 0; font-weight: 500;
  text-transform: none; color: var(--muted);
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--secondary); font-weight: 500; font-size: 14px; text-align: left;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.nav-item svg { flex: none; width: 16px; height: 16px; stroke-width: 1.5; }
.nav-item:hover { background: var(--raised); color: var(--ink); }
.nav-item.is-active {
  background: var(--raised);
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--red);
}
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.foot-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 36px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card);
  font: 500 13px/16px var(--sans); color: var(--ink); text-decoration: none; cursor: pointer;
  transition: background-color 160ms var(--ease);
}
.foot-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.foot-site { background: var(--card); }
.foot-out { background: transparent; color: var(--secondary); border-color: transparent; }
.foot-btn:hover { background: var(--raised); }
.note-count {
  margin-left: auto; min-width: 0; height: auto; padding: 0;
  border-radius: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.pay-now {
  margin-top: 24px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px;
}
.pay-now strong { display: block; margin: 8px 0; font-size: 32px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pay-actions { display: grid; gap: 8px; min-width: min(100%, 280px); }
.dash-go.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.dash-go.ghost:hover { background: var(--raised); color: var(--ink); }
.order-list, .note-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.order-list li, .note-list li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.note-list li.is-new { box-shadow: inset 2px 0 0 var(--red); }
.order-list strong, .note-list strong { display: block; font-weight: 500; }
.order-list span, .note-list span { color: var(--muted); font-size: 13px; }
.dash-main { min-width: 0; padding: 0 32px 48px; }
.dash-top { display: flex; align-items: center; gap: 12px; min-height: 56px; margin-bottom: 24px; }
.dash-top h1 { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: 0; }
.top-gap { margin-left: auto; }
.icon-btn, .btn-ghost {
  min-height: 36px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); font-weight: 500; color: var(--ink);
  transition: background-color 160ms var(--ease);
}
.icon-btn { width: 36px; padding: 0; display: none; place-items: center; }
.btn-ghost:hover, .icon-btn:hover { background: var(--raised); }
.admin-topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; margin: 0 -32px 24px; padding: 0 32px;
  background: rgba(250, 250, 250, 0.92);
  border-bottom: 1px solid var(--line);
}
.topbar-title { margin: 0; font-size: 15px; font-weight: 500; letter-spacing: 0; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.admin-content { max-width: 1440px; }
.page-head h2 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: 0; line-height: 1.15; }
.page-head p { margin: 8px 0 0; color: var(--secondary); max-width: 62ch; font-weight: 400; }
.page { display: none; }
.page.is-visible { display: block; }
.shield-frame {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.metrics, .chart-grid { display: grid; gap: 16px; margin-top: 24px; }
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-grid { grid-template-columns: 1.4fr 0.8fr; }
.metric, .panel, .chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: none;
  padding: 20px;
}
.metric header, .panel-head, .chart-card header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.metric header span, .chart-card header span, .metric-label { color: var(--muted); font-weight: 400; font-size: 13px; }
.metric strong, .metric-value {
  display: block; margin: 12px 0 4px;
  font-size: 32px; line-height: 1; letter-spacing: -0.02em; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.metric:nth-child(2) strong { color: var(--red); }
.metric-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 20px; font-weight: 400; }
.spark { display: none; }
.metric-foot, .delta { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 400; }
.delta b { color: var(--ok); font-weight: 500; }
.hbar { display: grid; gap: 12px; margin-top: 20px; }
.hbar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; font-weight: 400; font-size: 14px; }
.hbar-row span:last-child { font-variant-numeric: tabular-nums; color: var(--secondary); min-width: 24px; text-align: right; }
.hbar-track { height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; border-radius: 2px; background: var(--bar); }
.hbar-row.is-lead .hbar-track span { background: var(--red); }
.vbars { display: flex; align-items: flex-end; gap: 16px; height: 160px; margin-top: 20px; }
.vbars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.vbars i { display: block; width: 100%; max-width: 28px; border-radius: 4px 4px 2px 2px; background: var(--bar); }
.vbars .is-lead i { background: var(--red); }
.vbars span { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted); text-align: center; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel-head h3, .chart-card h3 { margin: 8px 0 0; font-size: 16px; font-weight: 500; letter-spacing: 0; }
.panel-link { border: 0; background: none; color: var(--secondary); font-weight: 500; font-size: 13px; }
.panel-link:hover { color: var(--ink); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th { text-align: left; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); padding: 8px; }
.data-table td { padding: 12px 8px; border-top: 1px solid var(--line); }
.data-table tbody tr:hover td { background: var(--bg); }
.badge { display: inline-flex; border-radius: 0; padding: 0; background: none; font-size: 13px; font-weight: 400; color: var(--secondary); }
.badge.admin { background: none; color: var(--red); }
.toolbar { display: flex; gap: 12px; align-items: center; margin: 16px 0; }
.search-input { flex: 1; background: var(--card); }
.toolbar-meta { color: var(--muted); font-weight: 400; font-size: 13px; font-variant-numeric: tabular-nums; }
.device-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.device-list li {
  display: grid; grid-template-columns: 36px 1fr auto auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.device-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--raised); display: grid; place-items: center; }
.device-mark svg { width: 16px; height: 16px; fill: var(--ink); }
.device-list code { font-weight: 500; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.device-list button { border: 0; background: transparent; color: var(--red); border-radius: 8px; min-height: 32px; padding: 0 8px; font-weight: 500; }
.device-form { grid-template-columns: 1.4fr 0.8fr auto; align-items: end; }
.cabinet-plan {
  margin-top: 16px; display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.empty { color: var(--muted); }

@media (max-width: 980px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-side {
    position: fixed; z-index: 30; transform: translateX(-105%);
    width: min(280px, 88vw); border-radius: 0 16px 16px 0;
    transition: transform 180ms var(--ease); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  }
  .dash-shell.drawer-open .dash-side, .admin-shell.drawer-open .dash-side { transform: none; }
  .icon-btn, .menu-toggle { display: grid; }
  .metrics, .chart-grid, .panel-grid, .device-form { grid-template-columns: 1fr; }
  .dash-main { padding: 0 16px 40px; }
  .admin-topbar { margin: 0 -16px 24px; padding: 0 16px; }
  .sidebar-backdrop { display: none; }
  .drawer-open .sidebar-backdrop, .dash-shell.drawer-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(23, 23, 23, 0.32); z-index: 20;
  }
}
@media (min-width: 981px) {
  .sidebar-backdrop { display: none !important; }
}
