/* LocSim admin — login gate + ops console */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --page-bg: #f4f7fb;
  --page-fg: #18181b;
  --muted: #52525b;
  --subtle: #71717a;
  --sky: #0ea5e9;
  --sky-deep: #0369a1;
  --rose: #e5484d;
  --amber: #d97706;
  --surface: rgba(15, 23, 42, 0.03);
  --border: rgba(15, 23, 42, 0.1);
  --header-bg: rgba(255, 255, 255, 0.84);
  --font: "Inter", "Noto Sans SC", sans-serif;
  --radius: 16px;
}

html, body {
  min-height: 100%;
  background: var(--page-bg);
  color: var(--page-fg);
  font-family: var(--font);
}

body { position: relative; overflow-x: hidden; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  z-index: 0;
}

.glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  right: -8vw;
  top: -12vw;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.16), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

.topbar__nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.nav-link {
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nav-link.is-active {
  background: #fff;
  color: var(--sky-deep);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--sky);
}

.brand__mark svg { width: 100%; height: 100%; }

.brand__name {
  display: block;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand__sub {
  display: block;
  font-size: 12px;
  color: var(--subtle);
}

.topbar__session {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__label {
  display: block;
  font-size: 12px;
  color: var(--subtle);
}

.shell {
  flex: 1;
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

body.mode-console .shell {
  width: min(1180px, calc(100% - 40px));
}

body.mode-login .shell,
body.mode-forbidden .shell {
  align-self: center;
  width: min(480px, calc(100% - 48px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0 64px;
}

.gate {
  display: grid;
  gap: 24px;
}

.gate__intro h1 {
  font-size: clamp(26px, 5vw, 34px);
  letter-spacing: -0.035em;
  line-height: 1.25;
  margin: 8px 0 10px;
}

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sky-deep);
}

.lede,
.panel__head p,
.recharge p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.console-stack {
  display: grid;
  gap: 20px;
}

.module { min-width: 0; }

.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.work-grid.is-split {
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.05fr);
}

.panel {
  background: var(--header-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(16px);
}

.panel__head { margin-bottom: 22px; }

.panel__tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sky-deep);
  margin-bottom: 10px;
}

.panel__tag--warn { color: var(--amber); }

.panel h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.stack { display: grid; gap: 16px; }

.field { display: grid; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.field input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 14px;
  font: inherit;
  color: var(--page-fg);
}

.field input:focus {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  border-color: var(--sky);
}

.otp-row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.field--grow { flex: 1; }

.btn {
  height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 18px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--sky);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: #0284c7; }

.btn--ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--page-fg);
}

.btn--small { height: 36px; font-size: 13px; width: fit-content; }

.status {
  min-height: 1.4em;
  font-size: 13px;
  color: var(--muted);
}

.status.is-error { color: var(--rose); }
.status.is-ok { color: var(--sky-deep); }

.meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.meta dt {
  font-size: 12px;
  color: var(--subtle);
  margin-bottom: 4px;
}

.meta dd {
  font-weight: 650;
  word-break: break-all;
}

.plan {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #fff;
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.plan__top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.plan__name { font-size: 24px; font-weight: 750; letter-spacing: -0.03em; }

.rail__kicker {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 6px;
}

.chip {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.chip.is-expired {
  background: rgba(229, 72, 77, 0.12);
  color: var(--rose);
}

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(229, 72, 77, 0.08);
  color: #9f1239;
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.stats span { display: block; font-size: 12px; color: var(--subtle); }
.stats strong { font-size: 16px; }

.analytics-range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.analytics-range .btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(14, 116, 144, 0.08);
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.summary-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.summary-card span {
  display: block;
  font-size: 12px;
  color: var(--subtle);
  margin-bottom: 8px;
}

.summary-card strong {
  font-size: 28px;
  line-height: 1.1;
}

.analytics-filter {
  margin: 16px 0;
}

.analytics-filter__row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(160px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 900px) {
  .analytics-summary {
    grid-template-columns: 1fr;
  }

  .analytics-filter__row {
    grid-template-columns: 1fr;
  }
}

.recharge {
  display: grid;
  gap: 16px;
  padding-top: 8px;
}

.recharge h3 { font-size: 16px; }

.stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stepper__controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper__value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 76px;
}

.stepper__value strong {
  font-size: 24px;
  line-height: 1;
}

.stepper__value span {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}

.stepper__label {
  font: inherit;
}

.amount-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.amount-input input {
  width: 112px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  color: var(--page-fg);
  appearance: textfield;
}

.amount-input input::-webkit-outer-spin-button,
.amount-input input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.amount-input input:focus {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  border-color: var(--sky);
}

.amount-input span {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}

.confirm-sum {
  margin-top: 8px;
  font-weight: 700;
  color: var(--page-fg);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--page-fg);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn svg { width: 18px; height: 18px; }

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  color: var(--subtle);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tbody tr[data-phone] { cursor: pointer; }

.data-table tbody tr[data-phone]:hover,
.data-table tbody tr.is-active {
  background: rgba(14, 165, 233, 0.08);
}

.data-table tbody tr.is-empty { cursor: default; }

.data-table tbody tr.is-empty td {
  text-align: center;
  color: var(--subtle);
  padding: 22px 10px;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.pager__meta {
  font-size: 13px;
  color: var(--muted);
}

.pager__btns { display: flex; gap: 8px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--sky-deep);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.history {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.panel__head--row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.meta-note {
  font-size: 13px;
  color: var(--subtle);
  white-space: nowrap;
}

.config-form {
  display: grid;
  gap: 20px;
}

.config-section {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  display: grid;
  gap: 14px;
}

.config-section legend {
  padding: 0 6px;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--page-fg);
}

.config-hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.config-hint code,
.panel__head code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface);
}

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

.field--full {
  grid-column: 1 / -1;
}

.field textarea {
  min-height: 84px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  color: var(--page-fg);
  resize: vertical;
  line-height: 1.5;
}

.field textarea:focus {
  outline: 2px solid rgba(14, 165, 233, 0.35);
  border-color: var(--sky);
}

.config-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.42);
  display: grid;
  place-items: end center;
  padding: 24px;
  z-index: 20;
}

.modal[hidden] { display: none; }

.modal__dialog {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 8vh;
}

.modal__dialog h2 { margin-bottom: 10px; }
.modal__dialog p { color: var(--muted); line-height: 1.6; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 860px) {
  .work-grid,
  .work-grid.is-split { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .config-actions { justify-content: stretch; }
  .config-actions .btn { flex: 1; }
  .topbar {
    padding: 14px 16px;
    flex-wrap: wrap;
  }
  .topbar__nav {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
  }
  .nav-link { flex: 1; }
  .shell {
    width: min(calc(100% - 32px), 1080px);
    padding-top: 28px;
  }
  body.mode-login .shell,
  body.mode-forbidden .shell {
    width: min(calc(100% - 32px), 480px);
    padding: 32px 0 48px;
  }
  .otp-row {
    flex-direction: column;
    align-items: stretch;
  }
  .otp-row .btn { width: 100%; }
}
