/* BudgetBro merchant portal — shared styles for the merchant and admin pages. */

/* Palette lifted from the consumer app (app/styles.css) so the portal, the
   support console and the field app look like the same product as
   budgetbro.co. Light and blue-primary, not a separate dark theme.

   If the main app's palette changes, change these and everything follows —
   every rule below is written against the tokens, never a literal colour. */
:root {
  color-scheme: light;

  --bg: #f4f9ff;
  --surface: #ffffff;
  --border: #d9e8fb;
  --border-strong: #c5dff8;
  --text: #0b1220;
  --muted: #5d6b80;

  /* Blue is the brand and the primary action. */
  --accent: #1677ff;
  --accent-soft: #eaf4ff;
  --accent-border: #b9d7fb;

  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warn: #d99600;
  --warn-soft: #fff8df;
  --success: #13a763;
  --success-soft: #e9f9f1;

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --on-accent: #ffffff;
  --shadow: 0 24px 70px rgba(18, 72, 135, 0.14);
}

/* Deliberately no dark-scheme override: the consumer app is light only, and a
   portal that flips to dark on half the staff's phones would not read as the
   same product. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 32px 20px 80px; }
.wrap.wide { max-width: 1080px; }

header.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 28px;
}

header.bar h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
header.bar .who { color: var(--muted); font-size: 13px; }

h2 { font-size: 15px; margin: 32px 0 12px; letter-spacing: -0.01em; }
h2:first-of-type { margin-top: 0; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(18, 72, 135, 0.05);
}

.card h3 { margin: 0 0 4px; font-size: 15px; }

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

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

/* `search` and `tel` are easy to forget here, and an input left out falls back
   to the browser default — a white box in a dark interface. */
input[type="text"], input[type="email"], input[type="number"],
input[type="search"], input[type="tel"], input:not([type]), textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

textarea { min-height: 78px; resize: vertical; }

/* iOS gives search inputs rounded native chrome that ignores the above. */
input[type="search"] { -webkit-appearance: none; appearance: none; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.row > button { flex: 0 0 auto; }

button {
  font: inherit;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: default; filter: none; }

button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
button.small { padding: 5px 10px; font-size: 13px; }

/* --- feedback ------------------------------------------------------------- */

.note {
  border-radius: 8px;
  padding: 11px 14px;
  margin: 12px 0;
  font-size: 14px;
  border: 1px solid transparent;
}

.note.ok { background: var(--accent-soft); border-color: var(--accent); }
.note.bad { background: var(--danger-soft); border-color: var(--danger); }
.note.warn { background: var(--warn-soft); border-color: var(--warn); }
.note:empty { display: none; }

/* --- data ----------------------------------------------------------------- */

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

.stat {
  flex: 1 1 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat.flag .n { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 10px 6px 0; }
td { padding: 8px 10px 8px 0; border-top: 1px solid var(--border); vertical-align: top; }
.scroll { overflow-x: auto; }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag.live { background: var(--success-soft); color: var(--success); }
.tag.hot { background: var(--danger-soft); color: var(--danger); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* --- the dangerous one ---------------------------------------------------- */

/* Impersonation is visually separated on purpose. It should never be possible
   to click it while believing you are doing something routine. */
.card.danger { border-color: var(--danger); border-width: 1px; }
.card.danger h3 { color: var(--danger); }

.linkout {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  color: var(--text);
}

.hidden { display: none !important; }

/* The restaurant every action below operates on.
 *
 * Deliberately louder than the cards around it. The console previously had no
 * single answer to "what am I acting on?", and a context strip that reads like
 * just another card would not give it one. */
#selected-bar {
  border-left: 3px solid var(--accent, #2d7ff9);
  background: var(--panel-strong, rgba(45, 127, 249, 0.06));
}
#selected-bar h3 { margin: 2px 0; }

/* --- Owner metrics -------------------------------------------------------
   Every geometry value lives in an SVG attribute, never in a style= — the
   CSP is script-src/style-src 'self' with no 'unsafe-inline', so an inline
   style attribute is inert in production and geometry expressed that way
   would silently collapse the chart. Colour and stroke come from here. */
.metric-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric-tile { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; }
.metric-tile .metric-label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.metric-tile .metric-value { display: block; font-size: 30px; font-weight: 800; color: var(--text); line-height: 1.1; margin-top: 4px; }
.metric-tile .metric-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.metric-chart { width: 100%; height: auto; overflow: visible; }
.metric-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.metric-chart .grid { stroke: var(--border); stroke-width: 1; }
.metric-chart .bar-field { fill: var(--accent); }
.metric-chart .bar-self { fill: var(--success); }
.metric-chart .bar-support { fill: var(--accent-border); }
.metric-chart .bar-unknown { fill: var(--muted); }
.metric-chart .bar-released { fill: var(--danger); }
.metric-chart .bar-partial { opacity: 0.55; }
.metric-chart .forecast-band { fill: var(--accent-soft); stroke: var(--accent-border); stroke-width: 1; stroke-dasharray: 3 3; }
.metric-chart .forecast-rule { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.metric-chart .tick { fill: var(--muted); font-size: 10px; }
.metric-chart .tick-strong { fill: var(--text); font-size: 10px; font-weight: 700; }

.metric-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.metric-legend span { display: inline-flex; align-items: center; gap: 5px; }
.metric-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.metric-legend .k-field { background: var(--accent); }
.metric-legend .k-self { background: var(--success); }
.metric-legend .k-support { background: var(--accent-border); }
.metric-legend .k-unknown { background: var(--muted); }
.metric-legend .k-released { background: var(--danger); }

.metric-note { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rep-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border-bottom: 1px solid var(--border); padding: 6px 8px; }
.rep-table td { padding: 8px; border-bottom: 1px solid var(--border); }
.rep-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rep-table .quiet td { background: var(--warn-soft); }
.rep-table .off-roster { color: var(--muted); font-size: 12px; }
