:root {
    color-scheme: light;
    --ink: #172a24;
    --muted: #53665e;
    --paper: #f5f8f6;
    --white: #fff;
    --line: #dce6e0;
    --mint: #e4f3eb;
    --accent: #17644a;
    --deep: #132e25;
    --soft-blue: #e7f0fa;
    --soft-purple: #f0eafa;
    --soft-amber: #faeed8;
    --radius: 14px;
    font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0; color: var(--ink);
    background: linear-gradient(135deg, rgba(14, 35, 27, .52), rgba(235, 242, 236, .60)),
        url('/crm-background.jpg') center / cover fixed, var(--paper);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: progress; opacity: .66; }
p, h1, h2, h3 { margin-top: 0; }
:focus-visible { outline: 3px solid #51a181; outline-offset: 3px; }
.boot { display: grid; min-height: 100vh; place-items: center; }
.muted { color: var(--muted); }
.block { display: block; }
.stack { display: grid; gap: 18px; }
.section-tools { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 0 15px 12px; }
.section-tools .filters { padding: 0; }
.literal-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-preview { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.55; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; max-height: 48vh; overflow: auto; margin: 0; }
.month-tools { display: flex; gap: 10px; align-items: center; padding: 0 15px 14px; }
.month-tools strong { min-width: 125px; text-align: center; }
.calendar-overflow { overflow-x: auto; }
.calendar-grid { display: grid; grid-template-columns: repeat(7,minmax(80px,1fr)); min-width: 560px; border-top: 1px solid var(--line); }
.calendar-weekday { color: var(--muted); font-size: .83rem; text-align: center; padding: 7px; background: var(--paper); }
.calendar-cell { min-height: 86px; min-width: 0; border-top: 1px solid var(--line); border-right: 1px solid var(--line); padding: 4px; }
.calendar-cell.outside { background: var(--paper); }
.calendar-cell.current { background: #eaf8ee; }
.calendar-cell .button { min-height: 30px; }
.calendar-event { display: block; font-size: .78rem; color: var(--accent); background: var(--mint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 5px; padding: 2px 4px; margin: 2px 0; }
.button, .icon-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 38px; border: 1px solid transparent; border-radius: 8px; padding: 6px 12px;
    font-size: .875rem; font-weight: 650; line-height: 1.2; white-space: nowrap;
}
.button.primary { background: var(--accent); color: var(--white); border-color: var(--accent); }
.button.primary:hover { background: #0f523b; }
.button.secondary, .icon-button { background: var(--white); border-color: #cdded4; color: #245742; }
.button.secondary:hover, .icon-button:hover { background: #eff7f2; }
.button.plain { background: transparent; color: var(--accent); }
.button.plain:hover, .button.tint { background: var(--mint); color: #14513a; }
.icon-button { width: 38px; padding: 0; font-size: 1.3rem; }
.quiet-link, .back-link { color: var(--accent); font-size: .875rem; font-weight: 650; }
.quiet-link:hover, .back-link:hover { text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand strong { display: block; font-size: .93rem; letter-spacing: .065em; color: white; }
.brand small { display: block; color: #bad1c5; font-size: .8rem; }
.brand-mark {
    display: grid; align-items: end; grid-template-columns: repeat(3, 4px); justify-content: center; gap: 3px;
    width: 39px; height: 39px; padding-bottom: 11px; background: #92dfb1; border-radius: 11px; flex-shrink: 0;
}
.brand-mark i { display: block; width: 4px; border-radius: 1px; background: #184734; }
.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 14px; }
.brand-mark i:nth-child(3) { height: 18px; }
.workspace { min-height: 100vh; display: grid; grid-template-columns: 216px minmax(0, 1fr); }
.sidebar {
    position: sticky; top: 0; height: 100vh; background: var(--deep); color: #e2f2e9;
    padding: 25px 15px 18px; display: flex; flex-direction: column; gap: 16px;
}
.sidebar .brand { padding: 0 6px; }
.sidebar nav { display: grid; gap: 3px; margin-top: 17px; overflow-y: auto; min-height: 0; }
.sidebar nav a { display: flex; align-items: center; gap: 9px; font-size: .91rem; font-weight: 550; padding: 8px 8px; border-radius: 8px; }
.sidebar nav a:hover { background: #214437; }
.sidebar nav a.selected { background: #2c5141; color: #fff; font-weight: 700; }
.nav-count { margin-left: auto; padding: 0 7px; border-radius: 7px; background: #c0ead2; color: #174531; font-size: .78rem; }
.icon { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 7px; font-size: 1.05rem; flex-shrink: 0; }
.sidebar .icon { color: #b2ddc6; }
.sidebar-bottom { margin-top: auto; }
.local-label { margin: 0 7px 14px; font-size: .78rem; color: #d0e4d7; display: flex; align-items: center; gap: 7px; }
.local-label i { width: 7px; height: 7px; border-radius: 50%; background: #9adeb6; }
.profile { display: flex; align-items: center; gap: 10px; padding: 11px 7px 0; border-top: 1px solid #315144; }
.avatar { display: inline-grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; background: #d9eee3; color: #285c45; font-weight: 700; flex: 0 0 auto; }
.avatar.small { width: 33px; height: 33px; font-size: .8rem; }
.profile strong, .profile small { display: block; }
.profile strong { font-size: .86rem; }
.profile small { color: #bbd3c6; font-size: .78rem; }
.workspace-body { min-width: 0; background: rgba(244, 248, 245, .72); }
.topbar {
    min-height: 65px; background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 29px;
}
.breadcrumb { color: var(--muted); font-size: .87rem; font-weight: 650; }
.breadcrumb b { color: #90a299; margin: 0 6px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.search label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 0 10px; border-radius: 8px; background: #f8faf9; }
.search span { font-size: 1.22rem; color: var(--accent); }
.search input { background: transparent; border: 0; width: 165px; min-height: 35px; font-size: .875rem; color: var(--ink); }
.search input:focus { outline: none; }
.search label:focus-within { outline: 2px solid #51a181; outline-offset: 2px; }
.page { width: 100%; max-width: 1560px; margin: auto; padding: 27px 29px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.65rem, 3vw, 2.1rem); line-height: 1.16; letter-spacing: -.035em; margin: 0 0 6px; }
.page-head p { color: var(--muted); margin: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 22px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; padding: 15px; }
.stat-label { display: flex; justify-content: space-between; align-items: center; gap: 7px; font-size: .875rem; font-weight: 650; }
.stat-label .icon { background: var(--mint); color: #255c46; }
.stat-label .icon.blue { background: var(--soft-blue); color: #275e87; }
.stat-label .icon.amber { background: var(--soft-amber); color: #7d5015; }
.stat-label .icon.purple { background: var(--soft-purple); color: #603e85; }
.stat > strong { display: block; font-size: clamp(1.55rem, 2.7vw, 2rem); line-height: 1.15; margin: 11px 0 4px; letter-spacing: -.03em; }
.stat small { display: block; color: var(--muted); font-size: .81rem; }
.stats.financial { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard { display: grid; grid-template-columns: minmax(0, 2.05fr) minmax(260px, 1fr); gap: 15px; align-items: start; }
.case-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 15px; align-items: start; }
.panel { background: rgba(255, 255, 255, .94); border: 1px solid rgba(220, 230, 224, .9); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; min-height: 60px; padding: 10px 15px; }
.panel-head h2 { margin: 0; font-size: 1.07rem; letter-spacing: -.012em; }
.panel-text { margin: 0; padding: 0 16px 16px; color: var(--muted); font-size: .94rem; }
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th, td { padding: 11px 12px; vertical-align: middle; }
th { white-space: nowrap; background: #f3f7f4; color: #4b6558; font-weight: 650; border-block: 1px solid #e5ede8; }
td { border-top: 1px solid #e9eee9; }
tr:last-child td { padding-bottom: 14px; }
tbody tr:hover { background: #f8fbf9; }
.row-link { display: flex; align-items: center; gap: 8px; min-width: 125px; }
.row-link:hover strong { color: var(--accent); text-decoration: underline; }
.row-link strong, .row-link small, .task-cell strong, .task-cell small { display: block; }
.row-link small, .task-cell small, td small { color: var(--muted); font-size: .77rem; margin-top: 2px; }
.row-link strong, .task-cell strong { font-weight: 650; }
.task-cell { min-width: 110px; display: block; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.row-actions .button { min-height: 33px; }
.pill {
    display: inline-block; font-size: .78rem; line-height: 1.25; font-weight: 650; padding: 5px 8px;
    border-radius: 7px; background: #edf2ef; color: #405749;
}
.pill.green { background: var(--mint); color: #19563d; }
.pill.blue { background: var(--soft-blue); color: #255882; }
.pill.purple { background: var(--soft-purple); color: #5b427e; }
.pill.amber { background: var(--soft-amber); color: #735220; }
.event-list a { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-top: 1px solid #e9eee9; }
.event-list a:hover { background: #f8fbf9; }
.event-list a:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.event-list strong, .event-list small { display: block; }
.event-list strong { font-size: .86rem; }
.event-list small { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.event-note { margin: 5px 0 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.event-list .pill { margin-left: auto; }
.event-date { background: var(--mint); color: #1e5e44; border-radius: 8px; min-width: 48px; padding: 6px; font-size: .79rem; font-weight: 750; text-align: center; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 11px 14px; }
.filter-count { margin-left: auto; font-size: .85rem; }
.view-switch { display: inline-flex; gap: 2px; align-items: center; background: var(--white); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.view-switch .button { min-height: 33px; }
.board-filters { margin-bottom: 13px; }
.board-filters .filters { padding-block: 7px; }
.board-groups { border-top: 1px solid var(--line); }
.board-scroll { overflow: auto; overscroll-behavior-inline: contain; padding: 3px 2px 12px; min-width: 0; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 245px; gap: 12px; min-height: 365px; width: max-content; }
.board-column { padding: 10px; background: #eaf1ed; border: 1px solid #dce8e1; border-radius: 12px; min-height: 100%; }
.board-column header { display: flex; gap: 7px; align-items: flex-start; justify-content: space-between; padding: 2px 1px 8px; min-height: 50px; }
.board-column h2 { font-size: .93rem; line-height: 1.25; margin: 0; }
.board-column header > span { color: #3f5e4e; background: #d6e7dd; padding: 0 6px; border-radius: 6px; font-size: .8rem; }
.board-column.is-drop-target { outline: 2px dashed #218464; outline-offset: -4px; background: #dfefe6; }
.column-empty { margin: 8px 3px; color: var(--muted); font-size: .84rem; }
.board-card {
    display: grid; gap: 4px; background: var(--white); border: 1px solid #d8e4dd; border-radius: 9px;
    padding: 9px; margin-top: 7px; box-shadow: 0 2px 3px #173d2720; cursor: grab;
}
.board-card.dragging { opacity: .42; cursor: grabbing; }
.card-id { color: var(--muted); font-size: .78rem; font-weight: 650; }
.card-title { width: fit-content; background: transparent; color: var(--ink); border: 0; padding: 0; text-align: left; line-height: 1.35; font-weight: 700; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.board-card .muted { font-size: .82rem; }
.card-source { overflow-wrap: anywhere; }
.card-facts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.card-next { margin: 5px 0 2px; color: #36544a; font-size: .83rem; }
.card-actions { display: flex; justify-content: flex-end; margin-top: 2px; }
.card-actions .button { min-height: 30px; }
.checkpoints { padding: 0 14px 12px; }
.checkpoints h3 { margin: 0 0 6px; color: var(--accent); font-size: .97rem; }
.checkpoint {
    display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 5px; text-align: left;
    font-size: .91rem; background: transparent; color: var(--ink); border: 0; border-radius: 6px;
}
.checkpoint:hover { background: var(--mint); }
.checkpoint span { display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid #8eb29e; border-radius: 5px; flex: 0 0 auto; }
.checkpoint[aria-pressed="true"] span { background: var(--accent); color: var(--white); }
.all-steps { border-top: 1px solid var(--line); }
.all-steps summary { cursor: pointer; margin: 11px 14px; font-size: .9rem; color: var(--accent); font-weight: 650; }
.steps small { margin-left: auto; font-size: .75rem; color: var(--muted); text-align: right; }
.empty { padding: 25px 16px; color: var(--muted); }
.empty p { margin: 4px 0 0; }
.tabs { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin: 0 0 17px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 10px; border-bottom: 2px solid transparent; color: var(--muted); font-size: .89rem; font-weight: 650; }
.tabs a:hover, .tabs a.selected { color: var(--accent); }
.tabs a.selected { border-color: var(--accent); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; padding: 0 16px 16px; }
.facts div { padding: 8px 10px; border-radius: 8px; background: #f4f8f5; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 2px 0 0; font-weight: 650; overflow-wrap: anywhere; }
.case-note { margin: 0 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.steps { margin: 0; padding: 0 16px 16px; list-style: none; }
.steps li { display: flex; gap: 10px; align-items: center; min-height: 35px; color: var(--muted); font-size: .9rem; }
.steps i { display: block; width: 10px; height: 10px; border: 2px solid #b6c9be; border-radius: 50%; }
.steps .passed i { border-color: #7db396; background: #7db396; }
.steps .current { color: #15523a; font-weight: 750; }
.steps .current i { background: var(--accent); border-color: var(--accent); outline: 3px solid #d2ecd9; }
.partner-card { display: flex; align-items: center; gap: 11px; padding: 4px 16px 16px; }
.partner-card small, .record small { display: block; color: var(--muted); font-size: .83rem; }
.partner-card .button { margin-left: auto; }
.record-list { display: grid; gap: 9px; padding: 0 14px 14px; }
.record { padding: 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: 1fr auto; gap: 7px; align-items: start; }
.record p { grid-column: 1 / -1; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.handoff-files { margin: 3px 0 0; padding-left: 20px; grid-column: 1 / -1; }
#template-items { margin: 0; padding-left: 22px; color: var(--muted); font-size: .91rem; }
.import-report { padding: 13px; }
.record .button { justify-self: start; }
.record .row-actions { grid-column: 1 / -1; }
.record-wide { grid-column: 1 / -1; }
.record p.reply { background: #edf6f0; padding: 8px; border-radius: 7px; }
dialog { color: var(--ink); width: min(94vw, 550px); max-height: 90vh; border: 1px solid var(--line); border-radius: 14px; padding: 0; box-shadow: 0 22px 70px #142f2840; }
dialog::backdrop { background: #102b23a0; }
.dialog-head { padding: 12px 17px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.dialog-head h2 { margin: 0; font-size: 1.18rem; }
dialog form { padding: 15px 17px; }
.form-fields { display: grid; gap: 12px; }
.form-fields > p { margin: 0; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.inline-form { display: flex; align-items: end; gap: 8px; }
.field { display: grid; align-content: start; min-width: 0; gap: 4px; font-size: .87rem; font-weight: 650; }
.field input, .field select, .field textarea {
    display: block; width: 100%; background-color: #fff; color: var(--ink); font-weight: 400;
    border: 1px solid #cbdad1; border-radius: 8px; padding: 7px 10px; min-height: 39px;
}
.field textarea { resize: vertical; }
.field select {
    appearance: none; padding-right: 30px;
    background-image: linear-gradient(45deg, transparent 50%, #345c4b 50%), linear-gradient(135deg, #345c4b 50%, transparent 50%);
    background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px; background-repeat: no-repeat;
}
.form-hint { color: var(--muted); font-size: .87rem; }
.form-error { color: #94383a; font-size: .89rem; margin: 8px 0 0; }
.form-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; }
dialog footer { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }
.statement-row { padding: 12px; overflow-wrap: anywhere; }
.statement-row p { margin: 6px 0; }
.questionnaire { width:min(980px,94vw); margin:30px auto; display:grid; gap:18px; }
.questionnaire-head { display:flex; flex-wrap:wrap; gap:12px; justify-content:space-between; color:var(--ink); }
.questionnaire .panel { padding:clamp(18px,4vw,34px); }
.questionnaire h1 { margin-top:0; }
.questionnaire h2 { margin:18px 0 0; font-size:1.05rem; }
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 3; display: none; padding: 10px 15px; border-radius: 8px; color: white; background: #164c37; }
#toast.visible { display: block; }
#toast.error { background: #94383a; }
.login { min-height: 100vh; display: grid; grid-template-columns: .95fr 1fr; }
.login-cover { padding: 38px clamp(22px, 5vw, 75px); display: flex; flex-direction: column; justify-content: space-between; gap: 38px; background: var(--deep); color: white; }
.login-cover h1 { font-size: clamp(2rem, 5vw, 4.8rem); line-height: 1.08; letter-spacing: -.05em; margin: 0 0 13px; }
.login-cover p { color: #d2e7dc; }
.login-footer { font-size: .87rem; color: #bad1c5; }
.login-panel { display: grid; place-items: center; padding: 24px; }
.login-content { max-width: 420px; width: 100%; }
.login-content h2 { margin: 0 0 14px; font-size: 1.6rem; }
.login-content h3 { margin: 25px 0 10px; font-size: 1rem; }
.login-content form .button { margin-top: 12px; width: 100%; }
.demo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-list button { text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--ink); background: white; }
.demo-list button:hover { border-color: #519175; background: var(--mint); }
.demo-list span { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }
@media (max-width: 1160px) {
    .sidebar { padding-inline: 12px; }
    .workspace { grid-template-columns: 195px minmax(0, 1fr); }
}
@media (max-width: 1030px) {
    .dashboard { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; padding: 12px; gap: 10px; }
    .sidebar nav { display: flex; flex-wrap: wrap; margin-top: 0; }
    .sidebar nav a { padding: 4px 7px; }
    .sidebar-bottom { display: none; }
    .topbar, .page { padding-inline: 14px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 545px) {
    .login, .case-grid, .field-pair { grid-template-columns: 1fr; }
    .login-cover { gap: 16px; padding: 16px; }
    .login-cover h1 { font-size: 1.8rem; }
    .login-footer { display: none; }
    .login-cover p:last-child { margin: 0; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .topbar { justify-content: flex-end; }
    .breadcrumb { display: none; }
    .top-actions, .search { flex: 1; }
    .search input { width: 100%; }
    .stat, .panel-head { padding-inline: 11px; }
    .facts { padding-inline: 11px; }
    .workspace:is([data-role="partner"],[data-role="client"]) .table-wrap { overflow: visible; }
    .workspace:is([data-role="partner"],[data-role="client"]) table,
    .workspace:is([data-role="partner"],[data-role="client"]) tbody { display: block; }
    .workspace:is([data-role="partner"],[data-role="client"]) thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
    }
    .workspace:is([data-role="partner"],[data-role="client"]) tr { display: block; border-top: 1px solid var(--line); padding: 6px 10px; }
    .workspace:is([data-role="partner"],[data-role="client"]) td {
        display: grid; grid-template-columns: minmax(88px, .43fr) minmax(0, 1fr); gap: 6px;
        border: 0; padding: 5px 0; overflow-wrap: anywhere;
    }
    .workspace:is([data-role="partner"],[data-role="client"]) td::before { content: attr(data-label); color: var(--muted); font-size: .79rem; }
    .workspace:is([data-role="partner"],[data-role="client"]) td strong,
    .workspace:is([data-role="partner"],[data-role="client"]) td small,
    .workspace:is([data-role="partner"],[data-role="client"]) td p { grid-column: 2; }
    .workspace:is([data-role="partner"],[data-role="client"]) .row-actions .button { min-height: 42px; }
}
