/* Hi5 — light theme only. Left rail ported from CCI CRM; under 768px it becomes a hamburger drawer. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #e1e5ea;
  --primary: #0b7285;
  --primary-ink: #ffffff;
  --primary-soft: #e3f4f7;
  --danger: #c92a2a;

  --lv1: #f08c00; --lv1-bg: #fff0db; --lv1-ink: #8a4300;
  --lv2: #4c6ef5; --lv2-bg: #e3e9ff; --lv2-ink: #2b3fa0;
  --lv3: #2f9e44; --lv3-bg: #dcf5e0; --lv3-ink: #1b6b2c;

  --out: #c92a2a; --out-bg: #ffe3e3;
  --maybe: #a46a00; --maybe-bg: #fff3bf;
  --late: #5f3dc4; --late-bg: #ece6ff;

  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; }
.muted { color: var(--muted); }
.warn { color: var(--danger); }
.pre { white-space: pre-wrap; }
.spacer { flex: 1; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c5ccd4; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: #095c6b; border-color: #095c6b; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--danger-text { color: var(--danger); }
.btn--sm { min-height: 34px; padding: 0 11px; font-size: 0.9rem; }
.btn--lg { min-height: 48px; padding: 0 22px; font-size: 1.02rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn--danger { color: var(--danger); }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font: inherit; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ── gates (sign in / denied) ────────────────────────────────────────────── */
.gate { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 36px 28px; max-width: 380px; width: 100%; text-align: center; display: grid; gap: 14px; justify-items: center; }
.gate-box h1 { font-size: 2rem; }
.gate-sub { color: var(--muted); margin: 0; }
.gate-logo { border-radius: 16px; }

/* ── shell: left rail ported from CCI CRM (libre-crm-cci css/chrome.css) ── */
:root {
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-text-bright: #f1f5f9;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-section: #94a3b8;
  --primary-rgb: 11,114,133;
}
.app-layout { min-height: 100vh; }
.sidebar {
  width: 210px; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000;
  transform: translateX(-210px); transition: transform 0.25s ease, width 0.25s ease; overflow: visible;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 999; }
.sidebar-overlay.visible { display: block; }
.main-content { min-width: 0; }
.main { padding: 24px 28px 48px; outline: none; }

.sidebar-header { padding: 0 0.875rem; height: 56px; border-bottom: 1px solid var(--sidebar-border); display: flex; align-items: center; gap: 0.625rem; flex-shrink: 0; background: #fff; }
.sidebar-logo { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.sidebar-logo img { width: 36px; height: 36px; border-radius: 8px; }
.sidebar-app-name { font-size: 0.9375rem; font-weight: 700; color: var(--text); line-height: 1.2; white-space: nowrap; }
.sidebar-app-subtitle { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }

.sidebar-nav { flex: 1; padding: 0.75rem 0; list-style: none; margin: 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.875rem; color: var(--sidebar-text);
  font-size: 0.875rem; font-weight: 500; min-height: 44px; text-decoration: none; border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-text-bright); }
.sidebar-nav a.active { background: rgba(var(--primary-rgb), 0.28); color: #fff; border-left-color: #3bc9db; }
.sidebar-nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section-label { padding: 0.75rem 0.875rem 0.25rem; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--sidebar-section); }
.nav-group-items { list-style: none; margin: 0; padding: 0; }
.nav-group-collapsible:not(.expanded) > .nav-group-items { display: none; }
button.nav-section-label {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.5rem 0.875rem; min-height: 44px;
  background: none; border: none; font-family: inherit; cursor: pointer; text-align: left; transition: background 0.15s, color 0.15s;
}
button.nav-section-label:hover { background: var(--sidebar-hover); color: var(--sidebar-text-bright); }
button.nav-section-label:focus-visible { outline: 2px solid #3bc9db; outline-offset: -2px; }
.nav-group-title { flex: 1; min-width: 0; }
.sidebar-nav .nav-group-chevron { width: 12px; height: 12px; flex-shrink: 0; transition: transform 0.15s ease; }
.nav-group-collapsible.expanded > .nav-group-toggle .nav-group-chevron { transform: rotate(90deg); }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }
.sidebar-profile { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 0.75rem; min-width: 0; }
.sidebar-profile > div:last-child { min-width: 0; }
.sidebar-avatar { width: 32px; height: 32px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 600; color: var(--sidebar-text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.6875rem; color: var(--sidebar-section); }
.btn-signout { width: 100%; padding: 0.5rem 0.75rem; background: none; border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; font-size: 0.8125rem; color: var(--sidebar-text); cursor: pointer; font-family: inherit; }
.btn-signout:hover { background: var(--sidebar-hover); color: var(--sidebar-text-bright); }

.sidebar-collapse-btn {
  position: absolute; top: 42px; right: -14px; width: 28px; height: 28px; border-radius: 50%; background: #fff;
  border: 1px solid var(--border); color: var(--muted); cursor: pointer; display: none; align-items: center; justify-content: center;
  z-index: 1001; padding: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.sidebar-collapse-btn:hover { color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.sidebar-collapse-btn svg { width: 14px; height: 14px; }

.mobile-topbar {
  display: flex; align-items: center; gap: 0.75rem; padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 1rem 0.6rem;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 800;
}
.mobile-topbar-title { font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-hamburger { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; color: var(--text); border-radius: 6px; flex-shrink: 0; }
.btn-hamburger svg { width: 20px; height: 20px; }
.btn-hamburger:hover { background: var(--bg); }

@media (min-width: 768px) {
  .sidebar { transform: translateX(0); }
  .main-content { margin-left: 210px; }
  .sidebar-overlay { display: none !important; }
  .mobile-topbar { display: none; }
  .sidebar-collapse-btn { display: flex; }
  button.nav-section-label { min-height: 36px; }
  .app-layout.sidebar-collapsed .sidebar { width: 56px; }
  .app-layout.sidebar-collapsed .main-content { margin-left: 56px; }
  .app-layout.sidebar-collapsed .sidebar-header { padding: 0; justify-content: center; }
  .app-layout.sidebar-collapsed .sidebar-header > div:last-child { display: none; }
  .app-layout.sidebar-collapsed .sidebar-logo, .app-layout.sidebar-collapsed .sidebar-logo img { width: 32px; height: 32px; }
  .app-layout.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 0.625rem 0; border-left: none; position: relative; gap: 0; }
  .app-layout.sidebar-collapsed .sidebar-nav a span { display: none; }
  .app-layout.sidebar-collapsed .sidebar-nav a svg { width: 20px; height: 20px; }
  .app-layout.sidebar-collapsed .nav-section-label { display: none; }
  /* Let the hover label escape the 56px column (the scroll box would clip it). */
  .app-layout.sidebar-collapsed .sidebar-nav { overflow: visible; }
  /* Headers hide in the collapsed rail, so every group's items must stay visible. */
  .app-layout.sidebar-collapsed .nav-group > .nav-group-items { display: block; }
  .app-layout.sidebar-collapsed .sidebar-footer { padding: 0.5rem; }
  .app-layout.sidebar-collapsed .sidebar-profile { justify-content: center; }
  .app-layout.sidebar-collapsed .sidebar-profile > div:last-child { display: none; }
  .app-layout.sidebar-collapsed .btn-signout { font-size: 0; padding: 0.5rem; display: flex; justify-content: center; }
  .app-layout.sidebar-collapsed .btn-signout::before {
    content: ''; display: block; width: 16px; height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E") no-repeat center;
  }
  .app-layout.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
  .app-layout.sidebar-collapsed .sidebar-nav a:hover::after {
    content: attr(data-label); position: absolute; left: 56px; top: 50%; transform: translateY(-50%);
    background: var(--text); color: #fff; padding: 4px 10px; border-radius: 4px; font-size: 0.75rem; font-weight: 500;
    white-space: nowrap; z-index: 200; pointer-events: none;
  }
}

.page { max-width: 1040px; margin: 0 auto; display: grid; gap: 16px; }
.page--narrow { max-width: 760px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.page-head .head-title { margin-right: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.page-head .head-title h1 { margin-right: 0; }
.head-sub { color: var(--muted); width: 100%; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { width: 100%; text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.loading, .empty { color: var(--muted); }
.error-box { background: var(--out-bg); color: var(--out); padding: 12px 14px; border-radius: 10px; }
.meta { color: var(--muted); font-size: 0.88rem; margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin-right: auto; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }


/* Tables (Users, Usage) */
.card--flush { padding: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th { text-align: left; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td .chip { margin-left: 6px; }
.data-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .actions { text-align: right; white-space: nowrap; }
.data-table .wrap { overflow-wrap: anywhere; }
.data-table tr.is-off td { color: var(--muted); }

/* Usage */
.u-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.u-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.u-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 4px; }
.u-tile-label { font-size: 0.82rem; color: var(--muted); }
.u-tile-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.u-card { position: relative; }
.u-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; }
.u-legend-item, .u-who { display: inline-flex; align-items: center; gap: 6px; }
.u-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.u-plot { width: 100%; min-height: 220px; }
.u-plot svg { display: block; overflow: visible; }
.u-empty { display: grid; place-items: center; min-height: 160px; margin: 0; }
.u-grid { stroke: #e9ecf1; stroke-width: 1; }
.u-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.u-hit { fill: transparent; outline: none; }
.u-hit.is-hover { fill: rgba(17, 21, 28, .05); }
.u-tip { position: absolute; top: 58px; z-index: 2; min-width: 160px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(17,21,28,.14); padding: 8px 10px; font-size: 0.85rem; display: grid; gap: 3px; pointer-events: none; }
.u-tip-row { display: flex; align-items: center; gap: 6px; }
.u-tip-total { color: var(--muted); margin-top: 2px; }
.u-details summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.u-details .data-table { margin-top: 8px; }

/* ── Home: big squares (NJAW field-app style) ──────────────────────────── */
.home { max-width: 900px; }
.home-greeting { font-size: 1.35rem; }
.today-card {
  display: grid; gap: 4px; padding: 18px 20px; border-radius: 16px; text-decoration: none;
  background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(11,114,133,.25);
}
.today-card:active { transform: scale(0.99); }
.today-card--empty { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.today-kicker { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.today-title { font-size: 1.35rem; font-weight: 750; line-height: 1.2; }
.today-sub { font-size: 0.95rem; opacity: 0.92; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tile {
  position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  aspect-ratio: 1 / 0.85; padding: 16px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05); color: var(--text); text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.08); border-color: var(--primary); }
.tile:active { transform: scale(0.97); }
.tile.is-off { opacity: 0.55; }
.tile-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.tile-icon svg { width: 30px; height: 30px; }
.tile-title { font-size: 1.1rem; font-weight: 700; }
.tile-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.3; }
.tile-badge { position: absolute; top: 10px; right: 10px; background: var(--lv1-bg); color: var(--lv1-ink); font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }

/* ── Today's plan ────────────────────────────────────────────────────────── */
.today .page-head h1 { font-size: 1.5rem; }
.plan-text { margin: 0; font-size: 1.08rem; line-height: 1.6; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.focus-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.focus-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border-radius: 10px; }
.focus-skill { font-weight: 700; font-size: 1.05rem; }
.goal-group { display: grid; gap: 6px; }
.goal-group + .goal-group { margin-top: 6px; }
.goal-group h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.btn--block { width: 100%; }
.sticky-action { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 5; }
.sticky-action .btn { box-shadow: 0 6px 18px rgba(11,114,133,.35); min-height: 56px; font-size: 1.1rem; }

/* ── chips ───────────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.chip--out { background: var(--out-bg); color: var(--out); border-color: transparent; }
.chip--maybe { background: var(--maybe-bg); color: var(--maybe); border-color: transparent; }
.chip--late { background: var(--late-bg); color: var(--late); border-color: transparent; }
.chip--done { background: var(--lv3-bg); color: var(--lv3-ink); border-color: transparent; }
.chip--due { background: var(--lv1-bg); color: var(--lv1-ink); border-color: transparent; }
.chip--cancel { background: #eceff3; color: #49525e; border-color: transparent; }
.type-chip { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); }
.type-scored { background: var(--primary-soft); color: var(--primary); }

/* Level chips, dots and picker */
.lv-chip { display: inline-flex; padding: 2px 9px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.lv-chip.lv-1, .lv-btn.lv-1.is-on { background: var(--lv1-bg); color: var(--lv1-ink); }
.lv-chip.lv-2, .lv-btn.lv-2.is-on { background: var(--lv2-bg); color: var(--lv2-ink); }
.lv-chip.lv-3, .lv-btn.lv-3.is-on { background: var(--lv3-bg); color: var(--lv3-ink); }
.lv-btn.lv-1.is-on { border-color: var(--lv1); }
.lv-btn.lv-2.is-on { border-color: var(--lv2); }
.lv-btn.lv-3.is-on { border-color: var(--lv3); }
.lv-text-1 { color: var(--lv1-ink); } .lv-text-2 { color: var(--lv2-ink); } .lv-text-3 { color: var(--lv3-ink); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.lv-bg-1 { background: var(--lv1); } .lv-bg-2 { background: var(--lv2); } .lv-bg-3 { background: var(--lv3); }
.lv-picker { display: inline-grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lv-btn { min-height: 40px; min-width: 0; padding: 0 8px; border: 1.5px solid var(--border); background: var(--surface); border-radius: 9px; font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.lv-picker--sm .lv-btn { min-height: 34px; font-size: 0.8rem; }
.legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.legend-item { display: inline-flex; gap: 5px; align-items: center; font-size: 0.82rem; color: var(--muted); }
.legend-hint { color: var(--muted); font-size: 0.82rem; }

/* ── segmented + filters ─────────────────────────────────────────────────── */
.seg { display: inline-flex; background: #eaedf1; border-radius: 10px; padding: 3px; }
.seg-btn { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg-btn.is-on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fchip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer; color: var(--text); }
.fchip.is-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.fchip-n { color: var(--muted); font-weight: 500; }
.search { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; font: inherit; background: var(--surface); }

/* ── calendar ────────────────────────────────────────────────────────────── */
.cal-list { display: grid; gap: 8px; }
.week-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 10px 0 2px; }
.cal-row { display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.cal-row:hover { border-color: #c5ccd4; }
.cal-row.is-today { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.cal-row.is-cancelled .cal-name, .cal-row.is-cancelled .cal-sub { text-decoration: line-through; color: var(--muted); }
.cal-date { display: grid; justify-items: center; line-height: 1.1; }
.cal-dow, .cal-mon { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }
.cal-dom { font-size: 1.4rem; font-weight: 700; }
.cal-main { min-width: 0; display: grid; gap: 4px; }
.cal-title { display: flex; gap: 8px; align-items: center; min-width: 0; }
.cal-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-sub { color: var(--muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── event ───────────────────────────────────────────────────────────────── */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; white-space: pre-wrap; min-width: 0; overflow-wrap: anywhere; }
.att-summary { margin: 0; color: var(--muted); font-weight: 600; }
.att-list { list-style: none; margin: 0; padding: 0; display: grid; }
.att-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.att-row:first-child { border-top: 0; }
.att-who { display: grid; gap: 2px; min-width: 0; flex: 1 1 180px; }
.att-name { font-weight: 650; color: var(--text); text-decoration: none; }
.att-role, .att-by { color: var(--muted); font-size: 0.82rem; }
.att-note { font-size: 0.9rem; }
.att-seg { display: inline-grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: #eef0f3; border-radius: 10px; padding: 3px; }
.att-btn { border: 0; background: transparent; min-height: 36px; padding: 0 12px; border-radius: 8px; font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.att-btn.is-on.att-in { background: var(--surface); color: var(--lv3-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.att-btn.is-on.att-late { background: var(--late-bg); color: var(--late); }
.att-btn.is-on.att-maybe { background: var(--maybe-bg); color: var(--maybe); }
.att-btn.is-on.att-out { background: var(--out-bg); color: var(--out); }

/* ── debrief ─────────────────────────────────────────────────────────────── */
.save-status { font-size: 0.85rem; color: var(--muted); }
.save-status.is-error { color: var(--danger); }
.db-list { display: grid; gap: 8px; }
.db-search { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 0; background: var(--bg); }
.db-search .search { flex: 1; font-size: 16px; }
.db-count { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.db-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 12px; }
.db-card.is-open { border-color: var(--primary); }
.db-card.is-out .db-name { color: var(--muted); }
.db-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; color: inherit; }
.db-name { font-weight: 700; margin-right: auto; }
.db-id { color: var(--muted); font-weight: 500; }
.db-progress { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.db-body { padding: 0 16px 16px; display: grid; gap: 10px; }
.db-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr; gap: 4px 12px; align-items: center; }
.db-row .lv-picker { width: 100%; }
.db-others { grid-column: 2; display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.8rem; }
.db-others:empty { display: none; }
.db-label { font-weight: 600; font-size: 0.92rem; }
.db-row--goal { padding-left: 12px; border-left: 3px solid var(--primary-soft); }
.db-row--goal .db-label { font-weight: 500; font-size: 0.86rem; }
.goal-tag { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--primary); letter-spacing: 0.04em; }
.db-note textarea { min-height: 60px; }
.other-note { margin: 0; font-size: 0.88rem; color: var(--muted); }
.db-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ── people ──────────────────────────────────────────────────────────────── */
.people-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.people-list li + li { border-top: 1px solid var(--border); }
.person-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; color: inherit; text-decoration: none; }
.person-row:hover { background: #fafbfc; }
.person-row.is-archived { opacity: 0.6; }
.pr-id { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.pr-name { font-weight: 650; display: flex; gap: 8px; align-items: center; min-width: 0; }
.pr-meta { color: var(--muted); font-size: 0.88rem; text-align: right; }
.contact { margin: 0; color: var(--muted); }
.att-line { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.att-upcoming { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }

.goal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.goal { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; }
.goal.is-closed { opacity: 0.7; }
.goal-main { background: none; border: 0; padding: 0; text-align: left; font: inherit; cursor: pointer; display: grid; gap: 6px; color: inherit; }
.goal-text { font-weight: 650; }
.goal-meta, .goal-levels { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.trail { display: inline-flex; gap: 3px; margin-left: 6px; }
.trail .dot { width: 9px; height: 9px; }
.closed-goals summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.closed-goals .goal-list { margin-top: 8px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.skill-grid { border-collapse: collapse; font-size: 0.88rem; min-width: 100%; }
.skill-grid th, .skill-grid td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.skill-grid th[scope=row], .skill-grid thead th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.grid-ev a { color: var(--muted); text-decoration: none; font-weight: 600; }
.grid-cell .dot + .dot { margin-left: 3px; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline li { border-left: 3px solid var(--primary-soft); padding-left: 12px; }
.tl-head { font-size: 0.85rem; color: var(--muted); }
.timeline p { margin: 4px 0 0; }

/* ── settings ────────────────────────────────────────────────────────────── */
.edit-list { display: grid; gap: 8px; }
.edit-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.edit-row > input[type=text] { flex: 1 1 160px; }
.edit-row.is-archived > input[type=text] { color: var(--muted); text-decoration: line-through; }
.edit-tools { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lv-input { border-left-width: 4px !important; }
.lv-border-1 { border-left-color: var(--lv1) !important; }
.lv-border-2 { border-left-color: var(--lv2) !important; }
.lv-border-3 { border-left-color: var(--lv3) !important; }
.simple-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }

/* ── forms + dialogs ─────────────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; font: inherit; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; }
.check--inline { display: inline-flex; font-size: 0.9rem; }
.radio-group { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.radio-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.radio-opt > span { display: grid; gap: 2px; }
.radio-opt input { margin-top: 3px; }
.repeat-box { display: grid; gap: 10px; padding: 12px; background: var(--bg); border-radius: 10px; }
.day-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.day-pick { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 9px; cursor: pointer; font-size: 0.88rem; }
.key-row { display: flex; gap: 8px; }
.prompt-box { margin: 0; max-height: 45vh; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; line-height: 1.45; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.form-error { color: var(--danger); margin: 0; font-size: 0.9rem; }

dialog { border: 0; padding: 0; border-radius: 16px; max-width: min(560px, calc(100vw - 24px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.form-dialog-form { display: grid; gap: 14px; padding: 20px; max-height: calc(100dvh - 48px); overflow-y: auto; }
.form-dialog-title { font-size: 1.15rem; }
.form-dialog-body { display: grid; gap: 12px; }
.form-dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0 0; margin-bottom: -8px; border-top: 1px solid var(--border); }
.bot-calls { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.85rem; max-height: 50vh; overflow-y: auto; }
.bot-call.is-denied code { color: var(--danger); }
.bot-card.is-revoked { opacity: 0.65; }

/* app-dialog.js (confirm / alert / choose) */
.app-dialog { max-width: min(420px, calc(100vw - 24px)); }
.app-dialog-form { padding: 20px; display: grid; gap: 12px; }
.app-dialog-title { font-size: 1.1rem; }
.app-dialog-msg { margin: 0; color: var(--muted); }
.app-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.app-dialog-actions.is-stacked { flex-direction: column-reverse; align-items: stretch; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: #1b1f24; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; transition: opacity .3s; }
.toast.is-out { opacity: 0; }

/* ── phones: hamburger drawer (above) + content tweaks ────────────────────────────────────────── */
@media (max-width: 760px) {
  .main { padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: 1.3rem; }
  .row2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile-icon { width: 56px; height: 56px; }
  .tile-icon svg { width: 26px; height: 26px; }
  .tile { aspect-ratio: 1; }
  .row3 { grid-template-columns: 1fr; }
  .db-row { grid-template-columns: 1fr; }
  .db-search { top: calc(60px + env(safe-area-inset-top, 0px)); }
  .edit-row > input[type=text] { flex-basis: 100%; }
  .edit-row { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .db-others { grid-column: 1; }
  .att-seg { width: 100%; }
  .person-row { grid-template-columns: 36px 1fr; }
  .pr-meta { grid-column: 2; text-align: left; }
  .toasts { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .page-head > .btn--primary:last-child { margin-left: auto; }
}
