/* ============================================================
   Trap Logger — friendly, modern, card-based UI
   ============================================================ */

:root {
  /* Warm neutrals */
  --bg:            oklch(0.98 0.006 95);
  --surface:       #ffffff;
  --surface-2:     oklch(0.965 0.006 95);
  --border:        oklch(0.91 0.006 95);
  --border-strong: oklch(0.85 0.008 95);

  /* Text */
  --text:      oklch(0.27 0.012 260);
  --text-soft: oklch(0.48 0.012 260);
  --text-mute: oklch(0.62 0.010 260);

  /* Primary — friendly green */
  --primary:      oklch(0.60 0.12 158);
  --primary-dark: oklch(0.52 0.12 158);
  --primary-soft: oklch(0.95 0.04 158);

  /* Status colors (shared chroma/lightness family) */
  --st-available:    oklch(0.60 0.12 158);
  --st-available-bg: oklch(0.95 0.04 158);
  --st-lent:         oklch(0.66 0.13 65);
  --st-lent-bg:      oklch(0.95 0.05 75);
  --st-maintenance:  oklch(0.60 0.11 245);
  --st-maintenance-bg: oklch(0.95 0.04 245);
  --st-lost:         oklch(0.58 0.15 25);
  --st-lost-bg:      oklch(0.95 0.04 25);

  --danger: oklch(0.58 0.15 25);

  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow:    0 1px 2px oklch(0.4 0.02 260 / 0.05), 0 4px 16px oklch(0.4 0.02 260 / 0.06);
  --shadow-lg: 0 8px 40px oklch(0.4 0.02 260 / 0.14);

  --sidebar-w: 248px;
  --font-head: "Schibsted Grotesk", system-ui, sans-serif;
  --font-body: "Schibsted Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; margin: 0; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- App layout ---------- */

#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
  box-shadow: 0 2px 8px oklch(0.60 0.12 158 / 0.35);
}
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 17px; }
.brand-sub  { font-size: 11px; color: var(--text-mute); letter-spacing: 0.02em; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-soft); font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }

/* ---------- Main ---------- */

.main { flex: 1; min-width: 0; padding: 30px 36px 60px; max-width: 1200px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-title h1 { font-size: 25px; }
.page-title p  { margin: 3px 0 0; color: var(--text-mute); font-size: 13.5px; }

/* Auth chip */
.auth-chip { display: flex; align-items: center; gap: 10px; }
.auth-email { font-size: 13px; color: var(--text-soft); }
.viewer-badge {
  font-size: 12px; font-weight: 600; color: var(--st-lent);
  background: var(--st-lent-bg); padding: 5px 11px; border-radius: 999px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 14px;
  transition: transform 0.06s, background 0.12s, box-shadow 0.12s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px oklch(0.60 0.12 158 / 0.3); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--st-lost-bg); color: var(--st-lost); }
.btn-danger:hover { background: oklch(0.90 0.06 25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ---------- Metric cards ---------- */

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.metric-label { font-size: 12.5px; color: var(--text-mute); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.metric-label svg { width: 15px; height: 15px; }
.metric-value { font-family: var(--font-head); font-size: 34px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }

/* ---------- Cards / panels ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 22px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 16px; }
.card-head .sub { font-size: 12.5px; color: var(--text-mute); margin-top: 2px; }
.card-body { padding: 22px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-mute); font-weight: 600; padding: 11px 22px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 13px 22px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; }
.cell-mute { color: var(--text-mute); }

/* Status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-available   { color: var(--st-available);   background: var(--st-available-bg); }
.pill-lent        { color: var(--st-lent);         background: var(--st-lent-bg); }
.pill-maintenance { color: var(--st-maintenance);  background: var(--st-maintenance-bg); }
.pill-lost        { color: var(--st-lost);         background: var(--st-lost-bg); }

/* Days-out chip */
.days { font-weight: 600; font-variant-numeric: tabular-nums; }
.days-warn { color: var(--st-lent); }
.days-over { color: var(--st-lost); }

/* ---------- Forms ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
  padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text); transition: border 0.12s, box-shadow 0.12s;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.field-error { color: var(--danger); font-size: 12.5px; }

/* ---------- Skeleton loader ---------- */

@keyframes shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
.skeleton {
  display: inline-block; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, oklch(0.93 0.006 95) 50%, var(--surface-2) 75%);
  background-size: 840px 100%;
  animation: shimmer 1.3s infinite linear;
}
.sk-line { height: 13px; width: 100%; }
.sk-metric { height: 34px; width: 56px; margin-top: 8px; border-radius: 8px; }
td .skeleton { display: block; }

/* ---------- Empty / toast / banner ---------- */

.empty { text-align: center; padding: 46px 20px; color: var(--text-mute); }
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 10px; }
.empty p { margin: 0; }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  margin-bottom: 20px;
}
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.banner-demo { background: var(--st-maintenance-bg); color: var(--st-maintenance); }

#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 9px;
  animation: toast-in 0.25s cubic-bezier(0.2,0.8,0.2,1);
}
.toast.ok { background: var(--primary-dark); }
.toast.err { background: var(--danger); }
.toast svg { width: 17px; height: 17px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Modal (login) ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: oklch(0.27 0.012 260 / 0.4);
  backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 70; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; padding: 30px; animation: toast-in 0.22s ease;
}
.modal h2 { font-size: 20px; margin-bottom: 6px; }
.modal p.lead { color: var(--text-mute); font-size: 13.5px; margin: 0 0 22px; }

.hidden { display: none !important; }

/* ---------- Responsive fallback ---------- */
@media (max-width: 860px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; width: 100%; flex-direction: row; flex-wrap: wrap; }
  #app { flex-direction: column; }
  .main { padding: 22px 18px 50px; }
}
