/*
 * Bayla product UI: shared design tokens and components.
 *
 * One accent (blue) for primary actions, active states and key data only;
 * neutral grays for everything else. Strict 4px spacing grid, Inter at
 * 13-14px, 1px borders over shadows, 6/8/12px radii, flat fast controls,
 * motion under 200ms with no overshoot. Linked by the admin dashboard, the
 * customer portal and the demo storefront so all three read as one system.
 */

:root {
  --bg: #FFFFFF;
  --bg-2: #FAFAFA;
  --bg-3: #F4F4F5;
  --border: #E4E4E7;
  --border-subtle: #F0F0F1;
  --text: #09090B;
  /* Greys and the action blue are set for reading: every text colour here
     is at least 4.5:1 on white, on --bg-2 and on --bg-3 (WCAG AA). */
  --text-2: #52525B;
  --text-3: #6B6B74;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-subtle: #EFF6FF;
  /* The wordmark's full stop keeps the brand blue (docs/BRAND.md). It is a
     mark, not text, so 3:1 is enough; never use it for words or buttons. */
  --brand: #3B82F6;
  /* Status colours for dots, bars and borders (3:1 or better as marks)... */
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  /* ...and their darker twins for words, 4.5:1 or better on white and on
     the tinted chip and banner backgrounds. */
  --success-text: #15803D;
  --warning-text: #B45309;
  --danger-text: #B91C1C;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);

  --ease: cubic-bezier(.2, 0, 0, 1);
  --fast: 120ms;
  --normal: 160ms;

  /* Legacy aliases kept so existing page rules keep resolving. */
  --plane: var(--bg-2);
  --surface: var(--bg);
  --ink: var(--text);
  --ink2: var(--text-2);
  --muted: var(--text-3);
  --line: var(--border);
  --track: var(--bg-3);
  --good: var(--success);
  --warn: var(--warning);
  --bad: var(--danger);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 22px;
  color: var(--text);
  background: var(--bg-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
b, strong { font-weight: 600; }
code {
  font-family: var(--mono); font-size: 12px; line-height: 16px;
  background: var(--bg-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm);
  padding: 2px 6px; color: var(--text);
}
pre {
  font-family: var(--mono); font-size: 12px; line-height: 20px; margin: 0;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 16px; overflow: auto; color: var(--text);
}
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-subtle), 0 0 0 1px var(--accent); }

/* --- top bar + navigation ------------------------------------------------ */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px; padding: 8px 24px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
/* The Bayla wordmark: "Bayla" set bold and tight, closed by a blue full stop.
   Same mark as the promo video and the marketing site; see docs/BRAND.md. */
header .logo { font-size: 16px; font-weight: 700; letter-spacing: -.035em; display: inline-flex; align-items: baseline; gap: 8px; }
header .logo b { font-weight: 700; }
header .logo i { font-style: normal; color: var(--brand); }
header .logo span { color: var(--text-2); font-weight: 500; font-size: 14px; letter-spacing: -.01em; }
.tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tabs button {
  height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 500; line-height: 32px; cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.tabs button:hover { background: var(--bg-3); color: var(--text); }
.tabs button.active { background: var(--accent-subtle); color: var(--accent); }
.tabs button.ghost, .tabs #logout { color: var(--text-2); }

main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 64px; }

/* --- stat cards --------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }
.card .k { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.card .v { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .s { font-size: 12px; line-height: 16px; color: var(--text-3); margin-top: 4px; }
/* A metric with a catalog entry: hover the label to read what it means. */
.card .k.help { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
.card .v.nodata { color: var(--text-3); font-weight: 500; font-size: 18px; }
.stamp { font-size: 12px; line-height: 16px; color: var(--text-3); margin: -14px 0 20px; }

/* --- panels ------------------------------------------------------------- */
.panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; margin-bottom: 16px; overflow-x: auto; }
.banner { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger-text); border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; line-height: 20px; }
.panel h3 { margin: 0 0 8px; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.panel h3 .muted { font-weight: 400; margin-left: 4px; }
.panel p.muted { margin: 0 0 16px; }
.panel h4 { margin: 0 0 4px; font-size: 14px; line-height: 22px; font-weight: 600; }

/* --- tables -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 20px; }
thead th { position: sticky; top: 0; background: var(--bg); }
th {
  text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2);
  padding: 12px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
tbody tr:hover td { background: var(--bg-2); }
tr:last-child td { border-bottom: 0; }
td code { font-size: 12px; white-space: nowrap; }
/* Action cells carry the `row` class directly on the <td>; keep them table
   cells (a flex <td> breaks table layout and stacks the buttons). */
td.row { display: table-cell; white-space: nowrap; }
td.row button { display: inline-block; vertical-align: middle; margin-right: 4px; }
td.row button:last-child { margin-right: 0; }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* --- buttons ------------------------------------------------------------- */
button { font-family: inherit; }
button.primary, .btn.primary {
  height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 36px; cursor: pointer;
  transition: background-color var(--fast) var(--ease);
}
button.primary:hover { background: var(--accent-hover); }
button.primary[disabled] { opacity: .5; cursor: default; }
button.act, button.ghost {
  height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; line-height: 30px; cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
button.act:hover, button.ghost:hover { background: var(--bg-3); }
button.act.danger { color: var(--text-2); }
button.act.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--bg); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- forms --------------------------------------------------------------- */
label.f, label.pill { display: block; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-2); margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input:not([type]), select {
  height: 36px; width: 100%; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
select { padding-right: 32px; }
textarea {
  width: 100%; min-height: 80px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px; resize: vertical;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
input::placeholder, textarea::placeholder { color: var(--text-3); }

/* --- small bits ---------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.muted { color: var(--text-2); font-size: 13px; line-height: 20px; }
.msg { font-size: 13px; line-height: 20px; margin-top: 8px; min-height: 20px; }
.msg.ok { color: var(--success-text); }
.msg.err { color: var(--danger); }
.hide { display: none !important; }
.bar { height: 6px; border-radius: var(--radius-full); background: var(--bg-3); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); transition: width var(--normal) var(--ease); }

/* quality chips + badges (admin Products tab) */
.qchips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; }
.qchip {
  height: 28px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-full);
  background: var(--bg); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 500; line-height: 26px; cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.qchip:hover { background: var(--bg-3); color: var(--text); }
.qchip.on { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }
.qbadge {
  display: inline-block; font-size: 11px; line-height: 16px; font-weight: 500; color: var(--text-2);
  background: var(--bg-3); border-radius: var(--radius-full); padding: 2px 8px; margin: 2px 4px 2px 0; white-space: nowrap;
}

/* auth / login cards */
.login, .auth { max-width: 400px; margin: 64px auto; }
.login .panel, .auth .panel { padding: 24px; }
.authswitch { text-align: center; margin-top: 12px; font-size: 13px; }

/* plan cards (portal billing) */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.plancard { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; background: var(--bg); }
.plancard.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.plancard h4 { margin: 0; font-size: 14px; line-height: 22px; font-weight: 600; }
.plancard .price { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 8px; }
.plancard ul { margin: 8px 0 12px; padding-left: 16px; font-size: 13px; line-height: 20px; color: var(--text-2); }

/* empty states */
.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty .ic { font-size: 20px; color: var(--text-3); margin-bottom: 8px; }
.empty h4 { margin: 0 0 4px; font-size: 16px; line-height: 24px; color: var(--text); }
.empty p { margin: 0 0 16px; font-size: 14px; }

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

/* Phones: the header is not pinned and the tabs wrap onto as many lines as
   they need, so every tab is on screen and none hides off the right edge. */
@media (max-width: 720px) {
  header { position: static; padding: 8px 12px; flex-wrap: wrap; }
  .tabs { flex-wrap: wrap; max-width: 100%; }
  .tabs button { flex: 0 0 auto; }
}
