/* store-profit owner console
   Surface: Operate (primary) / Monitor (dashboard). Dense, neutral, one accent.
   No hero, no gradients, no icon toppers, no decorative cards. */

:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #fbfcfc;
  --line: #e3e6e9;
  --line-strong: #ccd2d7;
  --ink: #14171a;
  --ink-2: #3d444c;
  --muted: #6a727c;
  --accent: #0b7a55;
  --accent-ink: #ffffff;
  --accent-soft: #e9f5ef;
  --accent-line: #b6ddca;
  --danger: #a4231b;
  --danger-soft: #fdecea;
  --warn: #7d5300;
  --warn-soft: #fdf4e3;
  --warn-line: #ecd9ab;
  --radius: 6px;
  --tap: 44px;
  --sans: "Helvetica Neue", Helvetica, Arial, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: 10px 14px;
  z-index: 50;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 10px;
  height: 10px;
  background: var(--accent);
  display: inline-block;
  border-radius: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 12px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--radius);
  font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link.is-active { color: var(--accent); background: var(--accent-soft); }

.count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  text-align: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.identity {
  color: var(--muted);
  font-size: 13px;
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form { margin: 0; }

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

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
}

.title { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.01em; font-weight: 600; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-narrow { max-width: 480px; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-title { margin: 0; font-size: 15px; font-weight: 600; }

/* ---------- metrics ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.metric { background: var(--surface); padding: 12px 14px; }
.metric dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.metric dd { margin: 6px 0 0; font-family: var(--mono); font-size: 17px; }
.metric-strong dd { font-weight: 600; }

.money { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.money-missing { color: var(--warn); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.table { width: 100%; border-collapse: collapse; background: var(--surface); }

.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child th, .table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-head { font-weight: 600; }
.row-head .muted { display: block; font-weight: 400; }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="number"], select, textarea {
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

input[type="number"], input.money-input { font-family: var(--mono); }
input[type="date"], input[type="datetime-local"] { font-family: var(--mono); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #0a6b4a; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); font-weight: 500; }
.btn-quiet:hover { background: var(--surface-2); }
.btn-danger { border-color: var(--line-strong); color: var(--danger); }
.btn-small { min-height: 36px; padding: 0 10px; font-size: 13px; }

.filter-bar { margin: 0; min-width: 280px; }
.filter-fields { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.field-inline { margin-bottom: 0; }
.field-inline label { font-size: 12px; }
.range-label { margin: 8px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }

.form { max-width: 420px; }
.form-error { color: var(--danger); margin: 0 0 12px; }

/* ---------- notices, tags, chips ---------- */

.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.notice-title { font-weight: 600; }
.notice-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--ink); }
.notice-danger { background: var(--danger-soft); border-color: #f0c6c2; }
.notice-ok { background: var(--accent-soft); border-color: var(--accent-line); }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--surface-2);
}
.tag-ok { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tag-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.tag-danger { background: var(--danger-soft); border-color: #f0c6c2; color: var(--danger); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.chip {
  border: 1px solid var(--warn-line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
}
.chip-meta { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
}
code { font-family: var(--mono); }

.links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.links li { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.empty { padding: 24px 0; text-align: center; color: var(--muted); }

/* ---------- cost editor ---------- */

.cost-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px; }
.cost-card + .cost-card { margin-top: 12px; }
.cost-card.is-dirty { border-color: var(--accent-line); }

.cost-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

.tier-table { width: 100%; border-collapse: collapse; }
.tier-table th, .tier-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.tier-table thead th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tier-table .num { text-align: right; }
.tier-table input { min-height: var(--tap); }
.tier-range { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.tier-range[data-open="true"]::after { content: "+"; }
.tier-error { color: var(--danger); font-size: 12px; margin: 2px 0 0; }

.alias { display: flex; align-items: center; gap: 8px; }
.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.toggle button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.preview-qty { max-width: 8rem; }

.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-top: 16px;
}
.save-bar .summary { color: var(--ink-2); font-size: 13px; }

/* ---------- modal ---------- */

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}
.modal-card {
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
}
.modal-card h2 { margin: 0 0 6px; font-size: 17px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.scope-choice { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.scope-option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.scope-option input { min-height: 0; width: auto; margin-top: 3px; }
.scope-option label { font-weight: 600; }
.scope-option .muted { display: block; font-size: 13px; }
.edit-list { list-style: none; padding: 0; margin: 10px 0 0; font-family: var(--mono); font-size: 13px; }

/* ---------- notifications ---------- */

.notif { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.notif + .notif { margin-top: 10px; }
.notif.is-unread { border-left: 3px solid var(--accent); }
.notif-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.notif-title { font-weight: 600; margin: 0; }
.notif-meta { color: var(--muted); font-family: var(--mono); font-size: 12px; }

/* `hidden` has to win over the display below, exactly as `.modal[hidden]` does:
   an IDL `hidden` property is a UA-level `display: none` that any class rule
   declaring `display` silently overrides. Without this the import status line
   rendered permanently - "pending / waiting" for a job nobody queued. */
.job-line[hidden] { display: none; }
.job-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }

/* the raw payload is reachable but collapsed, never the default view */
.raw > summary { cursor: pointer; }

/* ---------- footer ---------- */

.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- mobile ---------- */

@media (max-width: 760px) {
  .topbar-inner { gap: 8px; }
  .identity { display: none; }
  .shell { padding: 14px 12px 32px; }
  .panel { padding: 12px; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .page-head { flex-direction: column; }

  /* tables become stacked definition rows: no horizontal hunting on a phone */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table th, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table th, .table td { border: 0; padding: 4px 12px; }
  .table td.num { text-align: left; }
  .table td.num::before { content: attr(data-label) " "; color: var(--muted); font-family: var(--sans); }
  .tier-table { display: block; }
  .tier-table thead { display: none; }
  .tier-table tbody, .tier-table tr, .tier-table td { display: block; width: 100%; }
  .tier-table tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; }
  .tier-table td { border: 0; padding: 4px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
