/* Zeus AI components (Sprint 7b). Built only from tokens. Documented with live examples on /styleguide. */

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: 36px; padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--sh-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 1px 2px rgba(60, 57, 194, .35); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #a81f15; border-color: #a81f15; }
.btn-danger-quiet { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { height: 42px; padding: 0 var(--s-5); font-size: var(--fs-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-danger).loading::after { border-color: var(--line-strong); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { margin-bottom: var(--s-4); }
.field > label, .label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 38px; padding: 0 var(--s-3); background: var(--surface); color: var(--text); font-size: var(--fs-md);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--sh-xs);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea, .field textarea { height: auto; min-height: 84px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh-base); }
.input::placeholder, .textarea::placeholder, .field input::placeholder { color: var(--n-400); }
.input:hover, .select:hover, .textarea:hover, .field input:hover, .field select:hover { border-color: var(--n-300); }
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.select, .field select { appearance: none; padding-right: 34px; background: var(--surface) 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='%23646c87' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.field.invalid .input, .field.invalid input, .field.invalid select, .field.invalid textarea, .input.invalid { border-color: var(--danger); }
.field.invalid .input:focus, .field.invalid input:focus { box-shadow: 0 0 0 3px rgba(196, 40, 28, .25); }
.help { font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; }
.error-text { font-size: var(--fs-xs); color: var(--danger); margin-top: 6px; display: flex; gap: 4px; align-items: flex-start; }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--n-300); border-radius: var(--r-pill); transition: background var(--dur) var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: var(--sh-xs); transition: transform var(--dur) var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: var(--r-md); gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--sh-sm); }

/* ---------- chips, badges, avatar ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip-brand { background: var(--accent-soft); color: var(--accent); }
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-size: var(--fs-xs); font-weight: 700; flex: 0 0 auto; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

/* ---------- panels, page header, stat cards ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-xs); overflow: hidden; }
.panel-hd { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); font-size: var(--fs-md); font-weight: 650; }
.panel-hd a { font-size: var(--fs-xs); font-weight: 600; }
.panel-body { padding: var(--s-5); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head h1, h1.pagetitle { font-size: var(--fs-3xl); letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--text-2); font-size: var(--fs-md); margin: 4px 0 0; }
.pagesub { color: var(--text-2); font-size: var(--fs-md); margin: 4px 0 var(--s-6); }
.page-actions { display: flex; gap: var(--s-2); align-items: center; }
.sectitle { font-size: var(--fs-lg); font-weight: 700; margin: 0 0 var(--s-3); }
.stat-grid, .statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-6); }
.stat, .statcard { display: flex; gap: var(--s-3); align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--sh-xs); }
.stat-badge { width: 40px; height: 40px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; background: var(--accent-soft); color: var(--accent); }
.stat-badge.good { background: var(--good-soft); color: var(--good); } .stat-badge.warn { background: var(--warn-soft); color: var(--warn); }
.stat-badge.info { background: var(--info-soft); color: var(--info); } .stat-badge.danger { background: var(--danger-soft); color: var(--danger); }
.stat-num { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { font-size: var(--fs-sm); color: var(--text); font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }

/* ---------- tables ---------- */
.table, table.dealtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, table.dealtable th { position: sticky; top: 0; text-align: left; padding: var(--s-3) var(--s-4); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td, table.dealtable td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover, table.dealtable tbody tr:hover { background: var(--n-25); }
.table tbody tr:last-child td, table.dealtable tbody tr:last-child td { border-bottom: 0; }
.table .num, table.dealtable .num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }

/* ---------- tabs, stepper, menu ---------- */
.tabs, .wtabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab, .wtab { position: relative; padding: var(--s-3) var(--s-4); border: 0; background: none; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); white-space: nowrap; }
.tab:hover, .wtab:hover { color: var(--text); }
.tab.active, .wtab.active { color: var(--accent); }
.tab.active::after, .wtab.active::after { content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.stepper { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: var(--s-1) 0; }
.step { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; background: var(--surface); border: 2px solid var(--line-strong); }
.step.done { color: var(--text-2); } .step.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.step.current { color: var(--accent); } .step.current .dot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step + .step::before { content: ""; width: 28px; height: 2px; margin: 0 var(--s-2); background: var(--line-strong); }
.step.done + .step::before, .step.current::before { background: var(--good); }
.menu { min-width: 180px; padding: var(--s-1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-md); }
.menu button, .menu a { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: var(--s-2) var(--s-3); border: 0; background: none; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text); text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- modal, drawer, toast ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--s-5); background: rgba(13, 18, 38, .5); backdrop-filter: blur(2px); animation: fade var(--dur) var(--ease); }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg); animation: rise 180ms var(--ease); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); padding: var(--s-5) var(--s-6) var(--s-3); }
.modal-head h2 { font-size: var(--fs-xl); } .modal-head .sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: 4px; }
.modal-body { padding: var(--s-2) var(--s-6) var(--s-4); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--n-25); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal-foot[hidden] { display: none; }
.drawer-overlay { justify-content: flex-end; padding: 0; }
.drawer { width: 100%; max-width: 520px; height: 100%; display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--sh-lg); animation: slide 200ms var(--ease); }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } } @keyframes slide { from { transform: translateX(24px); opacity: 0; } }
#toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 80; display: flex; flex-direction: column; gap: var(--s-2); max-width: 380px; }
.toast { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--ink-900); color: #fff; border-radius: var(--r-md); box-shadow: var(--sh-lg); font-size: var(--fs-sm); animation: rise 180ms var(--ease); }
.toast .icon { margin-top: 2px; } .toast.good .icon { color: #5fe3a0; } .toast.danger .icon { color: #ff9b94; } .toast.warn .icon { color: #ffd277; }
.toast button { margin-left: auto; background: none; border: 0; color: var(--ink-300); padding: 0; }

/* ---------- feedback ---------- */
.alert { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: var(--fs-sm); border: 1px solid transparent; background: var(--info-soft); color: var(--info); }
.alert .icon { margin-top: 2px; } .alert .body { color: var(--text); } .alert .body b { color: inherit; }
.alert-warn { background: var(--warn-soft); color: var(--warn); } .alert-danger { background: var(--danger-soft); color: var(--danger); } .alert-good { background: var(--good-soft); color: var(--good); }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-8) var(--s-5); color: var(--text-2); }
.empty-state .ico { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); margin-bottom: var(--s-2); }
.empty-state .ico svg { width: 22px; height: 22px; } .empty-state h3 { color: var(--text); font-size: var(--fs-lg); } .empty-state p { max-width: 380px; margin: 0; font-size: var(--fs-sm); }
.empty { font-size: var(--fs-sm); color: var(--text-3); text-align: center; padding: var(--s-4) var(--s-2); }
.skeleton { display: block; height: 14px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--n-50) 25%, var(--n-100) 37%, var(--n-50) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; margin: var(--s-2) 0; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.progress { height: 8px; background: var(--n-100); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-grad); border-radius: var(--r-pill); transition: width 300ms var(--ease); }
/* widths come from classes, never inline style (the CSP forbids inline styles after Sprint 7e) */
.pct-0 { width: 0%; } .pct-5 { width: 5%; } .pct-10 { width: 10%; } .pct-15 { width: 15%; } .pct-20 { width: 20%; } .pct-25 { width: 25%; } .pct-30 { width: 30%; }
.pct-35 { width: 35%; } .pct-40 { width: 40%; } .pct-45 { width: 45%; } .pct-50 { width: 50%; } .pct-55 { width: 55%; } .pct-60 { width: 60%; } .pct-65 { width: 65%; }
.pct-70 { width: 70%; } .pct-75 { width: 75%; } .pct-80 { width: 80%; } .pct-85 { width: 85%; } .pct-90 { width: 90%; } .pct-95 { width: 95%; } .pct-100 { width: 100%; }
.sk-w1 { width: 92%; } .sk-w2 { width: 78%; } .sk-w3 { width: 64%; } .sk-w4 { width: 85%; }
.progress.good > span { background: var(--good); } .progress.warn > span { background: var(--warn); }
.divider-text { display: flex; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--fs-xs); margin: var(--s-4) 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.select-sm { height: 32px; width: auto; min-width: 120px; padding-top: 0; padding-bottom: 0; font-size: var(--fs-sm); border-radius: var(--r-sm); }
/* ---- stage colors: a stage's position in its process picks stage-c0..c5; chips, swatches and chart segments follow ---- */
.stage-c0 { --st: var(--info); --st-soft: var(--info-soft); } .stage-c1 { --st: var(--warn); --st-soft: var(--warn-soft); }
.stage-c2 { --st: var(--good); --st-soft: var(--good-soft); } .stage-c3 { --st: var(--accent); --st-soft: var(--accent-soft); }
.stage-c4 { --st: var(--danger); --st-soft: var(--danger-soft); } .stage-c5 { --st: var(--n-600); --st-soft: var(--n-100); }
.stagechip { display: inline-flex; align-items: center; height: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; background: var(--st-soft, var(--info-soft)); color: var(--st, var(--info)); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--st, var(--n-400)); }
a.stat, button.stat { text-align: left; font: inherit; color: inherit; text-decoration: none; cursor: pointer; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
a.stat:hover, button.stat:hover { border-color: var(--brand-200); box-shadow: var(--sh-md); text-decoration: none; }
.row-link { color: var(--text); text-decoration: none; } .row-link:hover { color: var(--accent); text-decoration: underline; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }
.is-overdue { color: var(--danger); font-weight: 600; }
/* ---- documents: upload dialog, access matrix ---- */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2); padding: var(--s-6); border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--n-25); color: var(--text-2); font-size: var(--fs-sm); text-align: center; cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone.has-file { border-style: solid; color: var(--text); font-weight: 600; }
.visually-hidden:focus-visible + .dropzone, .dropzone:focus-within { box-shadow: var(--ring); }
.upload-progress { width: 100%; height: 8px; margin-top: var(--s-3); border: 0; border-radius: var(--r-pill); overflow: hidden; background: var(--n-100); accent-color: var(--accent); }
.upload-progress::-webkit-progress-bar { background: var(--n-100); } .upload-progress::-webkit-progress-value { background: var(--accent); }
.upload-progress::-moz-progress-bar { background: var(--accent); }
.matrix th, .matrix td { text-align: center; } .matrix th:first-child, .matrix td:first-child { text-align: left; }
.pm-status { width: 28px; color: var(--good); }

/* ---- one-time secrets (temporary passwords) ---- */
.secret-box { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--n-50); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: var(--s-2); }
.secret-box code { font-size: var(--fs-md); user-select: all; word-break: break-all; }

/* ---- error and not-found pages (templates/error.html) ---- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); background: var(--canvas); }
.error-card { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); max-width: 440px; padding: var(--s-8); text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-md); }
.error-card .brand-mark { display: block; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--brand-grad); margin-bottom: var(--s-3); }
.error-code { margin: 0; font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.02em; color: var(--accent); }
.error-card h1 { font-size: var(--fs-xl); margin: 0; } .error-card .btn { margin-top: var(--s-4); }

/* ---- print: a deal Overview on paper (sidebar, tabs and actions hidden) ---- */
@media print {
  .app-sidebar, header, .tabs, .dept-filter, .btn, .page-actions, #toasts, .pbar { display: none !important; }
  body, .app-main, main { background: #fff !important; }
  #app { display: block; } .app-main { margin: 0; padding: 0; }
  .panel, .stat, .card { box-shadow: none !important; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---- settings-style pages (admin sections, profile): width, heading, key-value list ---- */
.adm-page { max-width: 1040px; } .adm-page.narrow { max-width: 620px; }
.adm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.adm-head > div:first-child { flex: 1 1 360px; min-width: 0; }
.adm-title { margin: 0 0 var(--s-1); font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
.role-chip { margin: 0 4px 4px 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: var(--s-2) var(--s-4); margin: var(--s-4) 0 0; font-size: var(--fs-sm); }
.kv dt { color: var(--text-2); font-weight: 600; } .kv dd { margin: 0; min-width: 0; word-break: break-word; }
