:root {
  --bg: #0f1214;
  --panel: #181d21;
  --panel-2: #1d2429;
  --panel-3: #222b31;
  --ink: #eef2f3;
  --muted: #98a4aa;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --brand: #8fb2ff;
  --danger: #ff7d7d;
  --success: #8fd6a2;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(143, 178, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #0f1214, #0c0f11 100%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 11px;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell,
.auth-view,
.app-view,
.main,
.panel {
  height: 100%;
}

.auth-view {
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card,
.sidebar,
.panel,
.provider-card,
.user-list-box,
.user-form,
.userbox,
.stat-card,
.restaurant-item,
.user-item {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.auth-hero {
  padding: 20px 20px 14px;
  background: linear-gradient(180deg, #1c2328, #151a1e);
  border-bottom: 1px solid var(--line);
}

.auth-card .stack {
  padding: 16px 20px 20px;
}

h1,
h2,
h3 {
  margin: 0;
  font-size: inherit;
  font-weight: 650;
}

.auth-hero h1,
.brand h1,
.panel-header h2 {
  font-size: 1.2rem;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

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

.lede {
  margin: 8px 0 0;
  font-size: 11px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.hero-tags span,
.state-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

.hero-tags span {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

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

.app-view {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
}

.sidebar {
  border-radius: var(--radius-xl);
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand p:last-child {
  margin: 0;
}

.userbox,
.section-head,
.actions,
.panel-header,
.item-topline,
.toggle,
.top-grid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.userbox,
.stat-card,
.view-switcher button,
.search-field input,
.restaurant-item,
.user-item {
  box-shadow: none;
}

.userbox {
  padding: 10px;
  border-radius: var(--radius-md);
}

.sidebar-section {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.search-field {
  display: grid;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
}

.restaurant-list,
.user-list,
.view-switcher,
.stats-grid {
  display: grid;
  gap: 6px;
}

.restaurant-list {
  min-height: 0;
  overflow: auto;
  padding-right: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.restaurant-list::-webkit-scrollbar {
  display: none;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
  padding: 8px;
  border-radius: var(--radius-md);
}

.stat-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.1rem;
}

.main {
  min-height: 0;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}

.panel-header {
  align-items: flex-start;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.panel-header .muted {
  margin: 4px 0 0;
  font-size: 11px;
}

.form-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: start;
}

.provider-card,
.user-list-box,
.user-form,
.log-list-box,
.log-card,
.log-detail-box {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-lg);
  min-height: 0;
  align-content: start;
}

.provider-card .section-head {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.compact-top {
  padding: 8px;
}

.top-grid {
  align-items: end;
}

.top-grid > label:first-child {
  flex: 1;
}

.toggle-card {
  min-width: 110px;
  padding-top: 0;
  align-self: end;
}

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

.conditional {
  display: grid;
  gap: 6px;
  align-content: start;
}

.sync-card {
  gap: 6px;
}

.compact-copy {
  margin: 0;
  font-size: 10px;
}

label {
  display: grid;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
button {
  min-height: 28px;
  border-radius: var(--radius-sm);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel-3);
  color: var(--ink);
  padding: 5px 8px;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(143, 178, 255, 0.12);
}

button {
  border: 1px solid transparent;
  background: var(--brand);
  color: #0f1214;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: 700;
  appearance: none;
}

button.ghost,
.view-switcher button,
.restaurant-item,
.user-item {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--line);
}

button.ghost.danger {
  color: var(--danger);
  border-color: rgba(255, 125, 125, 0.22);
}

.view-switcher button.active,
.restaurant-item.active,
.user-item.active {
  border-color: rgba(143, 178, 255, 0.38);
  background: rgba(143, 178, 255, 0.12);
}

.restaurant-item,
.user-item {
  text-align: left;
  padding: 9px 11px;
  border-radius: 12px;
  display: grid;
  gap: 4px;
  overflow: visible;
  align-content: start;
}

.restaurant-item {
  min-height: 68px;
}

.item-meta,
.item-route {
  font-size: 10px;
  line-height: 1.35;
}

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

.item-route {
  color: var(--brand);
  white-space: normal;
  overflow-wrap: anywhere;
  min-height: 2.7em;
}

.state-pill {
  color: var(--success);
  background: rgba(143, 214, 162, 0.12);
  border: 1px solid rgba(143, 214, 162, 0.16);
  padding: 2px 7px;
  font-size: 9px;
}

.state-pill.off {
  color: var(--danger);
  background: rgba(255, 125, 125, 0.1);
  border-color: rgba(255, 125, 125, 0.14);
}

.toggle input {
  width: 16px;
  min-height: 16px;
}

.message {
  min-height: 14px;
  margin: 0;
  color: var(--brand);
  font-size: 11px;
}

.message.error {
  color: var(--danger);
}

.users-layout {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
}

.logs-layout {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  height: calc(100% - 48px);
}

.log-list-box,
.log-detail-box {
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.event-list,
.event-detail {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.event-list,
.log-detail-box {
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.event-list::-webkit-scrollbar,
.log-detail-box::-webkit-scrollbar {
  display: none;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.kv-item {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.kv-item span {
  color: var(--muted);
  font-size: 10px;
}

.log-code {
  margin: 0;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: #12171b;
  border: 1px solid var(--line);
  color: #cfe0ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.45;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-code.compact {
  max-height: 160px;
}

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

.delivery-card {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.delivery-meta {
  color: var(--muted);
  font-size: 10px;
}

.delivery-block {
  display: grid;
  gap: 3px;
}

.delivery-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.item-topline {
  align-items: flex-start;
  gap: 6px;
}

.item-topline strong {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.list-empty {
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--panel-2);
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .shell,
  .auth-view,
  .app-view,
  .main,
  .panel {
    height: auto;
  }

  .app-view {
    grid-template-columns: 1fr;
  }

  .restaurant-list {
    max-height: 280px;
  }
}

@media (max-width: 720px) {
  .form-grid,
  .users-layout,
  .logs-layout,
  .stats-grid,
  .top-grid,
  .kv-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .app-view,
  .auth-view {
    padding: 10px;
  }

  .sidebar,
  .panel,
  .auth-card .stack,
  .auth-hero {
    padding: 12px;
  }
}
