:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0b1830;
  --muted: #64748b;
  --line: #dbe3ee;
  --accent: #d6a72d;
  --accent-strong: #bd8c13;
  --surface-tint: #f1f5f9;
  --sidebar-bg: #07172d;
  --sidebar-muted: #cbd5e1;
  --sidebar-active: #d6a72d;
  --focus: #b77a05;
}

body {
  background:
    radial-gradient(circle at 85% 0%, rgb(214 167 45 / 9%), transparent 25rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea,
.panel,
.table-wrap,
.admin-sidebar,
.login-panel,
.modal {
  border-radius: 0.75rem;
}

button {
  min-height: 42px;
  border-color: var(--line);
  padding: 0.55rem 0.9rem;
  font-weight: 650;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease,
    transform 160ms ease, box-shadow 160ms ease;
}

button:hover {
  border-color: #c2ccd9;
  box-shadow: 0 4px 14px rgb(7 23 45 / 8%);
  transform: translateY(-1px);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #07172d;
}

button.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: #07172d;
}

input,
select,
textarea {
  min-height: 44px;
  border-color: var(--line);
  padding: 10px 12px;
}

.topbar {
  height: 82px;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 30px rgb(7 23 45 / 6%);
  backdrop-filter: blur(14px);
}

.brand-logo {
  height: 86.4px;
}

.brand {
  width: 236px;
  min-width: 236px;
}

.login-logo {
  width: min(83.2px, 100%);
}

.topbar-brand-label {
  color: #475569;
  font-weight: 700;
}

.topbar-mode-switch,
.mode-switch {
  min-height: 42px;
  border-radius: 0.65rem;
  color: var(--ink);
}

.theme-toggle {
  min-height: 42px;
  width: 42px;
  border-color: var(--line);
  color: var(--ink);
}

.login-actions {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
}

.main {
  max-width: 1520px;
  padding: 30px;
}

.admin-main {
  padding-left: 24px;
}

.admin-layout {
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 28px;
}

.admin-sidebar {
  top: 24px;
  max-height: calc(100vh - 130px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 1rem;
  background: linear-gradient(180deg, #0b203d, #061326);
  box-shadow: 0 20px 45px rgb(7 23 45 / 18%);
}

.sidebar-title {
  padding: 18px;
  border-color: rgb(255 255 255 / 10%);
  color: #f4d77c;
  letter-spacing: 0.1em;
}

.tabs {
  gap: 6px;
  padding: 14px;
}

.tab {
  min-height: 46px;
  border-radius: 0.65rem;
  color: #dbe6f4;
  font-weight: 650;
}

.tab:hover {
  background: rgb(255 255 255 / 9%);
  box-shadow: none;
  transform: none;
}

.tab.active {
  background: var(--accent);
  color: #07172d;
  box-shadow: 0 8px 20px rgb(0 0 0 / 18%);
}

.tab-section-title {
  color: #94a3b8;
  letter-spacing: 0.09em;
}

.admin-workspace {
  gap: 22px;
}

.page-toolbar {
  padding: 4px 2px 20px;
}

.toolbar h2 {
  color: var(--ink);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.panel,
.table-wrap,
.login-panel {
  border: 1px solid rgb(219 227 238 / 90%);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 14px 36px rgb(7 23 45 / 7%);
}

.panel {
  padding: 22px;
}

.panel h3 {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 750;
}

th {
  background: #eef3f8;
  color: #334155;
  font-size: 0.72rem;
  letter-spacing: 0.055em;
}

th,
td {
  padding: 13px 14px;
}

tbody tr:hover {
  background: #f8fafc;
}

.badge {
  min-height: 26px;
  padding: 3px 10px;
  font-weight: 700;
}

.user-tabs {
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 10px 30px rgb(7 23 45 / 6%);
}

.user-tabs .tab {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #334155;
}

.user-tabs .tab.active {
  background: var(--sidebar-bg);
  color: #ffffff;
}

.login-wrap {
  background:
    radial-gradient(circle at 50% 15%, rgb(214 167 45 / 16%), transparent 22rem),
    linear-gradient(145deg, #eef3f8, #f8fafc);
}

.login-panel {
  width: min(460px, 100%);
  padding: 34px;
  border-radius: 1.15rem;
}

.modal-backdrop {
  backdrop-filter: blur(5px);
}

.modal {
  border: 1px solid var(--line);
  box-shadow: 0 28px 70px rgb(7 23 45 / 25%);
}

html.dark {
  color-scheme: dark;
  --bg: #061225;
  --panel: #0b1b31;
  --ink: #f8fafc;
  --muted: #a7b4c5;
  --line: #263850;
  --surface-tint: #11243c;
}

html.dark body {
  background:
    radial-gradient(circle at 85% 0%, rgb(214 167 45 / 8%), transparent 25rem),
    var(--bg);
}

html.dark button,
html.dark input,
html.dark select,
html.dark textarea,
html.dark .panel,
html.dark .table-wrap,
html.dark .login-panel,
html.dark .modal,
html.dark .topbar,
html.dark .user-tabs {
  border-color: var(--line);
  background-color: var(--panel);
  color: var(--ink);
}

html.dark .topbar {
  background: rgb(11 27 49 / 94%);
}

html.dark .brand span,
html.dark .toolbar h2,
html.dark .panel h3 {
  color: var(--ink);
}

html.dark th {
  background: #10233b;
  color: #cbd5e1;
}

html.dark tbody tr:hover {
  background: #10233b;
}

html.dark .alert-modal,
html.dark .locate-modal,
html.dark .event-message-modal {
  background: var(--panel) !important;
  color: var(--ink) !important;
}

html.dark .alert-message,
html.dark .locate-result,
html.dark .event-message-detail pre {
  background: #ffffff !important;
  color: #000000 !important;
}

html.dark .alert-message :is(p, span, strong, .muted),
html.dark .locate-result :is(p, span, strong, .muted, .locate-meta),
html.dark .event-message-detail pre {
  color: #000000 !important;
}

html.dark .user-tabs .tab {
  background: transparent;
  color: #dbe6f4;
}

html.dark .user-tabs .tab.active {
  background: var(--accent);
  color: #07172d;
}

html.dark .login-wrap {
  background:
    radial-gradient(circle at 50% 15%, rgb(214 167 45 / 12%), transparent 22rem),
    #061225;
}

@media (max-width: 840px) {
  .topbar {
    height: auto;
    min-height: 112px;
  }

  .brand-logo {
    height: 46.4px;
  }

  .brand {
    width: 127px;
    min-width: 127px;
  }

  .main,
  .admin-main {
    padding: 18px;
  }

  .admin-layout {
    gap: 18px;
  }

  .admin-sidebar {
    border-radius: 0.85rem;
    max-height: none;
    overflow: hidden;
  }
}
