:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --border: #e3e3dd;
  --text: #1d1f1e;
  --muted: #6b6f6c;
  --accent: #1f5f4a;
  --accent-soft: #e3efe9;
  --danger: #b03a2e;
  --radius: 10px;

  --s-not_started: #d9d9d3;
  --s-submitted: #e8b54a;
  --s-verifying: #e08a3c;
  --s-live: #2f8a5f;
  --s-needs_update: #c9503f;
  --s-rejected: #8c2f26;
  --s-skipped: #b9bdc4;

  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 0 8px 18px; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 13px; }
.nav a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .signout { margin-top: 18px; color: var(--muted); }
main { padding: 28px 32px 80px; max-width: 1200px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { color: var(--muted); margin-bottom: 6px; font-size: 13px; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.grid > .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Business cards */
.biz { display: block; color: inherit; }
.biz:hover { text-decoration: none; border-color: #c9cbc4; }
.biz h2 { margin-bottom: 2px; }
.stats { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; }
.stats b { font-size: 16px; display: block; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; display: flex; margin-top: 12px; }
.bar span { display: block; height: 100%; }

/* Controls */
button, .btn {
  font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: #184d3c; }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }

label { display: block; font-size: 12.5px; font-weight: 550; margin-bottom: 4px; color: #3b3f3d; }
input, select, textarea {
  font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field .count.over { color: var(--danger); font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.fields .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }

/* Hours */
.hours-row { display: grid; grid-template-columns: 110px 90px 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 6px; }

/* Badges */
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.api { background: #e0ecfa; color: #1f4f86; }
.badge.import { background: #ece4f7; color: #5b3a8a; }
.badge.paid, .badge.unknown { background: #fbe7e4; color: #8c2f26; }
.badge.freemium { background: #fdf2dc; color: #7a5410; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--s-not_started); flex: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td input, td select { padding: 5px 7px; }
.dir-name { font-weight: 600; }
.dir-notes { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 360px; }
tr.group td { background: var(--surface-2); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { padding: 5px 11px; border-radius: 999px; font-size: 13px; }
.filters button.on { background: var(--text); color: #fff; border-color: var(--text); }

/* Matrix */
.matrix { border-collapse: separate; border-spacing: 0; }
.matrix th.dir { writing-mode: vertical-rl; transform: rotate(180deg); height: 150px; padding: 6px 4px; font-weight: 500; color: var(--text); }
.matrix td { padding: 0; border: 0; text-align: center; }
.matrix td.loc { text-align: left; padding: 6px 12px 6px 0; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix a.cell { display: block; width: 22px; height: 22px; margin: 2px; border-radius: 4px; background: var(--s-not_started); }
.matrix .na { display: block; width: 22px; height: 22px; margin: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* Copy kit */
.kit-row { display: grid; grid-template-columns: 190px 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; }
.kit-row:last-child { border-bottom: 0; }
.kit-row .label { color: var(--muted); font-size: 13px; }
.kit-row .value { white-space: pre-wrap; word-break: break-word; }
.kit-row .value.blank { color: #b0b3ae; font-style: italic; }

/* Notices */
.notice { padding: 12px 14px; border-radius: 8px; background: #fdf2dc; color: #5b420c; font-size: 13.5px; }
.notice.ok { background: var(--accent-soft); color: #174634; }
.notice.err { background: #fbe7e4; color: #7a281f; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }

.savebar { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; display: flex; gap: 10px; align-items: center; }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 22px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20, 22, 21, 0.35); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 8px; transition: all 0.2s; pointer-events: none; z-index: 10; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; display: flex; gap: 4px; overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 8px 0 0; }
  .nav a { white-space: nowrap; margin: 0; }
  .nav .signout { margin: 0; }
  main { padding: 20px 16px 80px; }
  .fields { grid-template-columns: 1fr; }
  .hours-row { grid-template-columns: 80px 70px 1fr 1fr; gap: 6px; }
  .kit-row { grid-template-columns: 1fr auto; }
  .kit-row .label { grid-column: 1 / -1; }
}
