/* Unified Ops Portal: shared look from the approved prototypes.
   Brand colours (--primary, --sidebar, --accent) come from /brand.css per brand and outlet. */
:root {
  --primary: #A21CAF; --sidebar: #1A0A28; --accent: #E879F9;
  --ink: #111827; --ink-2: #374151; --muted: #6B7280; --line: #E5E7EB; --line-soft: #F1F5F9;
  --bg: #F4F5F7; --card: #FFFFFF;
  --auto-bg: #E9EEF4; --auto-ink: #1E293B;          /* filled by the system */
  --staff-bg: #FFFBEB; --staff-line: #D97706;        /* staff fills in */
  --good: #166534; --good-bg: #DCFCE7; --warn: #92400E; --warn-bg: #FEF3C7; --bad: #991B1B; --bad-bg: #FEE2E2;
  --radius: 8px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--primary); }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.visually-hidden { position: absolute; left: -9999px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, monospace; }
.wrap { word-break: break-all; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--sidebar); color: #fff; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-brand { display: flex; flex-direction: column; padding: 4px 8px 16px; }
.sidebar-brand .product { font-weight: 700; font-size: 16px; }
.sidebar-brand .brand-name { font-size: 12px; color: #E9D5FF; }
.nav-group { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #C4B5D9; padding: 14px 8px 4px; font-weight: 600; }
.nav-item { color: #F3E8FF; text-decoration: none; padding: 9px 10px; border-radius: 6px; min-height: 40px; display: flex; align-items: center; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .spacer { flex: 1 1 auto; }
.topbar .who { color: var(--ink-2); font-size: 13px; }
.switcher select { height: 36px; border: 1px solid #D1D5DB; border-radius: 6px; padding: 0 8px; font: inherit; background: #fff; }
.content { padding: 20px 24px 32px; max-width: 1760px; width: 100%; }
.footer { padding: 12px 24px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* Cards, forms, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.table-card { padding: 0; overflow-x: auto; }
.btn { height: 36px; padding: 0 14px; border: 1px solid #D1D5DB; background: #fff; border-radius: 6px; font: inherit; font-weight: 500; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-block { width: 100%; height: 44px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input { height: 36px; border: 1px solid #D1D5DB; border-radius: 6px; padding: 0 10px; font: inherit; background: #fff; color: var(--ink); }
.input-staff { background: var(--staff-bg); border: 1.5px solid var(--staff-line); }
.value-auto { display: inline-block; background: var(--auto-bg); color: var(--auto-ink); border-radius: 4px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.legend { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: #4B5563; }
.legend-swatch { width: 22px; height: 14px; border: 1.5px solid var(--staff-line); background: var(--staff-bg); border-radius: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.span-2 { grid-column: 1 / -1; }
.row-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert { padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.chip { padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.chip-muted { background: var(--line-soft); color: #475569; }
.facts { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; font-weight: 500; }
.empty-state h2 { font-size: 16px; }
code.secret { word-break: break-all; font-size: 15px; letter-spacing: .08em; background: var(--auto-bg); padding: 2px 6px; border-radius: 4px; }

/* Tables with sortable headers */
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th { padding: 0; border-bottom: 1px solid var(--line); background: #FAFAFB; font-size: 12px; color: #4B5563; font-weight: 600; }
.table th > span, .table th > button { display: flex; align-items: center; gap: 4px; width: 100%; padding: 10px 12px; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; }
.table th > button { cursor: pointer; }
.table th > button::after { content: "↕"; color: #9CA3AF; }
.table th[aria-sort="ascending"] > button::after { content: "▲"; color: var(--primary); }
.table th[aria-sort="descending"] > button::after { content: "▼"; color: var(--primary); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sign-in pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 400px; max-width: 100%; }
.auth-card h1 { margin-bottom: 14px; }

/* Phone */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; }
  .sidebar-brand, .nav-group { display: none; }
  .nav-item { white-space: nowrap; }
  .topbar, .content { padding-left: 12px; padding-right: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}
