:root {
  color-scheme: dark; /* native date pickers, selects and scrollbars match the theme */
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-hover: #1e2330;
  --border: #2a3140;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #4f8cff;
  --accent-hover: #3a78ef;
  --danger: #f07178;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;

  --level-debug: #8b95a8;
  --level-info: #5ad4a8;
  --level-warn: #f0c674;
  --level-error: #f07178;
  --level-fatal: #ff5577;
  --level-dpanic: #ff5577;
  --level-panic: #ff5577;

  /* Order statuses: validated categorical steps for the dark surface (stack order paid, active, expired, cancelled). */
  --st-paid: #3987e5;
  --st-active: #199e70;
  --st-expired: #9085e9;
  --st-cancelled: #d95926;

  --chart-grid: #262c38;
  --chart-axis: #3a4252;
  --good: #0ca30c;
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.view {
  min-height: 100%;
}

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

.error {
  color: var(--danger);
  margin: 0;
  font-size: 13px;
}

/* —— Login —— */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-card label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 18px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* below 16px iOS zooms into the field */
  font-family: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.login-card button[type="submit"]:hover {
  background: var(--accent-hover);
}

.login-card button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* —— Panel shell —— */
#view-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-short,
.logout-icon {
  display: none;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tab.active {
  background: var(--bg-hover);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

@media (max-width: 700px) {
  #view-panel {
    height: auto;
    min-height: 100dvh;
  }

  .panel-header {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-wrap: wrap;
    gap: 0 8px;
    padding: 6px 8px 0;
  }

  .brand {
    padding-left: 6px;
  }

  .brand-full,
  .logout-text {
    display: none;
  }

  .brand-short,
  .logout-icon {
    display: inline;
  }

  #btn-logout {
    margin-left: auto;
  }

  .tabs {
    order: 3;
    flex-basis: 100%;
    scroll-snap-type: x proximity;
    padding: 4px 0 6px;
  }

  .tab {
    scroll-snap-align: start;
    min-height: 40px;
  }
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: var(--bg-hover);
}

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

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

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
}

.btn.icon {
  min-width: 32px;
  padding-left: 8px;
  padding-right: 8px;
}

@media (pointer: coarse) {
  .btn.small {
    min-height: 40px;
    padding: 8px 12px;
  }

  .btn.icon {
    min-width: 40px;
  }
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
