:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6feb;
  --on-sale: #1f9d55;
  --on-sale-bg: #e6f6ec;
  --sold: #d1453b;
  --sold-bg: #fbe9e7;
  --soft: #f0f2f5;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2027; --ink: #e8eaed; --muted: #9aa2ad;
    --line: #2b313a; --accent: #5b8cff; --soft: #232832;
    --on-sale: #46c982; --on-sale-bg: #14361f; --sold: #f0857c; --sold-bg: #3a1a17;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--soft); padding: .1em .35em; border-radius: 4px; font-size: .9em; }

.nav {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.nav .brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.nav nav { display: flex; gap: 16px; }
.nav nav a { color: var(--ink); }
.nav .logout { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav .who { color: var(--muted); font-size: 14px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

h1 { font-size: 22px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--sold); font-weight: 600; }

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink);
  padding: 7px 12px; border-radius: 8px;
}
button:hover, .btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { color: var(--sold); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow);
}
.login-card { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.login-card h1 { font-size: 26px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; padding: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); color: var(--ink);
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-icon { font-size: 24px; }
.tile-title { font-weight: 600; }
.tile-sub { color: var(--muted); font-size: 13px; }

/* Tables (browse, watches, admin) */
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

/* Calendar grid */
.cal-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.calendar { border-collapse: collapse; }
table.calendar th, table.calendar td {
  border: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap;
}
table.calendar th.show, table.calendar td.show {
  text-align: left; position: sticky; left: 0; background: var(--panel); font-weight: 600; z-index: 1;
}
table.calendar .date-head { font-weight: 700; }
table.calendar .slot-head { color: var(--muted); font-weight: 500; font-size: 12px; }
.cell { font-size: 12px; border-radius: 6px; }
.cell-on_sale { background: var(--on-sale-bg); color: var(--on-sale); font-weight: 700; }
.cell-sold_out { background: var(--sold-bg); color: var(--sold); }
.cell-not_on_sale, .cell-unknown, .cell-cancelled, .cell-past { color: var(--muted); }
.cell.dim { opacity: .5; }

.status-on_sale { color: var(--on-sale); font-weight: 600; }
.status-sold_out { color: var(--sold); }
.status-not_on_sale, .status-unknown, .status-cancelled, .status-past { color: var(--muted); }

form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
label { font-size: 13px; color: var(--muted); }
select, input[type="date"], input[type="text"] {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: var(--muted); }
.pill.admin { background: var(--accent); color: #fff; }
.section-title { margin: 22px 0 8px; font-size: 16px; }
.invite-box { background: var(--soft); padding: 12px; border-radius: 8px; word-break: break-all; margin-top: 10px; }
