:root {
  --crm-ink: #141414;
  --crm-muted: #686866;
  --crm-faint: #a7a7a2;
  --crm-paper: #f5f5f1;
  --crm-surface: #ffffff;
  --crm-line: #dfdfd8;
  --crm-line-strong: #cacac2;
  --crm-orange: #f47721;
  --crm-orange-soft: #fff0e4;
  --crm-danger: #b7342d;
  --crm-shadow: 0 22px 70px rgba(23, 22, 18, .10);
  --crm-radius: 22px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--crm-paper); scroll-behavior: smooth; }
/* Both documents opt in so footer/home navigation does not abort its transition. */
@view-transition { navigation: auto; }
body { background: var(--crm-paper); color: var(--crm-ink); margin: 0; min-width: 320px; overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--crm-orange); outline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
.skip-link { background: var(--crm-ink); color: white; left: 16px; padding: 11px 15px; position: fixed; top: -60px; z-index: 1000; }
.skip-link:focus { top: 16px; }

.eyebrow { color: var(--crm-muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; margin: 0; text-transform: uppercase; }
.eyebrow i { background: var(--crm-orange); border-radius: 50%; display: inline-block; height: 7px; margin-right: 7px; vertical-align: 1px; width: 7px; }
.button { align-items: center; appearance: none; border: 1px solid transparent; border-radius: 999px; display: inline-flex; font-size: 12px; font-weight: 700; gap: 14px; justify-content: center; letter-spacing: .02em; min-height: 43px; padding: 10px 17px; transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.button:hover { transform: translateY(-2px); }
.button--primary { background: var(--crm-ink); box-shadow: 0 10px 22px rgba(20,20,20,.14); color: #fff; }
.button--primary b { color: var(--crm-orange); font-size: 18px; line-height: 0; }
.button--primary:hover { background: #2b2b29; box-shadow: 0 13px 28px rgba(20,20,20,.2); }
.button--quiet { background: rgba(255,255,255,.65); border-color: var(--crm-line); color: var(--crm-ink); }
.button--quiet:hover { background: #fff; border-color: var(--crm-line-strong); }
.button--danger { background: var(--crm-danger); color: #fff; }
.button-link { background: transparent; border: 0; color: var(--crm-ink); font-size: 12px; font-weight: 700; padding: 5px 0; text-decoration: underline; text-decoration-color: var(--crm-line-strong); text-underline-offset: 4px; }
.button-link:hover { text-decoration-color: var(--crm-orange); }
.button-link--left { align-self: flex-start; }
.icon-button { align-items: center; background: transparent; border: 1px solid var(--crm-line); border-radius: 50%; color: var(--crm-ink); display: inline-flex; font-size: 22px; height: 40px; justify-content: center; line-height: 1; padding: 0; transition: background .2s, color .2s, transform .2s; width: 40px; }
.icon-button:hover { background: var(--crm-ink); color: #fff; transform: rotate(4deg); }

/* Authentication */
.auth-shell { background: var(--crm-paper); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(430px, .9fr); min-height: 100svh; }
.auth-intro { background: var(--crm-ink); color: #fff; display: flex; flex-direction: column; justify-content: space-between; min-height: 100svh; overflow: hidden; padding: clamp(30px,4.5vw,70px); position: relative; }
.auth-intro:before, .auth-intro:after { border: 1px solid rgba(255,255,255,.2); border-radius: 50%; content: ""; pointer-events: none; position: absolute; }
.auth-intro:before { height: min(68vw,950px); right: -27%; top: 18%; width: min(68vw,950px); }
.auth-intro:after { background: radial-gradient(circle, rgba(244,119,33,.88) 0 9%, rgba(244,119,33,.18) 34%, transparent 69%); filter: blur(12px); height: min(54vw,700px); right: -8%; top: 28%; width: min(54vw,700px); }
.auth-wordmark, .sidebar-wordmark { font-size: 18px; font-weight: 900; letter-spacing: -.13em; position: relative; text-transform: uppercase; white-space: nowrap; z-index: 1; }
.auth-wordmark span, .sidebar-wordmark span { color: var(--crm-orange); }
.auth-intro-copy { max-width: 610px; padding: 70px 0; position: relative; z-index: 1; }
.auth-intro .eyebrow { color: rgba(255,255,255,.65); }
.auth-intro h1 { font-size: clamp(52px,7.4vw,122px); font-weight: 430; letter-spacing: -.095em; line-height: .84; margin: 23px 0 28px; }
.auth-intro h1 em { color: var(--crm-orange); font-style: normal; }
.auth-intro-copy > p { color: rgba(255,255,255,.67); font-size: clamp(16px,1.25vw,21px); line-height: 1.45; margin: 0; max-width: 470px; }
.auth-security-note { color: rgba(255,255,255,.58); font-size: 11px; letter-spacing: .02em; margin: 0; position: relative; z-index: 1; }
.auth-security-note span { color: #9ed38f; font-size: 13px; margin-right: 7px; }
.auth-panel { align-items: center; display: flex; justify-content: center; padding: 50px 28px; }
.auth-card { max-width: 440px; width: 100%; }
.auth-card-heading h2 { font-size: clamp(38px,4vw,54px); font-weight: 450; letter-spacing: -.075em; line-height: .96; margin: 16px 0 13px; }
.auth-card-heading > p:last-child, .auth-help, .form-intro { color: var(--crm-muted); font-size: 14px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 19px; margin-top: 40px; }
.auth-form label, .inline-form label, .modal-card label { color: var(--crm-muted); display: flex; flex-direction: column; font-size: 11px; font-weight: 700; gap: 8px; letter-spacing: .04em; text-transform: uppercase; }
.auth-form input, .inline-form input, .inline-form select, .modal-card input, .modal-card select, .modal-card textarea, .note-form textarea { background: #fff; border: 1px solid var(--crm-line); border-radius: 10px; color: var(--crm-ink); min-height: 48px; outline: none; padding: 11px 13px; text-transform: none; transition: border-color .2s, box-shadow .2s; }
.auth-form input:focus, .inline-form input:focus, .inline-form select:focus, .modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus, .note-form textarea:focus { border-color: var(--crm-orange); box-shadow: 0 0 0 3px rgba(244,119,33,.12); }
.auth-form .button { margin-top: 4px; min-height: 52px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 25px; }
.auth-status { color: var(--crm-muted); font-size: 13px; line-height: 1.45; margin-top: 26px; min-height: 20px; }
.auth-status.is-error { color: var(--crm-danger); }
.auth-status.is-success { color: #2d6b3d; }
.auth-help { border-top: 1px solid var(--crm-line); margin: 36px 0 0; padding-top: 22px; }

/* Workspace shell */
.workspace-shell { background: var(--crm-paper); min-height: 100svh; }
.sidebar { background: var(--crm-ink); bottom: 0; color: #fff; display: flex; flex-direction: column; left: 0; padding: 28px 18px; position: fixed; top: 0; width: 244px; z-index: 40; }
.sidebar-top { align-items: center; display: flex; justify-content: space-between; padding: 0 10px; }
.sidebar-kicker { color: rgba(255,255,255,.46); font-size: 9px; font-weight: 700; letter-spacing: .12em; margin: 66px 10px 18px; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-item { align-items: center; background: transparent; border: 0; border-radius: 10px; color: rgba(255,255,255,.68); display: grid; font-size: 13px; font-weight: 650; gap: 11px; grid-template-columns: 22px 1fr auto; min-height: 46px; padding: 0 11px; text-align: left; transition: background .2s, color .2s, transform .2s; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(2px); }
.nav-item.is-active { background: #fff; color: var(--crm-ink); }
.nav-item b { background: rgba(255,255,255,.12); border-radius: 999px; font-size: 10px; padding: 3px 7px; }
.nav-item.is-active b { background: var(--crm-orange-soft); color: #a64b0f; }
.nav-glyph { color: var(--crm-orange); font-size: 18px; font-weight: 400; text-align: center; }
.nav-glyph--task::before, .nav-glyph--task::after { background: currentColor; content: ''; display: block; height: 1px; margin: 5px auto; width: 13px; }
.nav-glyph--task::after { width: 8px; }
.menu-lines { display: grid; gap: 4px; width: 16px; }
.menu-lines i { background: currentColor; display: block; height: 1px; width: 100%; }
.sidebar-close, .sidebar-open { display: none; }
.workspace-frame { margin-left: 244px; min-height: 100svh; }
.workspace-header { align-items: center; background: rgba(245,245,241,.89); backdrop-filter: blur(14px); border-bottom: 1px solid var(--crm-line); display: flex; gap: 26px; justify-content: space-between; min-height: 88px; padding: 17px clamp(24px,4vw,64px); position: sticky; top: 0; z-index: 30; }
.workspace-header h1 { font-size: clamp(24px,2.6vw,38px); font-weight: 450; letter-spacing: -.065em; line-height: 1; margin: 5px 0 0; }
.workspace-actions { align-items: center; display: flex; gap: 11px; }
.global-search { align-items: center; background: #fff; border: 1px solid var(--crm-line); border-radius: 999px; color: var(--crm-faint); display: flex; font-size: 16px; gap: 7px; min-height: 40px; padding: 0 14px; }
.global-search input { background: transparent; border: 0; color: var(--crm-ink); font-size: 12px; outline: none; width: 150px; }
.user-menu { align-items: center; background: transparent; border: 0; color: var(--crm-ink); display: flex; gap: 9px; max-width: 240px; padding: 0 0 0 3px; text-align: left; }
.user-avatar { align-items: center; background: var(--crm-orange-soft); border-radius: 50%; color: #a44d13; display: flex; font-size: 11px; font-weight: 800; height: 35px; justify-content: center; width: 35px; }
.user-email { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-popover { background: #fff; border: 1px solid var(--crm-line); border-radius: 13px; box-shadow: var(--crm-shadow); padding: 9px; position: absolute; right: clamp(24px,4vw,64px); top: 76px; width: 225px; z-index: 50; }
.account-popover p { color: var(--crm-muted); font-size: 11px; margin: 5px 8px 9px; overflow-wrap: anywhere; }
.account-popover button { background: #fff4f2; border: 0; border-radius: 8px; color: var(--crm-danger); font-size: 12px; font-weight: 700; padding: 10px; text-align: left; width: 100%; }
.workspace-main { margin: 0 auto; max-width: 1600px; min-height: calc(100svh - 138px); padding: clamp(34px,4.5vw,70px) clamp(24px,4vw,64px); }
.workspace-view { animation: view-enter .32s ease both; }
@keyframes view-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.view-heading { align-items: end; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 32px; }
.view-heading h2 { font-size: clamp(35px,4vw,63px); font-weight: 440; letter-spacing: -.085em; line-height: .9; margin: 10px 0 0; }
.view-heading-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.workspace-footer { border-top: 1px solid var(--crm-line); color: var(--crm-muted); display: flex; font-size: 11px; justify-content: space-between; margin: 0 clamp(24px,4vw,64px); padding: 20px 0; }
.workspace-footer a { color: var(--crm-ink); text-decoration: underline; text-underline-offset: 4px; }

/* Dashboard */
.metric-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card, .surface-panel, .finance-summary article { background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); box-shadow: 0 8px 24px rgba(20,20,20,.025); }
.metric-card { min-height: 173px; padding: 23px; }
.metric-card p, .finance-summary p { color: var(--crm-muted); font-size: 11px; font-weight: 700; letter-spacing: .05em; margin: 0; text-transform: uppercase; }
.metric-card strong { display: block; font-size: clamp(31px,3vw,48px); font-weight: 500; letter-spacing: -.075em; line-height: 1; margin: 25px 0 16px; }
.metric-card [data-metric="value"] { font-size: clamp(22px,2.25vw,32px); overflow-wrap: anywhere; word-break: break-word; }
.metric-card span, .finance-summary span { color: var(--crm-muted); font-size: 11px; }
.metric-card--accent { background: var(--crm-orange); border-color: var(--crm-orange); color: #fff; }
.metric-card--accent p, .metric-card--accent span { color: rgba(255,255,255,.75); }
.dashboard-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-top: 14px; }
.surface-panel { min-height: 350px; padding: 24px; }
.panel-heading { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 20px; }
.panel-heading h3 { font-size: 23px; font-weight: 500; letter-spacing: -.06em; margin: 8px 0 0; }
.stack-list, .activity-list, .task-list, .notes-list { display: grid; }
.stack-list { gap: 10px; }
.empty-inline { color: var(--crm-muted); font-size: 13px; margin: 23px 0; }
.followup-item, .activity-item, .task-item, .note-item { border-top: 1px solid var(--crm-line); }
.followup-item { align-items: center; display: grid; gap: 15px; grid-template-columns: 40px 1fr auto; padding: 14px 0; }
.followup-avatar { align-items: center; background: var(--crm-orange-soft); border-radius: 50%; color: #a94d11; display: flex; font-size: 11px; font-weight: 800; height: 37px; justify-content: center; width: 37px; }
.followup-item strong, .activity-item strong, .task-item strong { font-size: 13px; font-weight: 750; }
.followup-item p, .activity-item p, .task-item p, .note-item p { color: var(--crm-muted); font-size: 12px; line-height: 1.4; margin: 4px 0 0; }
.followup-item time { color: var(--crm-muted); font-size: 11px; white-space: nowrap; }
.activity-item { display: grid; gap: 11px; grid-template-columns: 9px 1fr; padding: 15px 0; }
.activity-item > i { background: var(--crm-orange); border-radius: 50%; height: 7px; margin-top: 5px; width: 7px; }
.activity-item time, .note-item time { color: var(--crm-faint); font-size: 10px; }

/* Filters + tables */
.filter-bar { align-items: center; background: rgba(255,255,255,.6); border: 1px solid var(--crm-line); border-radius: 14px; display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 17px; padding: 10px; }
.filter-search { align-items: center; background: #fff; border: 1px solid var(--crm-line); border-radius: 9px; color: var(--crm-faint); display: flex; flex: 1 1 270px; gap: 8px; min-height: 38px; padding: 0 11px; }
.filter-search input { background: transparent; border: 0; color: var(--crm-ink); font-size: 12px; outline: 0; width: 100%; }
.field-select { align-items: center; background: #fff; border: 1px solid var(--crm-line); border-radius: 9px; display: flex; gap: 8px; min-height: 38px; padding: 0 10px; }
.field-select > span { color: var(--crm-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.field-select select { appearance: none; background: transparent; border: 0; color: var(--crm-ink); font-size: 12px; outline: 0; padding: 0 15px 0 0; }
.result-count { color: var(--crm-muted); font-size: 11px; margin-left: auto; padding: 0 7px; white-space: nowrap; }
.data-state { color: var(--crm-muted); font-size: 13px; min-height: 5px; }
.data-state.is-error { background: #fff1ef; border: 1px solid #ffd7d2; border-radius: 10px; color: var(--crm-danger); margin-bottom: 14px; padding: 11px 13px; }
.lead-table-wrap { background: var(--crm-surface); border: 1px solid var(--crm-line); border-radius: var(--crm-radius); overflow-x: auto; }
.data-table { border-collapse: collapse; min-width: 680px; width: 100%; }
.data-table th { background: rgba(245,245,241,.7); color: var(--crm-muted); font-size: 10px; font-weight: 750; letter-spacing: .07em; padding: 14px 17px; text-align: left; text-transform: uppercase; }
.data-table td { border-top: 1px solid var(--crm-line); font-size: 12px; padding: 14px 17px; vertical-align: middle; }
.data-table tbody tr { transition: background .18s; }
.data-table tbody tr:hover { background: #fffaf5; }
.table-person { display: grid; gap: 3px; }
.table-person strong { font-size: 13px; font-weight: 750; }
.table-person span { color: var(--crm-muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-action { background: transparent; border: 0; color: var(--crm-ink); font-size: 11px; font-weight: 750; padding: 5px; text-decoration: underline; text-underline-offset: 3px; }
.table-muted { color: var(--crm-faint); font-size: 11px; font-weight: 650; }
.status-pill, .priority-pill, .kind-pill, .task-status { border-radius: 999px; display: inline-flex; font-size: 10px; font-weight: 750; line-height: 1; padding: 6px 8px; text-transform: capitalize; }
.status-new, .status-draft { background: #edf1f0; color: #51605e; }
.status-contacted, .status-pending { background: #fff0df; color: #9a5418; }
.status-qualified, .status-paid, .status-won { background: #e7f5e6; color: #37683c; }
.status-proposal { background: #eef0fb; color: #515a91; }
.status-lost, .status-spam, .status-void { background: #f4e9e7; color: #89504b; }
.status-archived { background: #eeeeeb; color: #73736d; }
.priority-high { background: #ffebe7; color: #b24432; }
.priority-normal { background: #f0f0ec; color: #62625e; }
.priority-low { background: #f6f6f4; color: #888882; }
.kind-income { background: #e7f5e6; color: #37683c; }
.kind-expense { background: #fff0df; color: #9a5418; }
.pagination { align-items: center; display: flex; gap: 13px; justify-content: center; margin-top: 18px; }
.pagination span { color: var(--crm-muted); font-size: 12px; }

/* Lead board */
.kanban-board { display: grid; gap: 12px; grid-auto-columns: minmax(250px, 1fr); grid-auto-flow: column; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { background: rgba(255,255,255,.55); border: 1px solid var(--crm-line); border-radius: 16px; min-height: 390px; padding: 12px; }
.kanban-heading { align-items: center; display: flex; justify-content: space-between; margin: 3px 4px 12px; }
.kanban-heading h3 { font-size: 12px; letter-spacing: -.02em; margin: 0; text-transform: capitalize; }
.kanban-heading span { color: var(--crm-muted); font-size: 10px; }
.kanban-card { background: #fff; border: 1px solid var(--crm-line); border-radius: 12px; display: grid; gap: 12px; margin-top: 9px; padding: 13px; text-align: left; width: 100%; }
.kanban-card:hover { border-color: #f0b27e; box-shadow: 0 10px 20px rgba(20,20,20,.06); }
.kanban-card strong { font-size: 13px; }
.kanban-card p { color: var(--crm-muted); font-size: 11px; margin: 3px 0 0; }
.kanban-card-footer { align-items: center; display: flex; justify-content: space-between; }

/* Finance + tasks */
.finance-summary { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0,1fr)); margin-bottom: 17px; }
.finance-summary article { padding: 20px; }
.finance-summary strong { display: block; font-size: clamp(27px,2.6vw,41px); font-weight: 500; letter-spacing: -.065em; margin: 21px 0 10px; overflow-wrap: anywhere; word-break: break-word; }
.task-layout { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.task-item { align-items: center; display: grid; gap: 12px; grid-template-columns: 20px 1fr auto; padding: 15px 0; }
.task-check { appearance: none; background: #fff; border: 1px solid var(--crm-line-strong); border-radius: 5px; height: 17px; margin: 0; width: 17px; }
.task-check:checked { background: var(--crm-orange); border-color: var(--crm-orange); box-shadow: inset 0 0 0 4px #fff; }
.task-item.is-done strong { color: var(--crm-muted); text-decoration: line-through; }
.task-due { color: var(--crm-muted); font-size: 10px; text-align: right; }
.count-chip { background: var(--crm-orange-soft); border-radius: 999px; color: #a54c11; font-size: 10px; font-weight: 800; padding: 5px 8px; }

/* Drawer and dialogs */
.drawer { border: 0; height: 100%; inset: 0; margin: 0; max-height: none; max-width: none; overflow: visible; padding: 0; position: fixed; width: 100%; z-index: 80; }
.drawer::backdrop { background: rgba(14,14,13,.42); }
.drawer-scrim { background: rgba(14,14,13,.42); inset: 0; position: absolute; }
.drawer-card { background: var(--crm-paper); box-shadow: -24px 0 80px rgba(0,0,0,.16); height: 100%; margin-left: auto; max-width: 620px; overflow-y: auto; padding: 30px; position: relative; width: min(100%,620px); }
.drawer-header, .modal-header { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; }
.drawer-header h2, .modal-card h2 { font-size: 32px; font-weight: 500; letter-spacing: -.07em; line-height: .95; margin: 8px 0 0; }
.drawer-meta { border-bottom: 1px solid var(--crm-line); color: var(--crm-muted); display: flex; flex-wrap: wrap; font-size: 11px; gap: 9px 16px; margin: 28px 0 15px; padding-bottom: 15px; }
.drawer-contact { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 25px; }
.drawer-contact a, .drawer-contact span { background: #fff; border: 1px solid var(--crm-line); border-radius: 999px; font-size: 11px; padding: 8px 10px; }
.lead-context { border-bottom: 1px solid var(--crm-line); padding: 5px 0 24px; }
.lead-context .panel-heading { margin-bottom: 12px; }
.lead-context .panel-heading h3 { font-size: 20px; }
.lead-message { color: var(--crm-ink); font-size: 13px; line-height: 1.55; margin: 0 0 16px; overflow-wrap: anywhere; white-space: pre-wrap; }
.brief-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.brief-grid > div { background: #fff; border: 1px solid var(--crm-line); border-radius: 10px; min-width: 0; padding: 10px; }
.brief-grid > div:last-child { grid-column: 1 / -1; }
.brief-grid dt { color: var(--crm-muted); font-size: 9px; font-weight: 750; letter-spacing: .07em; margin-bottom: 5px; text-transform: uppercase; }
.brief-grid dd { color: var(--crm-ink); font-size: 12px; line-height: 1.42; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.inline-form { border-bottom: 1px solid var(--crm-line); display: grid; gap: 18px; padding: 6px 0 27px; }
.form-grid { display: grid; gap: 15px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-span { grid-column: 1 / -1; }
.notes-section { padding-top: 27px; }
.notes-list { gap: 0; max-height: 300px; overflow-y: auto; }
.note-item { padding: 13px 0; }
.note-item p { color: var(--crm-ink); white-space: pre-wrap; }
.note-form { display: grid; gap: 10px; margin-top: 16px; }
.note-form textarea { min-height: 76px; resize: vertical; }
.danger-link { color: var(--crm-danger); margin-top: 28px; }
.modal { background: transparent; border: 0; max-height: none; max-width: none; padding: 24px; width: min(100%,760px); }
.modal::backdrop { background: rgba(14,14,13,.48); backdrop-filter: blur(3px); }
.modal-card { background: var(--crm-paper); border: 1px solid rgba(255,255,255,.45); border-radius: 22px; box-shadow: var(--crm-shadow); display: grid; gap: 18px; max-height: calc(100svh - 48px); overflow-y: auto; padding: 28px; }
.modal-card--compact { max-width: 560px; }
.modal-card textarea { min-height: 90px; resize: vertical; }
.check-grid { border: 0; display: grid; gap: 10px; margin: 0; padding: 0; }
.check-grid legend { color: var(--crm-muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; margin-bottom: 9px; padding: 0; text-transform: uppercase; }
.check-grid label { align-items: center; color: var(--crm-ink); cursor: pointer; flex-direction: row; font-size: 12px; font-weight: 500; gap: 8px; letter-spacing: 0; text-transform: none; }
.check-grid input { accent-color: var(--crm-orange); min-height: auto; padding: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }
.toast-region { bottom: 22px; display: grid; gap: 9px; pointer-events: none; position: fixed; right: 22px; width: min(360px, calc(100vw - 44px)); z-index: 100; }
.toast { animation: toast-in .25s ease both; background: var(--crm-ink); border-radius: 12px; box-shadow: var(--crm-shadow); color: #fff; font-size: 13px; line-height: 1.35; padding: 13px 15px; }
.toast.is-error { background: var(--crm-danger); }
.toast.is-success { background: #2f6a3f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.noscript-message { background: #fff4df; bottom: 0; color: #6b4210; left: 0; padding: 14px; position: fixed; right: 0; text-align: center; z-index: 1000; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace-header { gap: 13px; }
  .global-search { display: none; }
}
@media (max-width: 820px) {
  .auth-shell { display: block; }
  .auth-intro { min-height: 410px; padding: 26px 24px; }
  .auth-intro-copy { padding: 58px 0 38px; }
  .auth-intro h1 { font-size: clamp(48px,13vw,77px); }
  .auth-panel { padding: 45px 24px; }
  .sidebar { box-shadow: 18px 0 52px rgba(0,0,0,.26); transform: translateX(-105%); transition: transform .28s ease; width: min(286px,86vw); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close, .sidebar-open { display: inline-flex; }
  .workspace-frame { margin-left: 0; }
  .workspace-header { min-height: 76px; padding: 13px 20px; }
  .workspace-actions { margin-left: auto; }
  .workspace-header .eyebrow { display: none; }
  .workspace-header h1 { font-size: 25px; }
  .user-email { display: none; }
  .workspace-main { min-height: calc(100svh - 126px); padding: 38px 20px; }
  .view-heading { align-items: flex-start; flex-direction: column; margin-bottom: 24px; }
  .view-heading-actions { justify-content: flex-start; }
  .dashboard-grid, .task-layout { grid-template-columns: 1fr; }
  .workspace-footer { margin: 0 20px; }
  .drawer-card { max-width: 100%; width: 100%; }
}
@media (max-width: 570px) {
  .metric-grid, .finance-summary { grid-template-columns: 1fr; }
  .metric-card:last-child, .finance-summary article:last-child { grid-column: auto; }
  .metric-card { min-height: 145px; padding: 17px; }
  .metric-card strong { font-size: 33px; margin: 20px 0 11px; }
  .filter-bar { align-items: stretch; }
  .field-select { flex: 1 1 130px; }
  .result-count { margin-left: 0; }
  .view-heading h2 { font-size: 42px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-span { grid-column: auto; }
  .brief-grid { grid-template-columns: 1fr; }
  .brief-grid > div:last-child { grid-column: auto; }
  .drawer-card { padding: 24px 18px; }
  .modal { padding: 10px; }
  .modal-card { border-radius: 16px; max-height: calc(100svh - 20px); padding: 21px; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .button { flex: 1; }
  .workspace-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
