/* ============================================================
   XAI Portal — Minimal White Design System
   Inspired by Vercel / Linear / shadcn / SaaSFrame
   ------------------------------------------------------------
   Principles:
   - Pure white surface, near-black type, hairline 1px borders
   - No decorative shadow; hover uses tone + border shift
   - Typography and spacing carry the interface
   ============================================================ */

:root {
  /* Surfaces */
  --bg:            oklch(1 0 0);              /* pure white */
  --bg-subtle:     oklch(0.985 0 0);          /* hover / row alt */
  --bg-muted:      oklch(0.97 0 0);           /* code / textarea */
  --surface:       oklch(1 0 0);              /* cards */

  /* Lines */
  --border:        oklch(0.925 0 0);          /* hairline */
  --border-strong: oklch(0.86 0 0);           /* hover / focused */

  /* Text — contrast boosted 2026-07-17b for readability */
  --text:          oklch(0.16 0 0);           /* near-black, richer */
  --text-muted:    oklch(0.42 0 0);           /* labels, secondary (was 0.5) */
  --text-dim:      oklch(0.55 0 0);           /* placeholder-ish (was 0.62) */
  --text-inverse:  oklch(1 0 0);

  /* Brand / accent = restrained near-black (Vercel philosophy) */
  --accent:        oklch(0.18 0 0);
  --accent-hover:  oklch(0.28 0 0);
  --accent-fg:     oklch(1 0 0);

  /* Semantic (muted, low-chroma; only used for status) */
  --success:       oklch(0.5 0.13 149);
  --success-bg:    oklch(0.96 0.03 149);
  --success-border:oklch(0.87 0.06 149);
  --warning:       oklch(0.55 0.12 75);
  --warning-bg:    oklch(0.97 0.04 85);
  --warning-border:oklch(0.87 0.06 80);
  --danger:        oklch(0.53 0.19 27);
  --danger-bg:     oklch(0.97 0.03 27);
  --danger-border: oklch(0.88 0.06 27);
  --info:          oklch(0.5 0.12 253);
  --info-bg:       oklch(0.97 0.03 253);
  --info-border:   oklch(0.87 0.06 253);

  /* Focus ring (a11y) */
  --focus-ring:    oklch(0.62 0.19 259);

  /* Radius */
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadow (near-flat) */
  --shadow-sm: 0 1px 2px 0 rgb(15 15 15 / 0.04);
  --shadow-md: 0 4px 12px -2px rgb(15 15 15 / 0.06), 0 2px 4px -2px rgb(15 15 15 / 0.04);
  --shadow-lg: 0 12px 32px -8px rgb(15 15 15 / 0.10);

  /* Sizing */
  --content-max: 1120px;
  --topbar-h:    60px;
  --sidebar-w:   240px;
  --sidebar-w-collapsed: 68px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.0, 0.0, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Inter", "Segoe UI", "Noto Sans JP", "Hiragino Sans", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  /* 2026-08-24 P2 fix: CSS-native 和欧文間スペース (JIS text-spacing) */
  text-spacing: normal;
  text-spacing-trim: normal;
  text-autospace: ideograph-numeric ideograph-alpha;
  hanging-punctuation: allow-end;
  word-break: normal;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Typography basics */
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; color: var(--text); font-weight: 600; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 15px; line-height: 1.4; }
p  { margin: 0; }
a  { color: var(--text); text-decoration: none; transition: color 120ms var(--ease); }
a:hover { color: var(--accent-hover); }
code, kbd, samp, pre {
  font-family: ui-monospace, "SF Mono", "Geist Mono", "JetBrains Mono", Menlo, monospace;
  font-size: 12.5px;
}
code {
  background: var(--bg-muted);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
}
img { max-width: 100%; height: auto; display: block; }

/* Focus (a11y) */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Selection */
::selection { background: oklch(0.9 0 0); color: var(--text); }

/* ============================================================
   App shell (sidebar + topbar + content)
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 200ms var(--ease);
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open { transform: translateX(0); }
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,15,15,0.35);
  z-index: 150;
}
@media (max-width: 900px) {
  .sidebar-backdrop.open { display: block; }
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 10px 20px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand:hover { color: var(--text); }
.sidebar-brand .brand-name { font-size: 16px; font-weight: 600; }
.sidebar-brand .brand-tag { flex-shrink: 0; }

.nav-section {
  display: flex; flex-direction: column;
  margin-top: 6px;
}
.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--text-dim);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; color: currentColor; }
.nav-item .count {
  margin-left: auto;
  font-size: 11.5px;
  font-family: ui-monospace, "SF Mono", monospace;
  color: var(--text-muted);
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.nav-item .count.hot {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
.nav-item .external {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 10px;
}

/* Mobile menu button in topbar */
.menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.menu-btn:hover { background: var(--bg-subtle); }
@media (max-width: 900px) { .menu-btn { display: inline-flex; } }

/* Content wrapper (when using app-shell) */
.app-shell .topbar { padding-left: 20px; }
.app-shell .portal { max-width: none; padding-left: 28px; padding-right: 28px; }
@media (max-width: 640px) {
  .app-shell .portal { padding-left: 16px; padding-right: 16px; }
}
/* Hide topbar's brand-link on desktop when sidebar is present (avoid duplicate) */
@media (min-width: 901px) {
  .app-shell .topbar .brand-link { display: none; }
  .app-shell .topbar { justify-content: flex-end; gap: 12px; }
}

/* ============================================================
   Dashboard KPI stat cards (SaaSFrame-inspired)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 12px;
}
@media (min-width: 640px)  { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  min-height: 108px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.stat-label .icon {
  width: 14px; height: 14px;
  color: var(--text-dim);
}
.stat-value {
  font-family: ui-monospace, "SF Mono", "Geist Mono", monospace;
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-top: 2px;
}
.stat-value.hot { color: var(--danger); }
.stat-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
  display: flex; align-items: center; gap: 6px;
}
.stat-delta { display: inline-flex; align-items: center; gap: 3px; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-cta {
  position: absolute;
  top: 16px; right: 14px;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}
.stat-cta:hover { color: var(--text); }

/* ============================================================
   Activity feed
   ============================================================ */
.feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.feed-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.feed-header h3 { font-size: 14px; font-weight: 600; }
.feed-header a { font-size: 12px; color: var(--text-muted); }
.feed-header a:hover { color: var(--text); }
.feed-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background 120ms var(--ease);
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--bg-subtle); }
.feed-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.feed-dot.hot     { background: var(--danger); }
.feed-dot.success { background: var(--success); }
.feed-dot.warn    { background: var(--warning); }
.feed-title { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { font-size: 11.5px; color: var(--text-dim); font-family: ui-monospace, "SF Mono", monospace; }

/* Two-column dashboard layout */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
}
@media (min-width: 1024px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* ============================================================
   Topbar (existing, keep)
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 24px;
  padding-top: max(0px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand-link { display: flex; align-items: center; gap: 12px; color: inherit; }
.topbar .brand-link:hover { color: inherit; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 7px;
  display: inline-block;
  position: relative;
}
.logo-mark::after {
  content: "";
  position: absolute; inset: 6px;
  border: 1.5px solid var(--accent-fg);
  border-radius: 2px;
  opacity: 0.92;
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-tag {
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 500;
  background: var(--bg);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* Breadcrumb (topbar center) */
.crumbs {
  display: none;
  flex: 1;
  min-width: 0;
  margin: 0 24px;
  font-size: 13.5px;
  color: var(--text-dim);
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
@media (min-width: 720px) { .crumbs { display: flex; } }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-dim); opacity: 0.6; }
.crumbs .current { color: var(--text); font-weight: 500; }

/* Cmd-K trigger (topbar search-hint button) */
.cmdk-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 12px 0 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 120ms var(--ease), color 120ms var(--ease);
  font-family: inherit;
}
.cmdk-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.cmdk-trigger .cmdk-kbd {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-subtle);
}
.cmdk-trigger svg { flex-shrink: 0; }
@media (max-width: 720px) {
  .cmdk-trigger .cmdk-label,
  .cmdk-trigger .cmdk-kbd { display: none; }
  .cmdk-trigger { width: 36px; padding: 0; justify-content: center; }
}

/* User pill (topbar right) */
.user-pill {
  position: relative;
}
.user-pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px 0 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.user-pill-btn:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0;
  flex-shrink: 0;
}
.user-pill-email {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) { .user-pill-email { display: none; } }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  display: none;
}
.user-menu.open { display: block; }
.user-menu-header {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-menu-header .email {
  font-size: 12.5px; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-header .exp {
  font-size: 11px; color: var(--text-dim); margin-top: 4px;
  font-family: ui-monospace, "SF Mono", monospace;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.user-menu-item:hover { background: var(--bg-subtle); }
.user-menu-item.danger:hover { background: var(--danger-bg); color: var(--danger); }
.user-menu-item svg { color: var(--text-muted); }
.user-menu-item.danger:hover svg { color: var(--danger); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }

.btn-danger {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius);
  font-size: 14px;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }

.btn-block { width: 100%; }
.btn-lg { min-height: 44px; font-size: 14px; padding: 0 18px; }

/* ============================================================
   Main container
   ============================================================ */
.portal {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 40px 28px 96px;
}
.hero { padding: 12px 0 32px; }
.hero h1 {
  font-size: 34px;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}
.hero-sub {
  color: var(--text-muted);
  font-size: 15.5px;
  line-height: 1.55;
  max-width: 680px;
}

/* Section */
.section { margin-top: 56px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 18px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.section-title .section-meta {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  font-size: 13px;
}

/* ============================================================
   Cards & Card grid
   ============================================================ */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 640px)  { .cards { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(3, 1fr); gap: 18px; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  display: flex; flex-direction: column; gap: 12px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease), transform 140ms var(--ease);
  position: relative;
  overflow: hidden;
  min-height: 168px;
}
a.card:hover, a.card:focus-visible {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
a.card:active { transform: translateY(0); }
.card-info { cursor: default; }
.card-cat {
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.card-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.3;
}
.card-desc {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
  flex: 1;
}
.card-badge {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.card-badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.badge-active {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}
.badge-waiting {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}
.badge-genesis {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 28px 40px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
  margin-top: 56px;
}

/* ============================================================
   Auth (login / setup)
   ============================================================ */
.center-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(1200px 500px at 20% -10%, oklch(0.98 0 0), transparent 60%),
    radial-gradient(1200px 500px at 90% 110%, oklch(0.98 0 0), transparent 60%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-hint { color: var(--text-muted); font-size: 14px; line-height: 1.55; margin-bottom: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; }
.label-text {
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.input::placeholder { color: var(--text-dim); }
.input:hover { border-color: var(--border-strong); }
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.9 0 0);
}
.input-code {
  letter-spacing: 0.3em;
  font-family: ui-monospace, "SF Mono", "Geist Mono", monospace;
  font-size: 18px;
  text-align: center;
}

.auth-footer { margin-top: 20px; text-align: center; }
.link-muted { color: var(--text-dim); font-size: 12px; }
.link-muted:hover { color: var(--text-muted); }

.status { font-size: 13px; padding: 4px 0; min-height: 20px; }
.status.ok  { color: var(--success); }
.status.err { color: var(--danger); }

/* ============================================================
   Approvals list & detail
   ============================================================ */
.tabs {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 4px 0 24px;
}
.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.list { display: grid; gap: 12px; }
.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.list-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}
.list-item .summary {
  font-size: 16px;
  color: var(--text);
  margin: 10px 0 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-weight: 500;
}
.list-item .meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-muted); gap: 8px;
  flex-wrap: wrap;
}
.amount {
  font-family: ui-monospace, "SF Mono", "Geist Mono", monospace;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Approval kind badge (colored pill) */
.kind-badge {
  display: inline-flex; align-items: center;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.kind-A_product_go { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.kind-B_allocation { background: oklch(0.97 0.03 200); color: oklch(0.5 0.13 220); border-color: oklch(0.86 0.05 220); }
.kind-C_exception  { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

.status-approved { color: var(--success); font-weight: 600; }
.status-rejected { color: var(--danger); font-weight: 600; }
.status-expired  { color: var(--text-dim); font-weight: 600; }
.remaining-hot   { color: var(--danger); font-weight: 600; }

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

/* Detail */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 12px;
}
.detail-card .summary {
  font-size: 17px;
  margin: 10px 0 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.meta-row {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.amount-big {
  font-family: ui-monospace, "SF Mono", "Geist Mono", monospace;
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.detail-md {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
  white-space: pre-wrap;
  line-height: 1.7;
  max-height: 48vh;
  overflow-y: auto;
  color: var(--text);
}

.actions {
  display: flex; gap: 10px; margin-top: 24px;
}
.actions .btn { flex: 1; }

.decided-banner {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}
.decided-approved { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.decided-rejected { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.decided-expired  { background: var(--bg-muted);   color: var(--text-muted); border-color: var(--border); }

/* Reject form */
.reject-form {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  display: none;
}
.reject-form.open { display: block; }
.reject-form label { display: block; margin-bottom: 12px; }
.reject-form .label-text {
  display: block;
  margin-bottom: 8px;
}
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 120ms var(--ease), background 120ms var(--ease), color 120ms var(--ease);
}
.radio-chip:hover { border-color: var(--border-strong); color: var(--text); }
.radio-chip input { margin: 0; accent-color: var(--accent); }
.radio-chip:has(input:checked) {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  min-height: 88px;
  resize: vertical;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.9 0 0);
}

/* ============================================================
   Customer Center specific
   ============================================================ */
.remaining {
  color: var(--text-muted);
  font-size: 13px;
  margin: 4px 0 20px;
  display: inline-flex; align-items: center; gap: 6px;
}
.remaining::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
}
.score {
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.guard-fail {
  color: var(--danger);
  font-weight: 600;
  margin-left: 8px;
  font-size: 11px;
}

.doc-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin: 12px 0;
}
.doc-section h2 {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.doc-section pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
}
.doc-section .meta { font-size: 12px; color: var(--text-muted); margin: 4px 0; }

/* Sticky action bar on detail pages */
.action-bar {
  display: flex; gap: 10px;
  position: sticky; bottom: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-top: 20px;
}
.action-bar .btn { flex: 1; min-height: 44px; font-size: 14px; font-weight: 600; }

/* Approve/Reject shortcuts (semantic colored) */
.btn-approve {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-approve:hover:not(:disabled) { background: var(--accent-hover); }
.btn-reject {
  background: var(--bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-reject:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }

/* ============================================================
   Utilities
   ============================================================ */
.muted     { color: var(--text-muted); }
.dim       { color: var(--text-dim); }
.mono      { font-family: ui-monospace, "SF Mono", "Geist Mono", monospace; font-variant-numeric: tabular-nums; }
.text-sm   { font-size: 12.5px; }
.text-xs   { font-size: 11.5px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.hidden { display: none; }

/* ============================================================
   Cmd-K Palette (shadcn-inspired command dialog)
   ============================================================ */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 15, 15, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 88px 20px 20px;
  animation: cmdk-fade 140ms var(--ease);
}
@keyframes cmdk-fade { from { opacity: 0; } to { opacity: 1; } }
.cmdk-panel {
  width: 100%;
  max-width: 540px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -12px rgb(15 15 15 / 0.25);
  overflow: hidden;
  animation: cmdk-pop 160ms var(--ease);
}
@keyframes cmdk-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-row svg { flex-shrink: 0; color: var(--text-muted); }
.cmdk-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.cmdk-input::placeholder { color: var(--text-dim); }
.cmdk-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-group {
  padding: 8px 8px 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}
.cmdk-item:hover, .cmdk-item.active {
  background: var(--bg-subtle);
}
.cmdk-item .icon {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: var(--bg-muted);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.cmdk-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .hint {
  font-size: 11.5px; color: var(--text-dim);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-subtle);
  font-family: ui-monospace, "SF Mono", monospace;
}
.cmdk-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.cmdk-footer {
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-dim);
  background: var(--bg-subtle);
}
.cmdk-footer kbd {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 10.5px;
  background: var(--bg);
  color: var(--text-muted);
}

/* ============================================================
   Live count chip (on home Ops cards)
   ============================================================ */
.count-chip {
  align-self: flex-start;
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 2px 0;
}
.count-chip .num {
  font-family: ui-monospace, "SF Mono", "Geist Mono", monospace;
  font-size: 22px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.count-chip.hot .num { color: var(--danger); }
.count-chip.zero  .num { color: var(--text-dim); }
.count-chip .label { font-size: 12.5px; color: var(--text-muted); }

/* ============================================================
   Detail 2-column (approval-detail, desktop only)
   ============================================================ */
.detail-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  margin-top: 12px;
}
@media (min-width: 960px) {
  .detail-2col { grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; }
}
.detail-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: static;
}
@media (min-width: 960px) {
  .detail-side { position: sticky; top: calc(var(--topbar-h) + 20px); }
}
.detail-side .side-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 4px;
}
.detail-side .side-value {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 14px;
}
.detail-side hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.loading::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 800ms linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Mobile refinements (iPhone-first — Reo uses daily) */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .portal { padding: 20px 16px 96px; }
  .hero { padding: 4px 0 20px; }
  .hero h1 { font-size: 26px; letter-spacing: -0.025em; }
  .hero-sub { font-size: 14.5px; }
  .topbar { padding: 0 16px; height: 56px; }
  .brand-tag { display: none; }
  .section { margin-top: 40px; }
  .section-title { font-size: 11px; padding-bottom: 10px; margin-bottom: 14px; }
  .card { padding: 18px 18px 16px; min-height: auto; }
  .card-name { font-size: 17px; }
  .card-desc { font-size: 14px; }
  .cards { gap: 12px; }
  .detail-card { padding: 20px 18px; }
  .detail-card .summary { font-size: 16px; }
  .detail-md { font-size: 14px; padding: 14px; }
  .actions { flex-direction: column; gap: 8px; }
  .actions .btn { min-height: 48px; font-size: 15px; }
  .list-item { padding: 16px 16px 14px; }
  .list-item .summary { font-size: 15px; }
  /* Sticky bottom bar on detail — reachable one-hand */
  .action-bar {
    position: fixed;
    left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
    margin: 0;
  }
  main.portal:has(.action-bar) { padding-bottom: 120px; }
  /* Bigger tap targets */
  .btn { min-height: 44px; }
  .btn-ghost { width: 40px; height: 40px; }
  /* Radio chips larger */
  .radio-chip { padding: 10px 14px; font-size: 14px; }
}

/* Dark mode reservation (kept off by default; XAI is white-first per Reo 2026-07-17) */
@media (prefers-color-scheme: dark) {
  /* Intentionally left unset — Reo wants pure white minimal.
     If ever needed, override :root variables here. */
}
