/* UI-COMPONENTS: routed workspace additions. Original glass tokens live in styles.css. */
:root { color-scheme: dark; --surface: #101a17; --field-bg: rgba(255,255,255,.035); --line: rgba(255,255,255,.10); }
:root[data-theme="light"] { color-scheme: light; --bg: #edf3ef; --text: #172e28; --muted: #546a63; --surface: #f8fbf9; --field-bg: rgba(255,255,255,.7); --line: rgba(25,58,45,.14); --glass-border: rgba(25,58,45,.14); }
body.light-mode { --bg: #edf3ef; --muted: #546a63; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--teal); text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 1px; }
svg.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }
.brand { color: var(--text); }
.brand-name { font-size: 27px; letter-spacing: -1.3px; }
.brand-dot { color: var(--lime); }
.brand-subtitle { font-size: 9px; letter-spacing: 2.6px; }
.sidebar { min-height: 650px; }
.workspace-note { color: var(--muted); font-size: 11px; display: flex; gap: 8px; flex-wrap: wrap; padding: 15px 9px; }
.workspace-note .status-dot { margin-top: 3px; }
.workspace-note > span:last-child { flex-basis: 100%; padding-left: 15px; font-size: 10px; opacity: .8; }
.profile-name { overflow-wrap: anywhere; }
.profile-caption { font-size: 10px; color: var(--muted); margin-top: 4px; }
#sign-out { margin: 16px 8px 0; }
.signin-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.signin-card { max-width: 490px; padding: 42px; display: flex; flex-direction: column; gap: 22px; }
.signin-card h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.2; letter-spacing: -1.3px; font-weight: 550; }
.signin-card .brand-subtitle { margin-top: -17px; }
.page-content { display: flex; flex-direction: column; gap: 20px; flex: 1; min-width: 0; }
.page-content:focus, #page-heading:focus { outline: none; }
.skip-link { position: fixed; top: -60px; left: 20px; z-index: 20; padding: 14px; background: var(--surface); border: 1px solid var(--teal); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.page-intro, .welcome { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 8px 2px; }
.page-intro h2, .welcome h2 { font-size: clamp(23px, 2.2vw, 32px); font-weight: 550; letter-spacing: -1px; line-height: 1.25; margin: 8px 0; }
.page-intro p, .welcome p { color: var(--muted); font-size: 13px; line-height: 1.7; max-width: 640px; }
.eyebrow { color: var(--teal); font-size: 10px; letter-spacing: 2.2px; font-weight: 600; }
.button, .primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 9px 14px; border-radius: 10px; font-size: 12px; font-weight: 550; cursor: pointer; line-height: 1.4; text-align: center; }
.button { background: var(--field-bg); border: 1px solid var(--line); color: var(--text); }
.button:hover { border-color: var(--teal); background: rgba(78,194,197,.08); }
.primary-button { color: #132b23; background: var(--lime); border: 1px solid var(--lime); box-shadow: none; }
.primary-button:hover { background: #e8ffa2; }
.danger-button { color: #f6a6a6; }
.danger-button:hover { border-color: #e99090; background: rgba(210,70,70,.08); }
.inline-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-actions .button { min-height: 32px; padding: 6px 9px; font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.metric-card { padding: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 11px; border-radius: 17px; }
.metric-card .stat-label { font-size: 12px; color: var(--muted); }
.metric-value { display: block; font-size: 32px; line-height: 1.2; font-weight: 550; letter-spacing: -1.2px; color: var(--text); }
.metric-card small { color: var(--muted); font-size: 11px; }
.data-panel { border-radius: 18px; padding: 22px; min-width: 0; }
.data-panel h3, .report-heading h3 { font-size: 16px; font-weight: 550; letter-spacing: -.3px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.page-toolbar h3 { margin-bottom: 5px; }
.toolbar-filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.toolbar-filters .field { flex: 1 1 140px; max-width: 220px; }
.toolbar-filters .search-field { flex: 2 1 220px; max-width: none; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 11px; color: var(--muted); min-width: 0; line-height: 1.4; }
.field > span { font-weight: 550; }
input, select, textarea { color: var(--text); background: var(--field-bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; width: 100%; min-width: 0; font-size: 12px; line-height: 1.4; }
input, select { min-height: 41px; }
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--surface); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .72; }
input[type=file] { padding: 8px; }
input[type=file]::file-selector-button { font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 6px; background: var(--field-bg); padding: 6px 9px; margin-right: 8px; cursor: pointer; }
.table-wrap { overflow-x: auto; max-width: 100%; scrollbar-width: thin; border-radius: 10px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 12px; text-align: left; }
.data-table th { padding: 13px 12px; color: var(--muted); font-weight: 500; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; border-block: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 17px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; min-width: 110px; max-width: 300px; overflow-wrap: anywhere; line-height: 1.6; }
.data-table td:first-child { min-width: 175px; }
.data-table td:last-child { min-width: 145px; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(78,194,197,.025); }
.record-link { font: inherit; color: var(--text); font-size: 13px; font-weight: 550; cursor: pointer; background: none; border: none; padding: 0; text-align: left; overflow-wrap: anywhere; }
.record-link:hover { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.record-heading { font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.record-subtitle, .muted { color: var(--muted); font-size: 11px; line-height: 1.65; }
.record-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; font-size: 10px; margin-top: 4px; letter-spacing: .3px; }
.badge { display: inline-flex; align-items: center; border-radius: 6px; padding: 4px 8px; background: rgba(78,194,197,.08); color: var(--teal); border: 1px solid rgba(78,194,197,.15); font-size: 10px; line-height: 1.3; white-space: nowrap; }
.pagination { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 45px 22px; min-height: 220px; }
.empty-state h3 { font-size: 17px; font-weight: 500; letter-spacing: -.3px; }
.empty-state p { color: var(--muted); line-height: 1.7; font-size: 12px; max-width: 460px; }
.empty-symbol { width: 43px; height: 43px; border-radius: 13px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--teal); font-size: 25px; margin-bottom: 4px; }
.loading-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.callout { border: 1px solid rgba(78,194,197,.15); background: rgba(78,194,197,.045); border-radius: 12px; padding: 15px 17px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.callout strong { color: var(--text); }
.callout a { text-decoration: underline; text-underline-offset: 3px; }

/* UI-DIALOG: native modal semantics, focus containment, validation, and action state. */
.workspace-dialog { color: var(--text); background: var(--surface); border: 1px solid var(--glass-border); border-radius: 20px; width: min(650px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 25px; box-shadow: 0 24px 90px rgba(0,0,0,.4); }
.workspace-dialog::backdrop { background: rgba(0,8,5,.7); backdrop-filter: blur(6px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { font-size: 21px; letter-spacing: -.5px; font-weight: 550; }
.dialog-heading .icon-button { flex-shrink: 0; font-size: 25px; }
.dialog-form { display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px; }
.form-grid > p, .form-grid > .field:has(textarea), .form-grid > .field:has(input[type=file]) { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 15px; border-top: 1px solid var(--line); }
.dialog-form > div > .field { margin-top: 15px; }
.dialog-form > .form-grid > .field { margin-top: 0; }
.form-error { color: #ffb8af; font-size: 12px; padding: 12px; border: 1px solid rgba(255,150,150,.2); border-radius: 8px; background: rgba(210,70,70,.08); line-height: 1.6; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.detail-list { display: grid; gap: 8px 16px; grid-template-columns: minmax(90px,.7fr) 1.3fr; font-size: 12px; margin-block: 15px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-list:has(> div) { display: flex; flex-direction: column; gap: 14px; }
.detail-list > div { display: grid; grid-template-columns: minmax(75px,.7fr) 1.3fr; gap: 12px; }
.timeline { list-style: none; margin: 17px 0 0 7px; border-left: 1px solid var(--line); padding-left: 19px; }
.timeline li { position: relative; padding: 0 0 22px; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.timeline li::before { position: absolute; content: ""; left: -23px; top: 6px; width: 7px; height: 7px; border: 2px solid var(--surface); border-radius: 50%; background: var(--teal); }
.timeline strong { font-size: 12px; font-weight: 550; }
.timeline p { color: var(--muted); white-space: pre-wrap; margin: 4px 0; }
.timeline li:last-child { padding-bottom: 5px; }
.linked-records { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 12px 0; font-size: 12px; }
.notification { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50; max-width: min(560px,calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--teal); border-radius: 12px; padding: 14px 20px; box-shadow: 0 8px 40px rgba(0,0,0,.3); font-size: 12px; line-height: 1.6; }
.notification[data-type=error] { border-color: #f6a6a6; }

/* PAGE-TRACKING: fixed stage order, horizontal board, and accessible table alternative. */
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; gap: 3px; }
.segmented .button { border: none; min-height: 30px; background: none; padding: 6px 13px; }
.segmented .button[aria-pressed=true] { background: rgba(78,194,197,.13); color: var(--teal); }
.pipeline-board { display: grid; grid-template-columns: repeat(6,minmax(180px,1fr)); gap: 12px; overflow-x: auto; padding-bottom: 14px; margin-top: 18px; scrollbar-width: thin; }
.pipeline-column { border: 1px solid var(--line); border-top: 2px solid rgba(78,194,197,.6); border-radius: 11px; padding: 12px; background: rgba(0,0,0,.07); min-height: 270px; }
.pipeline-column:nth-child(n+4) { border-top-color: rgba(220,255,120,.65); }
.pipeline-column-header { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding-bottom: 13px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.pipeline-column-header h4 { font-size: 12px; font-weight: 550; flex: 1; }
.stage-number { font-size: 9px; color: var(--muted); font-family: monospace; }
.pipeline-column-header .badge { padding: 3px 6px; }
.pipeline-card { border: 1px solid var(--line); background: var(--field-bg); border-radius: 10px; padding: 13px; margin-bottom: 10px; }
.pipeline-card .record-link { font-size: 12px; }
.pipeline-card .inline-actions { margin-top: 14px; }
.pipeline-card .inline-actions .button { font-size: 10px; padding: 5px 7px; min-height: 28px; }
.stage-age { color: var(--teal); font-size: 10px; margin-top: 14px; }
.next-action { color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.pipeline-empty { padding: 25px 5px; text-align: center; font-size: 10px; }
.stage-transition { display: flex; align-items: center; gap: 14px; margin-block: 20px; }

/* PAGE-OVERVIEW: metrics and activity are calculated from saved local records. */
.overview-grid { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(260px,1fr); gap: 17px; }
.overview-side { display: flex; flex-direction: column; gap: 17px; }
.overview-side .data-panel { flex: 1; }
.overview-progress { display: flex; align-items: baseline; gap: 8px; margin-top: 25px; }
.overview-progress strong { font-size: 45px; font-weight: 500; letter-spacing: -2px; }
.overview-progress span { color: var(--muted); font-size: 13px; }
progress { display: block; width: 100%; height: 7px; border-radius: 8px; overflow: hidden; margin-block: 14px; border: none; background: var(--field-bg); accent-color: var(--lime); }
progress::-webkit-progress-bar { background: var(--field-bg); border-radius: 8px; }
progress::-webkit-progress-value { background: var(--lime); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--lime); border-radius: 8px; }
.overview-side .empty-state { padding: 25px 8px; min-height: 155px; }
.overview-side .empty-state h3 { font-size: 14px; }
.overview-side .empty-symbol { display: none; }
.activity-list { list-style: none; display: flex; flex-direction: column; margin-top: 13px; }
.activity-list li { display: flex; align-items: flex-start; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.activity-list li:last-child { border-bottom: none; }
.activity-marker { background: rgba(78,194,197,.1); border: 1px solid rgba(78,194,197,.14); color: var(--teal); width: 29px; height: 29px; border-radius: 9px; flex-shrink: 0; display: grid; place-items: center; font-size: 12px; }
.activity-list .record-heading { font-size: 12px; }
.activity-list .record-subtitle { font-size: 10px; margin-top: 4px; }
.activity-chart { width: 100%; height: 210px; margin-block: 22px 6px; overflow: visible; }
.activity-chart text { fill: var(--muted); font-family: inherit; font-size: 10px; }
.activity-chart .chart-guide { stroke: var(--line); stroke-dasharray: 3 5; }
.activity-chart .lead-bar { fill: var(--teal); }
.activity-chart .visit-bar { fill: var(--lime); }
.chart-legend { display: flex; justify-content: flex-start; gap: 20px; }
.chart-legend .legend-item { font-size: 10px; }
.chart-footnote { margin-top: 14px; }
.quick-create { display: flex; flex-direction: column; gap: 12px; }
.quick-create a { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 5px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); }
.quick-create a:hover { background: rgba(78,194,197,.06); border-color: var(--teal); }
.quick-create strong { font-size: 14px; font-weight: 550; }
.quick-create span { color: var(--muted); font-size: 12px; }

/* PAGE-REPORTS / PAGE-SETTINGS: readable exports and workspace preferences. */
.settings-grid { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 18px; }
.settings-grid > div { display: flex; flex-direction: column; gap: 18px; }
.settings-grid h3 { margin-bottom: 12px; }
.settings-grid form { display: flex; flex-direction: column; gap: 19px; }
.settings-grid form > .primary-button { align-self: flex-start; }
.settings-grid .detail-list { display: flex; flex-direction: column; gap: 11px; }
.settings-grid .button { margin-top: 17px; align-self: flex-start; }
.report-sheet { display: flex; flex-direction: column; gap: 20px; }
.report-heading { display: flex; flex-direction: column; gap: 8px; }
.report-sheet > .metric-grid { margin-block: 0; }
.bottom-strip { margin-top: auto; }
body.light-mode .status-pill { color: #36554b; border-color: var(--line); }
body.light-mode .brand-dot { color: #5b7b27; }
body.light-mode .badge { color: #176266; background: rgba(78,194,197,.09); }
body.light-mode .form-error, body.light-mode .danger-button { color: #a63c38; }
body.light-mode .primary-button { color: #23370b; background: #d8ef9d; border-color: #c7df8a; }
body.light-mode .pipeline-column { background: rgba(255,255,255,.14); }
body.light-mode .stage-age, body.light-mode .eyebrow, body.light-mode .breadcrumb span, body.light-mode .segmented .button[aria-pressed=true] { color: #176266; }
body.light-mode .icon-button { color: var(--text); border-color: var(--line); }

/* UI-RESPONSIVE: keep tables and the pipeline scrolling inside their own panels. */
@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview-grid { grid-template-columns: minmax(0,1fr); }
  .overview-side { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .settings-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 760px) {
  .sidebar { min-height: 0; }
  .brand { padding-bottom: 6px; }
  .brand-name { font-size: 23px; }
  .sidebar-bottom { padding-top: 0; margin-top: 0; }
  .sidebar-bottom .workspace-note, .sidebar-bottom .profile { display: none; }
  #sign-out { margin: 10px 0 0; width: 100%; }
  .nav-label { display: none; }
  .navigation { grid-template-columns: repeat(4,minmax(0,1fr)); margin-top: 12px; }
  .nav-item { font-size: 10px; min-height: 55px; gap: 6px; }
  .page-intro, .welcome { align-items: flex-start; flex-direction: column; gap: 15px; }
  .page-intro h2, .welcome h2 { font-size: 26px; }
  .page-content { gap: 16px; }
  .data-panel { padding: 17px; }
  .toolbar-filters .field { max-width: none; }
  .pipeline-board { grid-template-columns: repeat(6,220px); }
  .page-toolbar { align-items: flex-start; }
  .topbar { padding: 16px; }
  .form-grid, .detail-grid { grid-template-columns: minmax(0,1fr); }
  .workspace-dialog { padding: 20px; }
}
@media (max-width: 430px) {
  .overview-side { display: flex; }
  .metric-card { padding: 16px; }
  .metric-value { font-size: 28px; }
  .page-intro .inline-actions { width: 100%; }
  .page-intro .inline-actions .button { flex: 1; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dd { margin-bottom: 10px; }
}
@supports not (backdrop-filter: blur(1px)) { .glass { background: var(--surface); } }
@media print {
  :root, body, body.light-mode { --bg: #fff; --text: #111; --muted: #555; --line: #ddd; --surface: #fff; color: #111; background: #fff; }
  .ambient-bg, .sidebar, .topbar, .bottom-strip, .notification, .skip-link, .page-intro, .page-toolbar, .toolbar-filters, button, dialog, .report-controls, .no-print { display: none !important; }
  .app-shell, .workspace, .page-content { display: block; padding: 0; margin: 0; }
  .glass, .glass-panel, .data-panel { background: #fff !important; color: #111; border-color: #ddd; box-shadow: none; backdrop-filter: none; overflow: visible; }
  .glass-panel::before { display: none; }
  .data-panel { padding: 14px; margin-bottom: 18px; }
  .metric-grid { grid-template-columns: repeat(4,1fr); }
  .metric-card { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .data-table { font-size: 9px; }
  .data-table td { min-width: 0 !important; max-width: none; padding: 8px; }
  .data-table th { padding: 8px; }
  .data-table tr { break-inside: avoid; }
  .data-table thead { display: table-header-group; }
  .badge { color: #222; background: #eee; border-color: #ccc; }
  @page { size: A4 landscape; margin: 14mm; }
}
