/* ── Reset / Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0c1b16;   /* deep forest night */
  --surface:   #122620;   /* dark undergrowth  */
  --card:      #182e27;   /* forest floor      */
  --border:    #265045;   /* tidal border      */
  --text:      #dceee8;   /* shore foam        */
  --muted:     #79a897;   /* sage mist         */
  --accent:    #2dd4bf;   /* seafoam teal      */
  --ok:        #4ade80;   /* sea glass green   */
  --warn:      #d4a84b;   /* driftwood amber   */
  --err:       #f87171;   /* coral             */
  --sidebar-w: 220px;
  --topbar-h:  60px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ───────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.3px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo span { color: var(--ok); font-weight: 400; }

nav { flex: 1; padding: 12px 0; }

.nav-link {
  display: block;
  padding: 9px 16px;
  color: var(--muted);
  font-size: 13px;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
}

.nav-link:hover { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
.nav-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(45,212,191,.07); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  display: block;
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  text-align: center;
  transition: border-color .15s, color .15s;
}

.btn-logout:hover { border-color: var(--err); color: var(--err); }

/* ── Main content ────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Top bar (filters) ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
}

.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }

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

.filter-form select,
.filter-form input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  height: 34px;
  box-sizing: border-box;
}

/* Custom dropdown arrow for select (replaces native iOS/browser arrow) */
.filter-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2379a897'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.filter-form select:focus,
.filter-form input:focus { outline: none; border-color: var(--accent); }

.filter-form label { color: var(--muted); font-size: 12px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s;
}

.btn:hover { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #0c1b16; }
.btn-secondary { background: var(--card); border: 1px solid var(--border); color: var(--text); }

/* ── Page body ───────────────────────────────────────────────────────────────── */
.content { padding: 24px; flex: 1; }

.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

/* ── Stat cards ──────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--text);
}

.stat-value.accent { color: var(--accent); }
.stat-value.ok     { color: var(--ok); }
.stat-value.warn   { color: var(--warn); }
.stat-value.err    { color: var(--err); }

/* Coloured left border on stat cards */
.stat-card.c-accent { border-left: 3px solid var(--accent); }
.stat-card.c-ok     { border-left: 3px solid var(--ok); }
.stat-card.c-warn   { border-left: 3px solid var(--warn); }
.stat-card.c-err    { border-left: 3px solid var(--err); }

/* ── Charts ──────────────────────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.chart-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}

.chart-wrap { position: relative; height: 220px; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  margin: 0;
}


.btn-xs {
  padding: 3px 10px;
  font-size: 11px;
  border-radius: 5px;
}

.table-card h3 > .btn {
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
  vertical-align: middle;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 9px 18px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }

/* Info tables (key/value pairs) — allow long values to wrap */
.info-table td {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  max-width: none;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Status code badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.badge-2xx { background: rgba(74,222,128,.15);  color: var(--ok); }
.badge-3xx { background: rgba(45,212,191,.15);  color: var(--accent); }
.badge-4xx { background: rgba(212,168,75,.15);  color: var(--warn); }
.badge-5xx { background: rgba(248,113,113,.15); color: var(--err); }

/* ── Loading / empty states ──────────────────────────────────────────────────── */
.loading, .empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 44px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.auth-logo span { color: var(--ok); font-weight: 400; }

.auth-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 32px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  background: var(--accent);
  color: #0c1b16;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: opacity .15s;
}
.auth-btn:hover  { opacity: .87; }
.auth-btn:disabled { opacity: .45; cursor: not-allowed; }

.auth-status {
  margin-top: 18px;
  font-size: 13px;
  min-height: 20px;
  color: var(--muted);
}
.status-info  { color: var(--accent); }
.status-ok    { color: var(--ok); }
.status-error { color: var(--err); }

.auth-link { margin-top: 20px; font-size: 12px; color: var(--muted); }
.auth-link a { color: var(--accent); }

/* ── Mobile nav toggle (hidden on desktop) ───────────────────────────────────── */
.nav-toggle  { display: none; }
.nav-overlay { display: none; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  /* Semi-transparent overlay behind the open drawer */
  .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .nav-overlay.open { opacity: 1; pointer-events: auto; }

  /* Hamburger button — 44×44px minimum touch target (Apple HIG) */
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle:active { color: var(--text); border-color: var(--accent); }

  /* Main takes full width; clip overflow without breaking sticky topbar */
  .main { margin-left: 0; overflow-x: clip; }

  /* Topbar: [☰ | title] on first row, filter form on its own row below.
     Horizontal padding matches .content (14px) so inputs align with cards. */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 14px;
    gap: 8px;
  }
  .topbar-title { flex: 1; font-size: 14px; min-width: 0; }

  /*
   * Filter form: single-column stack so every control gets the full
   * row width. iOS native date inputs have a minimum intrinsic width
   * that overflows a two-column grid, so we don't attempt side-by-side.
   */
  .filter-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .filter-form label              { display: none; }
  .filter-form select,
  .filter-form input[type="date"],
  .filter-form .btn               { width: 100%; min-width: 0; }

  /* Charts & content */
  .chart-grid { grid-template-columns: 1fr; }
  .content    { padding: 14px; }

  /* Tables scroll horizontally rather than clipping */
  .table-card { overflow-x: auto; }
}
