/* Shared look for the sign-in page, the upload-link pages, the upload page and the map.
   Served without a session (it holds no data), so the sign-in page can use it. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --text: #0e1525;
  --muted: #5d6b82;
  --faint: #94a0b4;
  --line: #e3e7ee;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #047857;
  --ok-soft: #e7f8f0;
  --warn: #b45309;
  --warn-soft: #fff6e6;
  --bad: #d92d20;
  --bad-soft: #fef1f0;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(14, 21, 37, 0.04), 0 16px 40px -18px rgba(14, 21, 37, 0.16);
  --ring: 0 0 0 4px rgba(79, 70, 229, 0.16);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07090f;
    --surface: #0e121b;
    --surface-2: #141a26;
    --text: #eef2f8;
    --muted: #97a3b6;
    --faint: #626e83;
    --line: #1f2737;
    --accent: #8b93ff;
    --accent-soft: #1a1d3b;
    --ok: #3ddc97;
    --ok-soft: #0c2a1f;
    --warn: #f5b84b;
    --warn-soft: #2b2010;
    --bad: #ff7a70;
    --bad-soft: #2d1312;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 18px 44px -20px rgba(0, 0, 0, 0.8);
    --ring: 0 0 0 4px rgba(139, 147, 255, 0.22);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  background:
    radial-gradient(1100px 560px at -10% -20%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 62%),
    radial-gradient(900px 520px at 110% -10%, color-mix(in oklab, #0ea5e9 12%, transparent), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(27px, 5.4vw, 34px); line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 650; letter-spacing: -0.015em; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
.eyebrow { font-size: 11.5px; font-weight: 650; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent); }
.stack > :not(:first-child) { margin-top: 16px; }
.stack-lg > :not(:first-child) { margin-top: 24px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Layout */
.page { max-width: 660px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom)); }
.center { min-height: 100dvh; display: grid; place-items: center; padding: 24px 20px; }
.narrow { width: 100%; max-width: 400px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; letter-spacing: -0.015em; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff;
  background: linear-gradient(140deg, #6366f1 0%, #3b82f6 55%, #06b6d4 100%);
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card.padded-lg { padding: 30px; }

/* Controls */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 52px; padding: 0 22px; border: 0; border-radius: 14px;
  font: inherit; font-size: 16px; font-weight: 620; letter-spacing: -0.01em; cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease, opacity 0.2s ease, background-color 0.2s ease;
}
.btn-primary { color: var(--bg); background: var(--text); box-shadow: 0 12px 28px -14px rgba(14, 21, 37, 0.7); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 32px -14px rgba(14, 21, 37, 0.75); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); height: 46px; font-size: 15px; }
.btn-danger { color: var(--bad); background: transparent; border: 1px solid color-mix(in oklab, var(--bad) 35%, var(--line)); height: 46px; font-size: 15px; }
.btn-danger:hover { background: var(--bad-soft); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary:disabled { opacity: 1; color: var(--faint); background: var(--surface-2); border: 1px solid var(--line); }
.btn:focus-visible, .input:focus-visible { outline: none; box-shadow: var(--ring); }
.input {
  width: 100%; height: 52px; padding: 0 16px; border: 1px solid var(--line); border-radius: 14px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.input:focus { border-color: var(--accent); background: var(--surface); }
.input-sm { height: 40px; width: auto; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pills, notices */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 13px 15px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.notice.ok { color: var(--ok); background: var(--ok-soft); }
.notice.warn { color: var(--warn); background: var(--warn-soft); }
.notice.bad { color: var(--bad); background: var(--bad-soft); }
.notice svg { flex: none; margin-top: 1px; }

/* Upload link: how many opens are used, and by whom */
.meter { display: flex; gap: 6px; }
.meter span { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.meter span.used { background: var(--accent); }
.meter.full span.used { background: var(--bad); }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.history li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 13px; background: var(--surface-2); font-size: 13.5px; line-height: 1.35;
}
.history .ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.history b { display: block; font-weight: 600; }
.history .meta { color: var(--muted); font-size: 12.5px; }

/* Upload page */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile { padding: 20px; }
.tile .supplier { font-size: 13px; font-weight: 650; color: var(--muted); letter-spacing: 0.01em; }
.tile .date { margin: 10px 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.drop {
  display: grid; place-items: center; gap: 6px; padding: 34px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed color-mix(in oklab, var(--faint) 60%, transparent); border-radius: var(--radius);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop.over { transform: scale(1.01); }
.drop .drop-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border-radius: 14px; color: var(--accent); background: var(--accent-soft); }
.drop strong { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.drop input { display: none; }
.file { display: grid; gap: 10px; padding: 18px 20px; }
.file.error { border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); }
.file .name { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.date-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; }

/* Upload page: Lowes' classes (a switch and two discounts each) and states */
.stack-sm > :not(:first-child) { margin-top: 8px; }
.label { font-size: 12px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.rates { display: grid; grid-template-columns: 1fr 86px 86px; align-items: center; gap: 8px 10px; }
.rates .head { font-size: 12px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.rates .head:not(:first-child) { text-align: center; }
.rates .class { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 600; cursor: pointer; }
.rates .class small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.rates .off { opacity: 0.45; }
.rates input[type="number"] { width: 100%; text-align: center; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.rates input[type="number"]::-webkit-inner-spin-button, .rates input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="checkbox"] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggles button {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.toggles button small { font-size: 12px; font-weight: 500; color: var(--faint); }
.toggles button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.toggles button[aria-pressed="true"] small { color: inherit; opacity: 0.75; }
.toggles button:focus-visible, input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--ring); }

/* Upload page: prices by hand (the gear), a spreadsheet in a dialog */
.topbar-end { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  appearance: none; display: grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:focus-visible, button.link:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-sm { width: auto; height: 38px; padding: 0 15px; font-size: 14px; border-radius: 11px; }
button.link { appearance: none; padding: 0; font: inherit; font-weight: 650; color: inherit; text-decoration: underline; background: none; border: 0; border-radius: 4px; cursor: pointer; }
.bad-text { color: var(--bad); }
.editor {
  width: min(1060px, 100vw - 24px); max-width: none; height: min(900px, 100dvh - 24px); max-height: none; padding: 0;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.editor[open] { display: flex; flex-direction: column; }
.editor::backdrop { background: rgba(7, 9, 15, 0.5); }
.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 14px; }
.editor-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 0 24px 14px; }
.editor-bar .field { display: grid; gap: 5px; }
.editor-bar #hand-now { padding-bottom: 10px; }
.grid-wrap { flex: 1 1 auto; min-height: 120px; overflow: auto; background: var(--surface-2); border-block: 1px solid var(--line); }
.grid { width: 100%; min-width: 900px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.grid .c-n { width: 44px; }
.grid .c-state { width: 72px; }
.grid .c-price { width: 86px; }
.grid .c-place { width: 104px; }
.grid .c-del { width: 40px; }
.grid thead th {
  position: sticky; top: 0; z-index: 1; padding: 8px 9px; font-size: 11.5px; font-weight: 650; letter-spacing: 0.05em;
  text-transform: uppercase; text-align: left; color: var(--faint); background: var(--surface); border-bottom: 1px solid var(--line);
}
.grid tbody th { padding: 0 8px; font-size: 12px; font-weight: 500; text-align: right; color: var(--faint); border-bottom: 1px solid var(--line); }
.grid td { padding: 0; background: var(--surface); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.grid td.loading { padding: 14px; color: var(--muted); }
.grid input {
  display: block; width: 100%; height: 34px; padding: 0 9px; font: inherit; color: inherit;
  background: transparent; border: 0; border-radius: 0; text-overflow: ellipsis;
}
.grid input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.grid input.bad { color: var(--bad); background: var(--bad-soft); }
.grid input[readonly], .grid input::placeholder { color: var(--faint); }
.grid input[readonly] { cursor: default; font-size: 12.5px; }
.grid .del { display: grid; place-items: center; width: 100%; height: 34px; padding: 0; font: inherit; font-size: 18px; color: var(--faint); background: none; border: 0; cursor: pointer; }
.grid .del:hover, .grid .del:focus-visible { color: var(--bad); outline: none; }
.editor-foot { padding: 14px 24px 20px; }
.editor-actions { display: flex; justify-content: flex-end; gap: 10px; }
.editor-actions .btn { width: auto; }
@media (max-width: 640px) {
  /* Phones: the dialog fills the screen and scrolls, so the sheet keeps most of it */
  .editor { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .editor[open] { display: block; overflow-y: auto; }
  .grid-wrap { height: 68dvh; }
  .editor-head, .editor-bar, .editor-foot { padding-left: 16px; padding-right: 16px; }
  .editor-actions { flex-direction: column-reverse; }
  .editor-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
