:root {
  --ink: #172033;
  --muted: #6b768d;
  --line: #e3e8f0;
  --soft: #f5f7fb;
  --white: #fff;
  --teal: #087f73;
  --teal-dark: #05665d;
  --teal-soft: #e7f6f3;
  --red: #b42318;
  --red-soft: #fff0ee;
  --amber: #9a6700;
  --amber-soft: #fff7d6;
  --shadow: 0 18px 45px rgba(25, 38, 63, .09);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--soft); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: linear-gradient(145deg, var(--teal), #2a65c7); font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #dff5f0, transparent 33%), radial-gradient(circle at 90% 80%, #e4ecff, transparent 36%), #f7f8fb; }
.login-card { width: min(460px, 100%); padding: 30px; border: 1px solid rgba(255,255,255,.8); border-radius: 24px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.login-copy { margin: 38px 0 24px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 30px; letter-spacing: -.03em; }
h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.02em; }
.login-copy p, .section-head p { margin: 10px 0 0; color: var(--muted); line-height: 1.55; font-size: 13px; }
.form-stack { display: grid; gap: 15px; }
.form-stack label > span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: var(--white); color: var(--ink); transition: border .15s, box-shadow .15s; }
input, select { min-height: 44px; padding: 0 12px; }
textarea { min-height: 82px; padding: 11px 12px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(8,127,115,.65); box-shadow: 0 0 0 3px rgba(8,127,115,.1); }
.button { min-height: 42px; padding: 0 15px; border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; transition: transform .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button.primary { color: #fff; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
code { padding: 2px 5px; border-radius: 5px; background: var(--soft); }
.error { margin: 0; padding: 10px 12px; border: 1px solid #ffd0ca; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fff; }
.sidebar .brand { padding: 0 8px 24px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 43px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font-weight: 750; }
.nav-item span { width: 20px; color: #8d98ab; font-size: 18px; }
.nav-item:hover { background: var(--soft); }
.nav-item.active { color: #fff; background: var(--ink); }
.nav-item.active span { color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 5px; padding-top: 20px; border-top: 1px solid var(--line); }
.sidebar-foot a, .sidebar-foot button { padding: 9px 11px; border: 0; color: var(--muted); background: transparent; text-align: left; text-decoration: none; cursor: pointer; font-size: 12px; font-weight: 700; }
.sidebar-foot a:hover, .sidebar-foot button:hover { color: var(--ink); }

.main { min-width: 0; padding: 30px clamp(18px, 3vw, 44px) 50px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.admin-badge { max-width: 260px; overflow: hidden; text-overflow: ellipsis; padding: 9px 12px; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); white-space: nowrap; font-size: 12px; font-weight: 750; }
.panel { display: none; }
.panel.active { display: block; animation: reveal .2s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card, .card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 6px 25px rgba(25,38,63,.035); }
.stat-card { padding: 19px; }
.stat-card .label { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card .value { margin: 16px 0 6px; font-size: 27px; font-weight: 850; letter-spacing: -.03em; }
.stat-card .note { color: var(--muted); font-size: 11px; }
.stat-card .icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--teal); background: var(--teal-soft); }
.content-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 14px; }
.card { padding: 20px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.status-dot { padding: 6px 9px; border-radius: 999px; color: var(--teal-dark); background: var(--teal-soft); font-size: 10px; font-weight: 800; }
.metric-list { display: grid; gap: 2px; }
.metric-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.metric-row:last-child { border-bottom: 0; }
.metric-row strong { color: var(--ink); }
.tariff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tariff { padding: 16px; border-radius: 12px; background: var(--soft); }
.tariff span { color: var(--muted); font-size: 11px; }
.tariff strong { display: block; margin-top: 8px; font-size: 21px; }
.text-button { margin-top: 16px; padding: 0; border: 0; color: var(--teal); background: transparent; cursor: pointer; font-weight: 750; }

.search { width: min(320px, 100%); display: flex; align-items: center; gap: 7px; padding-left: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--soft); }
.search input { min-height: 40px; padding-left: 0; border: 0; background: transparent; box-shadow: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 960px; }
th { padding: 10px 9px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 14px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--ink); font-size: 11px; font-weight: 850; }
.user-cell strong, .user-cell small { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-cell small { margin-top: 3px; color: var(--muted); }
.admin-label { display: inline-block; margin-top: 4px; color: var(--teal); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.balance-input { width: 105px; min-height: 36px; }
.save-balance { min-height: 34px; padding: 0 11px; }
.empty { padding: 30px; color: var(--muted); text-align: center; font-size: 13px; }

.settings-card { padding-bottom: 28px; }
.settings-grid { display: grid; gap: 11px; }
.setting-row { display: grid; grid-template-columns: minmax(220px, .85fr) minmax(260px, 1fr) auto; gap: 18px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
.setting-meta strong { display: block; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.setting-meta p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.setting-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag { padding: 4px 7px; border-radius: 999px; color: var(--muted); background: var(--soft); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.tag.secret { color: var(--amber); background: var(--amber-soft); }
.tag.restart { color: var(--red); background: var(--red-soft); }
.setting-control small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.setting-actions { display: flex; gap: 7px; }
.danger-link { min-height: 36px; padding: 0 9px; border: 0; color: var(--red); background: transparent; cursor: pointer; font-size: 11px; font-weight: 750; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; }
.toast { max-width: 380px; padding: 12px 14px; border-radius: 11px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-size: 12px; animation: reveal .2s ease; }
.toast.error { background: var(--red); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 10px; }
  .setting-actions { justify-content: flex-end; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand, .sidebar-foot { display: none; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item { justify-content: center; padding: 0 8px; font-size: 11px; }
  .nav-item span { display: none; }
  .main { padding: 20px 14px 35px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .admin-badge { max-width: 150px; }
  .stats-grid { grid-template-columns: 1fr; }
  .section-head.responsive { flex-direction: column; }
  .search { width: 100%; }
  .login-card { padding: 22px; }
}
