/* HuanHuan CRM — dark "operator console" theme, ported from the Claude Design prototype
   ("HuanHuan CRM Demo.dc.html"). Keep this in sync with the design — see requirement-ui.md's
   "Interactive prototype" section for the sync workflow. */

:root {
  --bg: oklch(0.15 0.014 260);
  --bg-elev: oklch(0.19 0.014 260);
  --bg-elev2: oklch(0.24 0.014 260);
  --border: oklch(1 0 0 / 0.09);
  --border-strong: oklch(1 0 0 / 0.18);
  --ink: oklch(0.93 0.01 260);
  --ink-dim: oklch(0.68 0.012 260);
  --ink-faint: oklch(0.48 0.012 260);
  --accent: oklch(0.78 0.14 75);
  --accent-ink: oklch(0.18 0.03 75);
  --blue: oklch(0.72 0.13 250);
  --amber: oklch(0.78 0.14 75);
  --green: oklch(0.74 0.14 150);
  --grey: oklch(0.62 0.01 260);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html, body { margin: 0; background: var(--bg); font-family: var(--mono); color: var(--ink); }
input, select, button, textarea { font-family: var(--mono); }
::selection { background: oklch(0.78 0.14 75 / 0.35); }
a { color: var(--accent); }

/* App shell */
.app { min-height: 100vh; background: var(--bg); color: var(--ink); display: flex; }

.sidebar { width: 220px; flex: none; background: var(--bg-elev); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 0; }
.brand-mark { font-size: 14px; font-weight: 700; letter-spacing: 0.05em; color: var(--ink); padding: 0 20px; }
.brand-sub { font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.14em; margin-top: 5px; padding: 0 20px; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 12.5px; letter-spacing: 0.02em; color: var(--ink-dim); cursor: pointer; border-left: 2px solid transparent; background: none; border-top: none; border-right: none; border-bottom: none; width: 100%; text-align: left; text-decoration: none; }
.nav-item.active { color: var(--ink); border-left-color: var(--accent); background: oklch(1 0 0 / 0.035); }
.nav-dot { width: 5px; height: 5px; background: currentColor; flex: none; border-radius: 50%; }
.sidebar-foot { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid var(--border); }
.operator-name { font-size: 12px; font-weight: 700; color: var(--ink); }
.operator-role { font-size: 9.5px; color: var(--ink-faint); margin: 3px 0 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.link-btn { background: none; border: none; color: var(--ink-dim); font-size: 11px; letter-spacing: 0.03em; cursor: pointer; padding: 0 0 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); flex: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; flex-wrap: wrap; }
.crumb { color: var(--ink-dim); background: none; border: none; font-size: 12.5px; padding: 0; cursor: pointer; font-family: var(--mono); text-decoration: none; }
.crumb.current { color: var(--ink); font-weight: 700; }
.session-tag { display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--ink-faint); letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.content { padding: 28px; overflow-y: auto; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: 0.005em; color: var(--ink); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn-primary { width: 100%; background: var(--accent); color: var(--accent-ink); border: none; font-weight: 700; font-size: 12.5px; letter-spacing: 0.05em; text-transform: uppercase; padding: 12px 16px; border-radius: 2px; cursor: pointer; margin-top: 8px; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-solid { background: var(--accent); color: var(--accent-ink); border: none; font-weight: 700; font-size: 11.5px; letter-spacing: 0.03em; padding: 9px 14px; border-radius: 2px; cursor: pointer; }
.btn-solid:disabled { opacity: 0.5; cursor: default; }
.icon-btn, .row-link { background: none; border: 1px solid var(--border-strong); color: var(--ink-dim); font-size: 11px; padding: 6px 10px; border-radius: 2px; cursor: pointer; text-decoration: none; display: inline-block; }
.icon-btn:hover, .row-link:hover { color: var(--ink); border-color: var(--ink-dim); }
.icon-btn:disabled, .row-link:disabled { opacity: 0.5; cursor: default; color: var(--ink-dim); border-color: var(--border-strong); }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.tile { background: var(--bg-elev); border: 1px solid var(--border); padding: 16px 18px; border-radius: 3px; }
.tile-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 9px; }
.tile-value { font-size: 25px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Panels (cards) */
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 3px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.panel-title { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-dim); margin: 0; }
.panel-body { padding: 18px; }

/* Tables */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; padding: 10px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--ink); }
table.data tbody tr:last-child > td { border-bottom: none; }
table.data tbody tr:hover { background: oklch(1 0 0 / 0.025); }
.expand-row > td { background: oklch(1 0 0 / 0.02); padding: 4px 18px 18px 40px; }
.empty { padding: 48px 18px; text-align: center; color: var(--ink-faint); font-size: 12.5px; }
.empty-cta { margin-top: 14px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; border-radius: 2px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge.blue { color: var(--blue); background: oklch(0.72 0.13 250 / 0.14); }
.badge.amber { color: var(--amber); background: oklch(0.78 0.14 75 / 0.14); }
.badge.green { color: var(--green); background: oklch(0.74 0.14 150 / 0.14); }
.badge.grey { color: var(--grey); background: oklch(1 0 0 / 0.07); }

/* Toolbar / search / filters */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.search-input { background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); font-size: 12px; padding: 8px 12px; border-radius: 2px; min-width: 200px; }
.search-input:focus, select:focus { outline: 1px solid var(--accent); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: none; border: 1px solid var(--border-strong); color: var(--ink-dim); font-size: 10.5px; letter-spacing: 0.03em; padding: 6px 12px; border-radius: 20px; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.toolbar-note { margin-left: auto; font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.04em; }
select.inline-select { background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); font-size: 12px; padding: 8px 12px; border-radius: 2px; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { background: none; border: none; color: var(--ink-dim); font-size: 12.5px; letter-spacing: 0.02em; padding: 10px 4px; margin-right: 26px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

/* Trend / bar charts */
.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 18px; overflow-x: auto; }
.trend-col-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; width: 28px; height: 100%; justify-content: flex-end; background: none; border: none; padding: 0; cursor: pointer; font-family: var(--mono); }
.trend-bar { width: 100%; max-width: 18px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.85; }
.trend-bar.blue { background: var(--blue); }
.trend-bar.selected { opacity: 1; box-shadow: 0 0 0 1px var(--ink) inset; }
.trend-label { font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.05em; writing-mode: vertical-rl; }

/* Chips used inline for org tags etc. */
.org-chip { font-size: 10px; color: var(--ink-dim); background: oklch(1 0 0 / 0.05); border: 1px solid var(--border); padding: 3px 9px; border-radius: 20px; white-space: nowrap; margin-right: 4px; display: inline-block; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 50% 0%, oklch(0.19 0.02 75 / 0.25), transparent 55%), var(--bg); }
.login-card { width: 380px; max-width: 100%; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 3px; padding: 40px 36px; }
.login-brand { font-size: 11px; letter-spacing: 0.16em; color: var(--accent); text-transform: uppercase; margin-bottom: 8px; }
.login-title { font-size: 21px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.field { margin-bottom: 16px; }
.field label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); display: block; margin-bottom: 6px; }
.field input { width: 100%; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border-strong); color: var(--ink); font-size: 13.5px; padding: 10px 12px; border-radius: 2px; }
.field-error { color: var(--amber); font-size: 11.5px; margin-bottom: 12px; }
.login-foot { margin-top: 24px; font-size: 10.5px; color: var(--ink-faint); text-align: center; letter-spacing: 0.03em; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--bg-elev2); border: 1px solid var(--border-strong); color: var(--ink); font-size: 12px; padding: 11px 18px; border-radius: 2px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); z-index: 50; }

/* Mobile: collapse sidebar to a top bar, matching requirement-ui.md's mobile-first rule */
@media (max-width: 767px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
  .sidebar-foot { margin-top: 0; margin-left: auto; padding: 0; border-top: none; display: flex; align-items: center; gap: 10px; }
  .operator-name, .operator-role { display: none; }
  .brand-sub { display: none; }
  .nav-item { width: auto; padding: 6px 10px; border-left: none; border-bottom: 2px solid transparent; }
  .nav-item.active { border-left: none; border-bottom-color: var(--accent); }
  .main { height: auto; }
  .content { padding: 16px; }
}
