/* Banyan brand palette + Shapeshifter app */
:root {
  --moss: #4A6741;
  --moss-dark: #3A5233;
  --moss-light: #6B8762;
  --moss-bg: #EDF1EA;
  --sky: #6FA8C8;
  --sky-dark: #4A8AAE;
  --sky-bg: #E5F0F6;
  --cream: #F5EFD5;
  --cream-dark: #E8DDB0;
  --ink: #1F2A24;
  --ink-2: #3D4A40;
  --muted: #6E7B72;
  --line: #DDE2DC;
  --line-2: #EAEEE7;
  --bg: #F7F8F4;
  --card: #FFFFFF;
  --danger: #B53A2A;
  --danger-bg: #FBE9E7;
  --warn: #C77B27;
  --warn-bg: #FBEEDC;
  --ok: #3F7A4A;
  --ok-bg: #E3F0E2;
  --info: #4A8AAE;
  --shadow-sm: 0 1px 2px rgba(31,42,36,0.06);
  --shadow: 0 4px 12px rgba(31,42,36,0.08);
  --shadow-lg: 0 12px 40px rgba(31,42,36,0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: 'Source Sans 3', -apple-system, system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }

h1, h2, h3, h4, h5 { font-family: 'Libre Franklin', 'Source Sans 3', sans-serif; color: var(--ink); margin: 0 0 8px 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.35; }
h4 { font-size: 14px; line-height: 1.4; font-weight: 600; }

a { color: var(--moss); text-decoration: none; }
a:hover { color: var(--moss-dark); text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.micro { font-size: 11px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; }
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.spacer { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }

/* ============ LOGIN ============ */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--moss-bg), var(--sky-bg)); z-index: 100; }
.login-card { width: 380px; background: var(--card); padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-card .login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-card label { display: block; margin-top: 14px; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.login-card input, .login-card select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; margin-top: 4px; background: var(--card); }
.login-card input:focus, .login-card select:focus { outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px var(--moss-bg); }
.login-card .btn { width: 100%; margin-top: 18px; }
.login-card .micro { margin-top: 12px; }
.login-card .passcode-error { color: var(--danger); font-size: 13px; font-weight: 600; margin-top: 10px; min-height: 1em; }
.login-card form { margin: 0; }

.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: var(--moss); color: white; display: flex; align-items: center; justify-content: center; font-family: 'Libre Franklin', sans-serif; font-weight: 800; font-size: 20px; }
.brand-title { font-family: 'Libre Franklin', sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-title-sm { font-family: 'Libre Franklin', sans-serif; font-weight: 700; font-size: 14px; color: white; }
.brand-sub-sm { font-size: 11px; color: rgba(255,255,255,0.7); }

/* ============ APP SHELL ============ */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--moss-dark); color: white; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,0.12); margin-bottom: 12px; }
.sidebar-brand .brand-mark { background: var(--cream); color: var(--moss-dark); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: rgba(255,255,255,0.85); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,0.07); color: white; text-decoration: none; }
.nav a.active { background: rgba(245,239,213,0.12); color: var(--cream); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: 0.85; font-size: 13px; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 6px; }
.nav-help { background: rgba(245,239,213,0.08); }
.nav-help:hover { background: rgba(245,239,213,0.14); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-summary { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: rgba(255,255,255,0.85); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; list-style: none; user-select: none; }
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary:hover { background: rgba(255,255,255,0.07); color: white; }
.nav-caret { margin-left: auto; opacity: 0.6; font-size: 10px; transition: transform 0.15s; }
.nav-group[open] .nav-caret { transform: rotate(180deg); }
.nav-group a { padding-left: 32px; font-size: 12.5px; }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; margin-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--cream); color: var(--moss-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-name { color: white; font-weight: 600; font-size: 13px; }
.user-role { color: rgba(255,255,255,0.6) !important; }
.sidebar-foot .btn.ghost { color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.18); margin-top: 8px; width: 100%; }
.sidebar-foot .btn.ghost:hover { background: rgba(255,255,255,0.08); color: white; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.entity-toggle { display: flex; align-items: center; gap: 8px; }
.entity-toggle select { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; background: var(--card); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.snapshot-pill { background: var(--moss-bg); color: var(--moss-dark); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.sync-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.sync-indicator .sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); transition: background 0.2s; }
.sync-indicator.syncing .sync-dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.sync-indicator.error .sync-dot { background: var(--danger); }
.sync-indicator.dirty .sync-dot { background: var(--warn); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.page-container { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }

/* ============ BUTTONS ============ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--ink); transition: all 0.12s ease; line-height: 1; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--moss); color: white; }
.btn.primary:hover { background: var(--moss-dark); }
.btn.secondary { background: var(--sky); color: white; }
.btn.secondary:hover { background: var(--sky-dark); }
.btn.ghost { border-color: var(--line); background: var(--card); color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg); border-color: var(--moss); color: var(--moss); }
.btn.danger { background: var(--danger); color: white; }
.btn.danger:hover { background: #8E2C20; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============ CARDS / TILES ============ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.card.tight { padding: 12px; }
.card-title { font-family: 'Libre Franklin', sans-serif; font-weight: 700; font-size: 14px; margin-bottom: 4px; color: var(--ink); }
.card-sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* Phase summary cards */
.phase-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.phase-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--moss); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: all 0.15s ease; }
.phase-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.phase-card.active { border-left-color: var(--cream-dark); background: var(--moss-bg); }
.phase-card .num { font-family: 'Libre Franklin', sans-serif; font-size: 24px; font-weight: 800; line-height: 1; margin-top: 8px; }
.phase-card .label { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.phase-card .balance { font-size: 13px; color: var(--ink-2); font-weight: 600; margin-top: 6px; }
.phase-card .name { font-size: 13px; font-weight: 700; color: var(--moss-dark); margin-bottom: 0; }

.phase-card.p-0 { border-left-color: #6E5DA5; }
.phase-card.p-7 { border-left-color: #888888; }
.phase-card.p-1 { border-left-color: #5DA5C5; }
.phase-card.p-2 { border-left-color: #7DC3A4; }
.phase-card.p-3 { border-left-color: #C9B458; }
.phase-card.p-4 { border-left-color: #D58A3A; }
.phase-card.p-5 { border-left-color: #C25D3A; }
.phase-card.p-6 { border-left-color: #8E2C20; }
.phase-card.p-tri { border-left-color: var(--moss-light); }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-family: 'Libre Franklin', sans-serif; font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.kpi .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.kpi .delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.kpi .delta.up { color: var(--danger); }
.kpi .delta.down { color: var(--ok); }

/* ============ TABLES ============ */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--moss); }
table.data th.sortable .arrow { opacity: 0.4; margin-left: 4px; }
table.data th.sortable.sorted .arrow { opacity: 1; color: var(--moss); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:hover td { background: var(--bg); }
table.data tr:last-child td { border-bottom: none; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data tr.clickable { cursor: pointer; }

/* ============ PILLS / TAGS ============ */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; line-height: 1.5; }
.pill.phase-0 { background: #E8E5F2; color: #4A4070; }
.pill.phase-7 { background: #E5E5E5; color: #555555; }
.pill.phase-1 { background: #DCEAF2; color: #2F6685; }
.pill.phase-2 { background: #DEF0E5; color: #2C6E48; }
.pill.phase-3 { background: #FAF1CB; color: #6B5B12; }
.pill.phase-4 { background: #FBE7CE; color: #8C5318; }
.pill.phase-5 { background: #F8DBD0; color: #8C3A22; }
.pill.phase-6 { background: #F2C9C2; color: #6E1F14; }
.phase-lock { margin-left: 4px; font-size: 10px; opacity: 0.85; }
.pill.status-open { background: var(--info); color: white; }
.pill.status-progress { background: var(--warn); color: white; }
.pill.status-blocked { background: var(--danger); color: white; }
.pill.status-completed { background: var(--ok); color: white; }
.pill.status-cancelled { background: var(--muted); color: white; }
.pill.subscribed { background: var(--ok-bg); color: var(--ok); }
.pill.cancelled { background: var(--line); color: var(--muted); }
.pill.commitment { background: var(--cream); color: #6B5B12; }
.pill.overdue { background: var(--danger-bg); color: var(--danger); }
.pill.priority-high   { background: #F8DBD0; color: #8C3A22; border: 1px solid #ECB29F; }
.pill.priority-medium { background: #FBE7CE; color: #8C5318; border: 1px solid #ECC788; }
.pill.priority-low    { background: #DEF0E5; color: #2C6E48; border: 1px solid #B5D9C0; }
.pill.aging-Current  { background: #DCEAF2; color: #2F6685; }
.pill.aging-1_30     { background: #DEF0E5; color: #2C6E48; }
.pill.aging-31_60    { background: #FAF1CB; color: #6B5B12; }
.pill.aging-61_90    { background: #FBE7CE; color: #8C5318; }
.pill.aging-91_180   { background: #F8DBD0; color: #8C3A22; }
.pill.aging-181plus  { background: #F2C9C2; color: #6E1F14; }

.phase-pill-btn { background: transparent; border: 1px solid var(--line); padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; cursor: pointer; font-family: inherit; line-height: 1.5; transition: all 0.1s; }
.phase-pill-btn:hover { border-color: var(--moss); }
.phase-pill-btn.phase-0 { background: #E8E5F2; color: #4A4070; border-color: #C9C0E0; }
.phase-pill-btn.phase-7 { background: #E5E5E5; color: #555555; border-color: #C7C7C7; }
.phase-pill-btn.phase-1 { background: #DCEAF2; color: #2F6685; border-color: #B6D2E0; }
.phase-pill-btn.phase-2 { background: #DEF0E5; color: #2C6E48; border-color: #B5D9C0; }
.phase-pill-btn.phase-3 { background: #FAF1CB; color: #6B5B12; border-color: #E8D685; }
.phase-pill-btn.phase-4 { background: #FBE7CE; color: #8C5318; border-color: #ECC788; }
.phase-pill-btn.phase-5 { background: #F8DBD0; color: #8C3A22; border-color: #ECB29F; }
.phase-pill-btn.phase-6 { background: #F2C9C2; color: #6E1F14; border-color: #DC9282; }

/* ============ FILTERS ============ */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; align-items: center; }
.filter-bar input, .filter-bar select { padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 13px; background: var(--card); }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--moss); }
.filter-bar input[type=search] { min-width: 200px; }
.filter-bar .filter-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-right: 4px; }
.tab-row { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab-row .tab { padding: 9px 14px; background: transparent; border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-row .tab:hover { color: var(--ink); }
.tab-row .tab.active { color: var(--moss); border-bottom-color: var(--moss); }

/* ============ MODALS ============ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(31,42,36,0.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal.wide { width: 720px; }
.modal.xwide { width: 960px; }
.modal-head { padding: 18px 22px 6px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { margin-bottom: 4px; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line-2); background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal label { display: block; margin-top: 12px; font-weight: 600; color: var(--ink-2); font-size: 13px; }
.modal input[type=text], .modal input[type=number], .modal input[type=date], .modal input[type=email], .modal select, .modal textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; margin-top: 4px; background: var(--card); }
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px var(--moss-bg); }
.modal textarea { min-height: 80px; resize: vertical; }
.modal .field-error { color: var(--danger); font-size: 12px; margin-top: 4px; font-weight: 600; }
.modal .name-confirm { background: var(--cream); border: 1px solid var(--cream-dark); padding: 14px; border-radius: var(--radius-sm); margin-top: 14px; }
.modal .name-confirm strong { color: #6B5B12; }

/* ============ TOASTS ============ */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: white; padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13px; min-width: 240px; max-width: 360px; animation: slideUp 0.2s ease; }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warn); }
.toast.email-log-toast { background: var(--moss-dark); max-width: 480px; }
.toast.email-log-toast .btn.primary { background: white; color: var(--moss-dark); border: 0; }
.toast.email-log-toast .btn.primary:hover { background: var(--moss-bg); }
.toast.email-log-toast .btn.ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.5); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ DASHBOARD CONTENT ============ */
.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.activity-feed { max-height: 480px; overflow-y: auto; }
.activity-item { padding: 10px 0; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--moss); margin-top: 6px; flex-shrink: 0; }
.activity-item .a-body { flex: 1; min-width: 0; }
.activity-item .a-meta { font-size: 11px; color: var(--muted); }
.activity-item .a-text { font-size: 13px; line-height: 1.4; }

.trend-chart { height: 240px; position: relative; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }
.section-title .spacer { flex: 1; }

/* ============ CUSTOMER DETAIL ============ */
.customer-header { display: grid; grid-template-columns: 2fr 3fr; gap: 18px; align-items: start; margin-bottom: 18px; }
.customer-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.overview-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .overview-grid { grid-template-columns: 1fr; } }
.invoice-table tfoot td { background: var(--bg); border-top: 2px solid var(--line); padding: 10px 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.stat .v { font-family: 'Libre Franklin', sans-serif; font-size: 18px; font-weight: 800; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

.commentary-feed { display: flex; flex-direction: column; gap: 10px; }
.comment { background: var(--card); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius); }
.comment.commitment { background: var(--cream); border-color: var(--cream-dark); }
.comment.overdue-commit { border-left: 3px solid var(--danger); }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; }
.comment-head .author { font-weight: 700; }
.comment-head .channel { padding: 1px 6px; background: var(--bg); border-radius: 4px; font-size: 10px; text-transform: uppercase; font-weight: 600; color: var(--muted); }
.comment-body { font-size: 13px; line-height: 1.5; }
.comment-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.comment-actions { display: inline-flex; gap: 4px; margin-left: 6px; }
.comment-actions .icon-btn { background: none; border: none; padding: 2px 6px; font-size: 11px; cursor: pointer; color: var(--muted); border-radius: 3px; font-family: inherit; }
.comment-actions .icon-btn:hover { background: var(--bg); color: var(--ink); }
.comment-actions .icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Action item with priority left border */
.ai-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); border-left-width: 4px; }
.ai-row.priority-high   { border-left-color: var(--danger); }
.ai-row.priority-medium { border-left-color: var(--warn); }
.ai-row.priority-low    { border-left-color: var(--ok); }
.ai-row.overdue         { background: var(--danger-bg); }

/* ============ DROP / UPLOAD ============ */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; background: var(--bg); cursor: pointer; transition: all 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--moss); background: var(--moss-bg); }
.dropzone .big { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

/* ============ ROLL-FORWARD ============ */
.rf-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.rf-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.rf-col h3 { font-size: 13px; margin-bottom: 8px; }
.rf-col .count { font-size: 22px; font-weight: 800; font-family: 'Libre Franklin'; }
.rf-col.new { border-top: 3px solid var(--info); }
.rf-col.carry { border-top: 3px solid var(--moss); }
.rf-col.paid { border-top: 3px solid var(--ok); }
.rf-row { padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12px; }
.rf-row:last-child { border-bottom: none; }
.rf-row .doc { font-weight: 700; }
.rf-row .cust { color: var(--muted); }
.rf-row .bal { font-weight: 600; color: var(--ink-2); }
.rf-row.flagged { background: var(--warn-bg); margin: 0 -8px; padding: 7px 8px; border-radius: 4px; }

/* ============ WALKTHROUGH ============ */
.walkthrough-grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.walkthrough-list { max-height: 75vh; overflow-y: auto; padding: 0 !important; }
.wt-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background 0.1s; }
.wt-row:last-child { border-bottom: none; }
.wt-row:hover { background: var(--bg); }
.wt-row.active { background: var(--moss-bg); border-left: 3px solid var(--moss); padding-left: 9px; }
.wt-row.reviewed { opacity: 0.7; }
.wt-row-num { width: 22px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; flex-shrink: 0; }
.wt-row-body { flex: 1; min-width: 0; }
.wt-row-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-row-meta { font-size: 11px; color: var(--muted); }
.wt-check { color: var(--ok); font-weight: 700; font-size: 14px; flex-shrink: 0; }
.walkthrough-detail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.wt-comments { display: flex; flex-direction: column; gap: 8px; }
.wt-comment-form label { font-size: 12px; }
.wt-section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.wt-stab { background: transparent; border: none; padding: 8px 12px; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.wt-stab:hover { color: var(--ink); }
.wt-stab.active { color: var(--moss); border-bottom-color: var(--moss); }
.wt-tab-body.hidden { display: none; }

/* ============ MEETING (legacy, kept for now) ============ */
.meeting-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.agenda-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.agenda-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--card); }
.agenda-item:hover { border-color: var(--moss); }
.agenda-item.active { border-color: var(--moss); background: var(--moss-bg); border-left: 3px solid var(--moss); }
.agenda-item .a-name { font-weight: 700; font-size: 13px; }
.agenda-item .a-meta { font-size: 11px; color: var(--muted); }

/* ============ AGING BUCKET BAR ============ */
.aging-bar { display: flex; height: 36px; border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); margin-top: 8px; }
.aging-seg { display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 12px; transition: filter 0.1s; cursor: default; }
.aging-seg:hover { filter: brightness(1.07); }
.aging-seg span { mix-blend-mode: normal; text-shadow: 0 1px 1px rgba(0,0,0,0.18); }
.aging-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.aging-legend-item { display: flex; gap: 8px; }
.aging-legend-item .dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; margin-top: 4px; }
.aging-legend-item .legend-key { font-size: 13px; }

/* ============ AGING SLICERS (click-to-filter) ============ */
.slicer-seg { cursor: pointer; position: relative; }
.slicer-seg.active { box-shadow: inset 0 0 0 2px var(--ink); filter: brightness(1.08); }
.slicer-seg.dimmed { opacity: 0.42; }
.slicer-seg.dimmed:hover { opacity: 0.85; }

.slicer-legend { padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.slicer-legend:hover { background: var(--moss-bg); }
.slicer-legend.active { background: var(--moss-bg); border-color: var(--moss-light); }

.slicer-row { cursor: pointer; transition: background 0.12s; }
.slicer-row:hover { background: var(--moss-bg); }
.slicer-row.active { background: var(--moss-bg); box-shadow: inset 3px 0 0 var(--moss); }
.slicer-row.active td:first-child { font-weight: 700; }

.slicer-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--moss); color: white; padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.slicer-pill button { background: rgba(255,255,255,0.22); border: 0; color: white; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; }
.slicer-pill button:hover { background: rgba(255,255,255,0.4); }

/* ============ GUIDE PAGE ============ */
.guide-grid { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .guide-grid { grid-template-columns: 1fr; } }
.guide-toc { position: sticky; top: 70px; }
.guide-toc a { display: block; padding: 8px 12px; color: var(--ink-2); border-left: 2px solid transparent; font-size: 13px; }
.guide-toc a:hover { color: var(--moss); border-left-color: var(--moss); text-decoration: none; }
.guide-toc a.active { color: var(--moss); border-left-color: var(--moss); font-weight: 600; }
.guide-section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 18px; }
.guide-section h2 { margin-bottom: 6px; }
.guide-section h3 { margin-top: 16px; margin-bottom: 4px; font-size: 14px; }
.guide-section p { margin: 6px 0; color: var(--ink-2); }
.guide-section ol, .guide-section ul { margin: 6px 0 6px 22px; color: var(--ink-2); }
.guide-section li { margin: 4px 0; }
.guide-step { display: flex; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.guide-step:first-of-type { border-top: none; }
.guide-step .stepnum { width: 28px; height: 28px; border-radius: 50%; background: var(--moss); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-family: 'Libre Franklin'; }
.guide-step .stepbody { flex: 1; }
.guide-step .stepbody h3 { margin: 4px 0 2px; }
.guide-callout { background: var(--cream); border-left: 3px solid var(--cream-dark); padding: 12px 14px; border-radius: 4px; margin: 10px 0; font-size: 13px; color: #6B5B12; }
.guide-callout strong { color: #5A4B0E; }
.guide-role-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
.guide-role-card .rc { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.guide-role-card .rc h4 { color: var(--moss-dark); margin-bottom: 6px; }
.guide-faq { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-top: 8px; }
.guide-faq summary { cursor: pointer; font-weight: 600; color: var(--ink); padding: 4px 0; }
.guide-faq summary:hover { color: var(--moss); }
.guide-faq[open] { background: var(--card); }
.guide-faq p { margin: 8px 0 4px; }

/* ============ SETTINGS ============ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.settings-grid .card { min-width: 0; }
.settings-grid .card h3 { margin-bottom: 8px; }
.settings-grid .table-wrap { max-width: 100%; }
.settings-table { table-layout: fixed; width: 100%; }
.settings-table td, .settings-table th { padding: 8px 10px; word-break: break-word; }
.settings-table .email-cell { word-break: break-all; display: inline-block; max-width: 100%; }
.settings-list { margin: 6px 0 0 0; padding-left: 0; list-style: none; }
.settings-list li { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.settings-list li:last-child { border-bottom: none; }
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
.kv .v { font-size: 13px; color: var(--ink); }
.perm-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.perm-row { display: contents; }
.perm-key { font-size: 12px; color: var(--ink-2); font-family: ui-monospace, Menlo, Consolas, monospace; }
.perm-val .ok { color: var(--ok); font-weight: 700; }
.perm-val { font-size: 12px; }

/* ============ EXECUTIVE REPORT ============ */
.exec-report { max-width: 1100px; margin: 0 auto; }
.exec-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px; background: var(--moss); color: white; border-radius: var(--radius) var(--radius) 0 0; margin-bottom: 0; }
.exec-header h1.exec-title { color: white; font-size: 24px; margin: 4px 0; }
.exec-brandline { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cream); font-weight: 700; }
.exec-meta { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 4px; }
.exec-totalblock { text-align: right; }
.exec-totallabel { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cream); font-weight: 700; }
.exec-totalvalue { font-family: 'Libre Franklin', sans-serif; font-size: 20px; font-weight: 800; }
.exec-plus { color: var(--cream); padding: 0 4px; }
.exec-totalnote { font-size: 12px; color: rgba(255,255,255,0.85); margin-top: 4px; }
.exec-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; background: var(--card); border: 1px solid var(--line); border-top: none; }
.exec-kpi { padding: 12px 14px; border-right: 1px solid var(--line); }
.exec-kpi:last-child { border-right: none; }
.exec-kpi.kpi-warn { background: var(--danger-bg); }
.exec-kpi .l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.exec-kpi .v { font-family: 'Libre Franklin', sans-serif; font-size: 22px; font-weight: 800; line-height: 1.1; margin: 4px 0 2px; }
.exec-row { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; margin-top: 12px; }
.exec-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 12px; }
.exec-card h3 { margin-bottom: 8px; }
.exec-mini { width: 100%; font-size: 12px; }
.exec-mini th, .exec-mini td { padding: 6px 8px; }
.exec-aging .aging-bar { margin-bottom: 10px; }
.exec-footer { margin-top: 18px; padding: 12px 16px; border-top: 2px solid var(--moss); font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }

/* Print-ready: hide app chrome, render report cleanly */
@media print {
  body * { visibility: hidden; }
  .exec-report, .exec-report * { visibility: visible; }
  .exec-noprint { display: none !important; }
  .exec-report { position: absolute; left: 0; top: 0; width: 100%; max-width: none; padding: 12px; }
  .sidebar, .topbar { display: none !important; }
  .exec-header { background: #4A6741 !important; color: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .exec-kpi.kpi-warn { background: #FBE9E7 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .aging-seg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 1100px) {
  .exec-kpis { grid-template-columns: repeat(3, 1fr); }
  .exec-row { grid-template-columns: 1fr; }
}

/* ============ CLUSTER CARDS ============ */
.cluster-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.cluster-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--moss); border-radius: var(--radius); padding: 16px 18px; cursor: pointer; transition: all 0.15s; }
.cluster-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-left-color: var(--moss-dark); }
.cluster-card.individual { border-left-color: var(--muted); background: var(--bg); }
.cluster-card .cluster-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.cluster-card .cluster-name { font-family: 'Libre Franklin', sans-serif; font-size: 18px; font-weight: 700; color: var(--ink); }
.cluster-card .right { text-align: right; }
.cluster-card .cluster-balance { font-family: 'Libre Franklin', sans-serif; font-size: 22px; font-weight: 800; color: var(--moss-dark); }
.cluster-card .cluster-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; margin-bottom: 12px; }
.cluster-card .cluster-stats .cs-num { font-family: 'Libre Franklin', sans-serif; font-size: 14px; font-weight: 700; color: var(--ink-2); }
.cluster-card .cluster-stats .cs-warn { color: var(--danger); }
.cluster-card .cluster-phases { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line-2); }

/* ============ MISC ============ */
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }
.role-banner { background: var(--cream); padding: 6px 14px; font-size: 12px; color: #6B5B12; border-bottom: 1px solid var(--cream-dark); text-align: center; font-weight: 600; }
.banner-warn { background: var(--warn-bg); border: 1px solid #ECC788; padding: 8px 12px; border-radius: var(--radius-sm); color: #6E3F14; font-size: 13px; margin-bottom: 12px; }

.pillbar { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* Responsive guards */
@media (max-width: 1100px) {
  .phase-grid { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .customer-header { grid-template-columns: 1fr; }
  .meeting-grid { grid-template-columns: 1fr; }
  .walkthrough-grid { grid-template-columns: 1fr; }
  .rf-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .phase-grid { grid-template-columns: repeat(2, 1fr); }
}
