:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --text: #17211f;
  --muted: #66736f;
  --line: #dfe7e4;
  --line-strong: #c9d4d0;
  --accent: #0f8f7f;
  --accent-dark: #087366;
  --accent-soft: #dff5f0;
  --amber: #c47a14;
  --amber-soft: #fff1d8;
  --red: #c24a4a;
  --red-soft: #ffe5e5;
  --blue: #336fbd;
  --blue-soft: #e7f0ff;
  --shadow: 0 16px 42px rgba(33, 45, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: #13221f;
  color: #f3fbf8;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  border-radius: 8px;
  background: #20b99f;
  color: #05241f;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.brand strong,
.auth-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand small,
.auth-brand span {
  display: block;
  margin-top: 3px;
  color: rgba(243, 251, 248, 0.64);
  font-size: 12px;
}

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

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: rgba(243, 251, 248, 0.72);
  text-align: left;
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: currentColor;
}

.icon svg,
.topbar svg,
.icon-button svg,
.search-box svg {
  width: 18px;
  height: 18px;
}

.icon path,
.topbar path,
.icon-button path,
.search-box path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item .icon path,
.brand-mark + span path {
  fill: currentColor;
  stroke: none;
}

.sidebar-status {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(243, 251, 248, 0.66);
  font-size: 12px;
}

.sidebar-status strong {
  display: block;
  margin-top: 6px;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 127, 0.13);
}

select {
  height: 38px;
  padding: 0 10px;
}

.search-box {
  width: 260px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  height: 34px;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 318px;
  gap: 18px;
}

.main-column {
  min-width: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(138px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.surface,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 94px;
  padding: 15px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

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

.surface {
  overflow: hidden;
}

.surface-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.surface-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.surface-head p,
.table-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-wrap {
  padding: 14px 16px 18px;
}

.line-chart {
  width: 100%;
  height: 220px;
}

.line-chart .grid-line {
  stroke: #e7eeeb;
  stroke-width: 1;
}

.line-chart .series-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.line-chart .series-area {
  fill: rgba(15, 143, 127, 0.1);
}

.line-chart text {
  fill: var(--muted);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #fbfcfc;
  font-size: 12px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.is-warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.is-danger {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.is-ok {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.thumb {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.thumb.is-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.side-panel {
  position: sticky;
  top: 22px;
  align-self: start;
  padding: 16px;
}

.panel-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.panel-head strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
  word-break: break-all;
}

.recharge-form {
  display: grid;
  gap: 13px;
  margin-top: 14px;
}

.recharge-form label,
.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.recharge-form input,
.recharge-form textarea,
.auth-card input {
  width: 100%;
  padding: 10px 11px;
  font-size: 14px;
}

.recharge-form textarea {
  resize: vertical;
}

.primary-button,
.text-button {
  height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.text-button {
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.text-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.action-message,
.auth-error {
  min-height: 18px;
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(13, 24, 22, 0.58);
  backdrop-filter: blur(12px);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.auth-brand {
  padding-bottom: 4px;
}

.auth-brand span {
  color: var(--muted);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .console-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    justify-content: center;
    min-width: 112px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .search-box {
    width: min(100%, 360px);
  }

  .metrics-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }
}
