/* SweetShop admin panel.
   Two rules keep the pages calm: every control is the same height, and every
   island (.card) has its title in the same place. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --sunken: #f1f3f5;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 12px;
  --control-h: 40px;
  --btn-w: 168px;
  --gap: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --sunken: #171a1f;
    --ink: #e8eaed;
    --muted: #9aa1ac;
    --line: #2c313a;
    --accent: #60a5fa;
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* --- Chrome --- */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
header .brand { font-weight: 700; padding: 14px 0; }
header nav { display: flex; gap: 18px; flex-wrap: wrap; }
header nav a { padding: 14px 0; color: var(--muted); }
header nav a.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
header .spacer { flex: 1; }
header .who { color: var(--muted); font-size: 13px; }
header form button { min-width: 0; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 72px; }

h1 { font-size: 24px; margin: 0 0 20px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }
.page-head h1 { margin: 0; }
.crumb { display: block; margin-bottom: 10px; font-size: 14px; }

/* --- Islands: title always top-left, same offset everywhere --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin-bottom: 18px;
}
.card > :first-child { margin-top: 0; }
.card > h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.3;
}
.card > .card-note { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.card > h2 + *:not(.card-note) { margin-top: 16px; }
.card.tight { padding-bottom: 12px; }

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat .value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- Forms: one grid, one control height --- */
.form {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
}
.form > * { grid-column: span 3; }
.col-2 { grid-column: span 2 !important; }
.col-3 { grid-column: span 3 !important; }
.col-4 { grid-column: span 4 !important; }
.col-6 { grid-column: span 6 !important; }
.col-12 { grid-column: span 12 !important; }

@media (max-width: 900px) {
  .form > *, .col-2, .col-3, .col-4 { grid-column: span 6 !important; }
  .col-6, .col-12 { grid-column: span 12 !important; }
}
@media (max-width: 560px) {
  .form > *, .col-2, .col-3, .col-4, .col-6 { grid-column: span 12 !important; }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; color: var(--muted); line-height: 1.25; }
.actions { display: flex; gap: 10px; align-items: end; }
.actions.right { justify-content: flex-end; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: var(--control-h);
  padding: 0 12px;
  width: 100%;
  min-width: 0;
}
select { padding-right: 8px; }
textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; }
input[type="file"] { padding: 8px 10px; height: auto; min-height: var(--control-h); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder { color: var(--muted); opacity: .7; }

/* Checkbox: big enough to hit, aligned with the controls beside it. */
input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  display: grid;
  place-content: center;
  cursor: pointer;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.field.check { flex-direction: row; align-items: center; gap: 10px; height: var(--control-h); }
.field.check > label { order: 2; color: var(--ink); font-size: 14px; }

.hint { color: var(--muted); font-size: 13px; margin: 16px 0 0; line-height: 1.5; }

/* --- Buttons: same width, centred label --- */
button, .btn {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  height: var(--control-h);
  min-width: var(--btn-w);
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
button.danger { background: var(--danger); }
button.small { height: 32px; min-width: 104px; padding: 0 12px; font-size: 13px; }
button.icon { height: 30px; width: 30px; min-width: 30px; padding: 0; font-size: 14px; }
button.link { background: none; border: none; color: var(--accent); min-width: 0; padding: 0; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
.scroll { overflow-x: auto; }
th, td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 2px; }
th:last-child, td:last-child { padding-right: 2px; }
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
td.center input[type="checkbox"] { margin: 0 auto; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
td input, td select { height: 34px; }
td .stack { display: flex; flex-direction: column; gap: 2px; }
td .stack .sub { color: var(--muted); font-size: 12px; }

tr.editable td { border-bottom: none; padding-bottom: 8px; }
tr.sub td { padding-top: 0; padding-bottom: 18px; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; }
.flash.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.flash.err { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.tag {
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.tag.on, .tag.completed { color: var(--ok); border-color: currentColor; }
.tag.off { color: var(--muted); }
.tag.new { color: var(--accent); border-color: currentColor; }
.tag.confirmed { color: var(--warn); border-color: currentColor; }
.tag.cancelled { color: var(--danger); border-color: currentColor; }

.muted { color: var(--muted); }
.thumbs { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.thumb { width: 132px; }
.thumb img { width: 132px; height: 132px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb button { width: 100%; min-width: 0; margin-top: 8px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chips a {
  font-size: 13px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.chips a:hover { color: var(--ink); text-decoration: none; }
.sub-panel { background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 22px 0 18px; }
