/* PresenceOS operator console — shared tokens + gallery/report/auth styles.
   Ported 1:1 from the old scripts/dashboard.mjs generator (now retired —
   this file + app.js render live, client-side, against an authenticated
   Supabase session instead of pre-rendering business data into HTML). */

:root {
  --bg: #16130f;
  --bg-panel: #1d1a15;
  --bg-panel-2: #221e18;
  --line: rgba(244, 235, 221, 0.1);
  --ink: #f4ebdd;
  --muted: #a6998a;
  --accent: #e1a45b;
  --accent-strong: #ff6a2b;
  --danger: #f36c6c;
  --radius: 14px;
}
* { box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100vh;
  background: radial-gradient(circle at 15% -10%, rgba(225, 164, 91, 0.12), transparent 45%), var(--bg);
  overflow-x: hidden;
}
a { color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 48px 20px 80px; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; margin: 0; }
button { font-family: inherit; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em;
  color: var(--badge-color); background: color-mix(in srgb, var(--badge-color) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--badge-color) 45%, transparent);
  border-radius: 999px; padding: 5px 12px; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--badge-color); flex: none; }
.badge--lg { font-size: 0.9rem; padding: 7px 16px; }
.badge--emphasis { box-shadow: 0 0 0 3px color-mix(in srgb, var(--badge-color) 25%, transparent); }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-word; }
.link:hover, .link:focus-visible { color: var(--accent-strong); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.link-list--sources { font-size: 0.82rem; opacity: 0.85; }
.cue {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; color: var(--ink); background: var(--bg-panel-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}
.cue-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25); flex: none; }
.cue-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  display: inline-flex; align-items: flex-end; width: 84px; height: 56px;
  border-radius: 10px; border: 1px solid var(--line); padding: 6px;
  box-shadow: inset 0 -18px 18px -10px rgba(0,0,0,0.35);
}
.swatch-label {
  font-size: 0.68rem; font-family: 'Inter', monospace; color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); background: rgba(0,0,0,0.35);
  border-radius: 4px; padding: 1px 5px;
}
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }
code { background: var(--bg-panel); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 0.85em; }

/* ---- auth (login) view ---------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 36px 32px; text-align: center;
}
.auth-title { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); letter-spacing: -0.01em; margin-bottom: 8px; }
.auth-sub { color: var(--muted); font-size: 0.92rem; line-height: 1.5; margin: 0 0 28px; }
.auth-field { text-align: left; margin-bottom: 18px; }
.auth-label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.auth-input {
  width: 100%; background: var(--bg-panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 0.98rem; padding: 12px 14px; min-height: 44px;
}
.auth-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  width: 100%; background: var(--accent); color: #1a120a; font-weight: 700; font-size: 0.95rem;
  border: none; border-radius: 999px; padding: 12px 20px; min-height: 44px; cursor: pointer;
  transition: background 150ms ease-out;
}
.btn-primary:hover, .btn-primary:focus-visible { background: var(--accent-strong); }
.btn-primary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-note { margin-top: 18px; font-size: 0.86rem; line-height: 1.5; }
.auth-note--error { color: var(--danger); }
.auth-note--success { color: var(--accent); }
.btn-signout {
  background: none; border: 1px solid var(--line); color: var(--muted); font-size: 0.82rem;
  border-radius: 999px; padding: 7px 16px; min-height: 36px; cursor: pointer; transition: border-color 150ms ease-out, color 150ms ease-out;
}
.btn-signout:hover, .btn-signout:focus-visible { color: var(--ink); border-color: var(--accent); }
.btn-signout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar (dashboard chrome, sign-out) ----------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.topbar-brand { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.05rem; }
.topbar-email { font-size: 0.8rem; color: var(--muted); margin-right: 12px; }

/* ---- loading / error states -------------------------------------------- */
.state-panel {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 64px 32px; text-align: center; color: var(--muted);
}
.state-panel--error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); color: var(--danger); }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--line); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- gallery ------------------------------------------------------------ */
header.page-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 40px; padding-bottom: 24px; border-bottom: 1px solid var(--line);
}
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); letter-spacing: -0.01em; }
h1 .divider { color: var(--muted); font-weight: 500; margin: 0 0.35em; }
.count-badge {
  font-size: 0.85rem; font-weight: 500; color: var(--muted); background: var(--bg-panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; white-space: nowrap;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform 200ms ease-out, border-color 200ms ease-out, box-shadow 200ms ease-out;
}
.card:hover { transform: translateY(-4px); border-color: rgba(225, 164, 91, 0.45); box-shadow: 0 16px 32px -16px rgba(0, 0, 0, 0.6); }
.card-visual {
  height: 104px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, hsl(var(--hue), 55%, 22%), hsl(calc(var(--hue) + 40), 65%, 14%));
  border-bottom: 1px solid var(--line);
}
.card-monogram { font-family: 'Fraunces', Georgia, serif; font-size: 2.5rem; font-weight: 600; color: rgba(244, 235, 221, 0.85); }
.card-body { padding: 16px 18px 6px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title { font-family: 'Fraunces', Georgia, serif; font-size: 1.05rem; font-weight: 600; margin: 0; line-height: 1.3; }
.card-meta { font-size: 0.78rem; color: var(--muted); margin: 0; }
.card-updated { font-size: 0.76rem; color: var(--muted); margin-top: auto; padding-top: 8px; }
.card-links {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); margin-top: 4px;
}
.card-links a, .card-links button.btn-detail {
  text-decoration: none; font-size: 0.82rem; font-weight: 600; padding: 7px 12px;
  border-radius: 999px; border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 5px;
  min-height: 32px; cursor: pointer; background: none;
}
.card-links .btn-detail { color: var(--ink); background: var(--bg-panel-2); font-family: inherit; }
.card-links .btn-detail:hover, .card-links .btn-detail:focus-visible { border-color: rgba(225,164,91,0.5); }
.card-links .btn-live { color: var(--accent); border-color: rgba(225,164,91,0.35); }
.card-links .btn-live:hover, .card-links .btn-live:focus-visible { color: var(--accent-strong); border-color: var(--accent-strong); }
.card-links a:focus-visible, .card-links button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.empty-state { border: 1px dashed var(--line); border-radius: var(--radius); padding: 64px 32px; text-align: center; color: var(--muted); }
.empty-title { font-family: 'Fraunces', Georgia, serif; font-size: 1.25rem; color: var(--ink); margin: 0 0 8px; }
.empty-body { max-width: 480px; margin: 0 auto; line-height: 1.6; }

/* ---- report (detail) view ---------------------------------------------- */
.report-header { padding-bottom: 24px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.breadcrumb {
  font-size: 0.8rem; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 16px;
  background: none; border: none; padding: 0; cursor: pointer; font-family: inherit;
}
.breadcrumb:hover, .breadcrumb:focus-visible { color: var(--accent); }
.report-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
h1.report-title { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem); letter-spacing: -0.01em; }
.report-meta { font-size: 0.9rem; color: var(--muted); margin: 0; }
.live-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 16px;
  background: var(--accent); color: #1a120a; font-weight: 700; font-size: 0.88rem;
  padding: 10px 18px; border-radius: 999px; text-decoration: none; min-height: 44px;
}
.live-btn:hover, .live-btn:focus-visible { background: var(--accent-strong); color: #1a120a; }
.live-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
section.report-section { margin-bottom: 40px; }
section.report-section h2 { font-size: 1.15rem; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.panel { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 6px; }
.field-value { font-size: 0.95rem; line-height: 1.6; margin: 0; }
.hook { font-family: 'Fraunces', Georgia, serif; font-size: 1.2rem; font-weight: 500; line-height: 1.5; color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 20px 24px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--muted); border: 2px solid var(--bg);
}
.timeline li.current::before { background: var(--accent-strong); }
.timeline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.92rem; }
.timeline-arrow { color: var(--muted); }
.timeline-ts { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.timeline-agent { font-size: 0.78rem; color: var(--muted); }
.timeline-operator-item::before { background: var(--accent); }
.timeline-operator-kind {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: rgba(225,164,91,0.14); border-radius: 4px; padding: 3px 8px;
}
.timeline-operator-kind--fix, .timeline-operator-kind--regenerate { color: #fb923c; background: rgba(251,146,60,0.14); }
.timeline-operator-kind--answer, .timeline-operator-kind--input { color: #60a5fa; background: rgba(96,165,250,0.14); }
.timeline-operator-body { margin: 8px 0 0; font-size: 0.9rem; line-height: 1.55; }
.plain-list { list-style: disc; margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; line-height: 1.55; }
.panel--questions { border-color: rgba(225, 164, 91, 0.45); background: color-mix(in srgb, var(--accent) 8%, var(--bg-panel)); }
.question-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.question-list li { font-size: 0.98rem; font-weight: 500; line-height: 1.5; padding-left: 28px; position: relative; }
.question-list li::before { content: '?'; position: absolute; left: 0; top: -1px; color: var(--accent); font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.1rem; }
.decision-list, .remark-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.decision-list li, .remark-list li { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.decision-list li:last-child, .remark-list li:last-child { border-bottom: none; padding-bottom: 0; }
.decision-text { font-weight: 600; margin: 0 0 4px; }
.decision-rationale { font-size: 0.88rem; color: var(--muted); margin: 0; line-height: 1.5; }
.remark-note { margin: 0 0 4px; line-height: 1.5; }
.remark-tag { font-size: 0.76rem; color: var(--muted); }
.tag-agent {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: rgba(225,164,91,0.12); border-radius: 4px; padding: 2px 6px; margin-right: 6px;
}
.empty-note { color: var(--muted); font-style: italic; font-size: 0.9rem; }
@media (min-width: 720px) {
  .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
}

/* ---- proposal panel + one-click-copy blocks (post-approval outreach) ---- */
.section-tag {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: #38bdf8; background: rgba(56,189,248,0.14); border-radius: 5px; padding: 3px 8px;
  vertical-align: middle; margin-left: 8px;
}
.panel--proposal { border-color: rgba(56,189,248,0.4); background: color-mix(in srgb, #38bdf8 6%, var(--bg-panel)); }
.send-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 0.9rem; font-weight: 600; color: #0b1220; background: #38bdf8;
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.send-link:hover { background: #7dd3fc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; color: var(--muted); }
.copy-block { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.copy-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--line);
}
.copy-label { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.copy-btn {
  font-size: 0.78rem; font-weight: 600; color: var(--accent); background: rgba(225,164,91,0.12);
  border: 1px solid rgba(225,164,91,0.35); border-radius: 6px; padding: 4px 12px; cursor: pointer;
}
.copy-btn:hover { background: rgba(225,164,91,0.22); }
.copy-btn.copied { color: #4ade80; border-color: rgba(74,222,128,0.5); background: rgba(74,222,128,0.14); }
.copy-src {
  margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
  line-height: 1.6; color: var(--ink); max-height: 340px; overflow-y: auto;
}
.proposal-signature { margin: 16px 0 0; font-style: italic; color: var(--muted); font-size: 0.9rem; }

/* ---- build cost panel ---------------------------------------------------- */
.panel--cost { }
.cost-total { margin: 0 0 14px; font-size: 1.5rem; font-weight: 700; color: var(--ink); }
.cost-total-sub { display: block; margin-top: 2px; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.cost-table-wrap { overflow-x: auto; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.cost-table th, .cost-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cost-table th { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.cost-table td { color: var(--ink); }
.cost-table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cost-table tfoot td { font-weight: 700; border-bottom: none; border-top: 2px solid var(--line); }

/* ---- deal panel (crm_deals) ---------------------------------------------- */
.panel--deal { border-color: rgba(74,222,128,0.35); background: color-mix(in srgb, #4ade80 5%, var(--bg-panel)); }
