:root {
    --ink: #25302e;
    --muted: #7d8580;
    --paper: #f7f7f4;
    --white: #fff;
    --line: #e9ebe5;
    --green: #526b59;
    --green-dark: #3e5545;
    --green-pale: #edf2eb;
    --orange: #b8784e;
    --shadow: 0 8px 26px rgba(34, 48, 41, .045);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: 'Segoe UI', Arial, sans-serif; font-size: 16px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; padding: 31px 18px 18px; background: #fff; border-right: 1px solid var(--line); z-index: 4; }
.brand { display: inline-block; padding: 0 13px; font: 700 33px Georgia, serif; letter-spacing: -1.4px; color: #293731; }
.brand span { color: var(--orange); }
.workspace-label, .eyebrow { color: #929991; font-size: 11px; font-weight: 700; letter-spacing: 1.35px; }
.workspace-label { margin: 45px 13px 15px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { height: 43px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-radius: 7px; color: #69716b; font-size: 15px; transition: .15s ease; }
.sidebar nav a:hover { background: #f8f8f5; color: var(--ink); }
.sidebar nav a.active { color: var(--green-dark); background: var(--green-pale); font-weight: 600; }
.nav-dot { width: 7px; height: 7px; border: 1.5px solid #aeb5ad; border-radius: 50%; }
.active .nav-dot { border-color: var(--green); background: var(--green); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 16px 3px 4px; border-top: 1px solid var(--line); }
.avatar { width: 35px; height: 35px; flex: 0 0 35px; display: grid; place-items: center; border-radius: 50%; color: #526b59; background: #e9eee6; font-weight: 700; }
.user-meta, .row-content { min-width: 0; display: grid; gap: 4px; }
.user-meta strong { font-size: 14px; font-weight: 600; }
.user-meta small, .row-content small { color: var(--muted); font-size: 13px; }
.logout-form { margin-left: auto; }
.icon-button { border: 0; background: transparent; color: #89918b; padding: 7px; font-size: 19px; }
.main { max-width: 1600px; margin-left: 248px; padding: 38px 48px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 27px; }
.topbar h1 { margin: 5px 0 0; font: 600 32px Georgia, serif; letter-spacing: -.5px; }
.topbar-date { padding-bottom: 4px; color: #828a83; font-size: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card, .panel { background: var(--white); border: 1px solid #eceee9; border-radius: 9px; box-shadow: var(--shadow); }
.metric-card { min-height: 135px; padding: 20px 20px 17px; }
.metric-top { display: flex; justify-content: space-between; color: #737c75; font-size: 14px; }
.metric-mark { color: #b3bbaa; font-size: 17px; }
.metric-card > strong { display: block; margin-top: 15px; font: 600 29px Georgia, serif; letter-spacing: -.5px; }
.metric-card > small { display: block; margin-top: 5px; color: #969d96; font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; margin-top: 19px; }
.panel { min-width: 0; padding: 23px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 20px; }
.panel-heading h2 { margin: 5px 0 0; font: 600 21px Georgia, serif; letter-spacing: -.2px; }
.text-link, .table-link { color: var(--green); font-size: 13px; font-weight: 600; white-space: nowrap; }
.text-link:hover, .table-link:hover { color: var(--orange); }
.list-row { display: flex; align-items: center; gap: 12px; min-height: 61px; border-top: 1px solid #f0f1ee; }
.row-icon { width: 31px; height: 31px; flex: 0 0 31px; display: grid; place-items: center; border-radius: 50%; font-size: 15px; }
.row-icon.warm { background: #f7eee7; color: var(--orange); }
.row-icon.cool { background: var(--green-pale); color: var(--green); }
.row-content { flex: 1; }
.row-content strong { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.date-pill { padding: 5px 8px; border-radius: 4px; background: #f3f5f0; color: #687365; font-size: 12px; white-space: nowrap; }
.priority, .status, .role-badge { display: inline-block; padding: 5px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.priority.low { background: #f0f2ed; color: #72796c; }
.priority.normal { background: #f4f0e5; color: #887b54; }
.priority.high { background: #faece7; color: #b45f47; }
.status.draft, .status.open, .status.unpaid { background: #f3f0e8; color: #89774c; }
.status.sent, .status.in_progress, .status.partial { background: #eaf1f5; color: #547a8e; }
.status.accepted, .status.paid, .status.done { background: #eaf2e9; color: #58765b; }
.status.rejected { background: #f7eae8; color: #a45b50; }
.content-grid { display: grid; grid-template-columns: minmax(275px, .75fr) minmax(0, 1.65fr); align-items: start; gap: 18px; }
.form-panel { position: sticky; top: 20px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label, .payment-form label { display: grid; gap: 7px; color: #5e6860; font-size: 13px; font-weight: 600; }
.stack-form label small { color: #929991; font-size: 12px; font-weight: 400; line-height: 1.5; }
input, select, textarea { width: 100%; min-width: 0; padding: 10px 11px; border: 1px solid #e4e7e1; border-radius: 5px; outline: none; background: #fff; color: var(--ink); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #9baa9b; box-shadow: 0 0 0 3px rgba(82, 107, 89, .08); }
textarea { resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: #afb5ae; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; padding: 0 15px; border: 0; border-radius: 5px; font-size: 14px; font-weight: 600; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button span { font-size: 17px; }
.full-button { width: 100%; margin-top: 3px; }
.cancel-link { color: var(--muted); font-size: 13px; text-align: center; }
.count { display: inline-grid; min-width: 21px; height: 21px; place-items: center; margin-left: 5px; padding: 0 5px; border-radius: 11px; background: #f0f2ed; color: #7d867b; font: 500 12px 'Segoe UI', Arial, sans-serif; vertical-align: 2px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0 12px 11px; color: #9aa198; font-size: 11px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid #eff0ed; color: #616a63; font-size: 13px; vertical-align: middle; }
td strong { color: #37433b; font-weight: 600; }
td small { display: block; max-width: 155px; margin-top: 4px; overflow: hidden; color: #999f99; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.action-cell { display: flex; align-items: center; gap: 10px; }
.inline-form { display: inline-flex; margin: 0; }
.text-button { padding: 4px 0; border: 0; background: transparent; color: var(--green); font-size: 13px; font-weight: 600; }
.compact-select { width: auto; max-width: 105px; padding: 6px 21px 6px 7px; border-color: #ebede8; color: #687169; font-size: 12px; }
.empty-state { padding: 27px 14px; border: 1px dashed #e6e9e3; border-radius: 5px; color: #949b94; font-size: 14px; line-height: 1.7; text-align: center; }
.alert { margin-bottom: 18px; padding: 12px 15px; border: 1px solid transparent; border-radius: 6px; font-size: 14px; }
.alert.success { border-color: #dce8da; background: #edf4eb; color: #4d6d50; }
.alert.error { border-color: #f0d9d4; background: #fbefec; color: #9c564a; }
.line-items-heading { display: flex; justify-content: space-between; align-items: center; color: #5e6860; font-size: 13px; }
#line-items { display: grid; gap: 7px; }
.item-row { display: grid; grid-template-columns: minmax(90px, 1fr) 65px 90px 22px; gap: 6px; }
.item-row input { padding: 8px; font-size: 12px; }
.remove-line { border: 0; background: transparent; color: #a2a8a0; font-size: 19px; }
.payment-row td { padding-top: 4px; background: #fafbf8; }
.payment-form { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr 1fr auto; align-items: end; gap: 9px; }
.payment-form label { font-size: 12px; }
.payment-form .button { min-height: 35px; font-size: 12px; }
.timeline { padding-left: 9px; }
.timeline-item { position: relative; margin-left: 8px; padding: 0 0 22px 18px; border-left: 1px solid #e7eae4; }
.timeline-item:last-child { padding-bottom: 2px; border-left-color: transparent; }
.timeline-marker { position: absolute; top: 2px; left: -5px; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: #829580; box-shadow: 0 0 0 1px #829580; }
.timeline-top { display: flex; justify-content: space-between; gap: 12px; }
.timeline-top strong { font-size: 14px; }
.timeline-top span, .timeline-meta { color: #909890; font-size: 12px; }
.timeline-meta { margin-top: 5px; }
.timeline-item p { margin: 10px 0; color: #687169; font-size: 13px; line-height: 1.7; }
.outcome-note { margin: 9px 0; color: #6a736b; font-size: 12px; line-height: 1.6; }
.outcome-note strong { margin-right: 4px; color: #536755; }
.task-list { display: grid; gap: 10px; }
.task-card { padding: 15px; border: 1px solid #eceee9; border-radius: 6px; }
.task-card-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.task-card h3 { margin: 7px 0 0; font-size: 15px; font-weight: 600; }
.task-card p { margin: 10px 0; color: #788078; font-size: 13px; line-height: 1.65; }
.task-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid #f0f1ee; color: #929991; font-size: 12px; }
.task-footer strong { color: #667067; font-weight: 600; }
.team-grid { grid-template-columns: minmax(275px, .8fr) minmax(0, 1.4fr); }
.team-list { display: grid; }
.team-member { display: flex; align-items: center; gap: 12px; min-height: 65px; border-top: 1px solid #f0f1ee; }
.role-badge { background: #f0f2ed; color: #697466; }
.team-member .role-badge { margin-left: auto; }
.doc-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.document-brand { display: flex; justify-content: space-between; gap: 30px; padding: 8px 0 25px; border-bottom: 1px solid var(--line); }
.document-brand h2 { margin: 8px 0 5px; font: 600 26px Georgia, serif; }
.document-brand p { margin: 4px 0; color: #788078; font-size: 13px; line-height: 1.5; }
.document-number { display: grid; align-content: start; gap: 6px; min-width: 150px; text-align: right; }
.document-number span { color: #929991; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; }
.document-number strong { color: var(--green-dark); font: 600 20px Georgia, serif; }
.document-number small { color: #858d85; font-size: 12px; }
.document-parties { display: flex; justify-content: space-between; gap: 25px; padding: 22px 0 27px; }
.document-parties > div { display: grid; align-content: start; justify-items: start; gap: 6px; }
.document-parties strong { margin-top: 3px; font-size: 15px; }
.document-parties span:not(.eyebrow):not(.status) { color: #768078; font-size: 13px; line-height: 1.5; }
.doc-validity { min-width: 140px; }
.document-table th, .document-table td { padding: 13px 12px; }
.document-table th:not(:first-child), .document-table td:not(:first-child) { text-align: right; }
.document-total { width: min(330px, 100%); display: grid; gap: 11px; margin: 18px 0 0 auto; }
.document-total > div { display: flex; justify-content: space-between; gap: 15px; color: #788078; font-size: 13px; }
.document-total strong { color: #455148; font-weight: 600; }
.document-total .grand-total { padding-top: 11px; border-top: 1px solid var(--line); color: var(--ink); font-size: 15px; font-weight: 700; }
.document-total .grand-total strong { color: var(--green-dark); font: 600 21px Georgia, serif; }
.document-notes { margin-top: 27px; padding: 15px 0; border-top: 1px solid var(--line); }
.document-notes p { color: #727b73; font-size: 13px; line-height: 1.7; }
.document-signoff { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--line); color: #788078; font: 500 16px Georgia, serif; }
.report-filter { margin-bottom: 18px; }
.report-filter-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px; margin-bottom: 18px; }
.report-filter-form label { display: grid; gap: 7px; color: #5e6860; font-size: 13px; font-weight: 600; }
.report-filter-form .button { min-height: 39px; grid-column: span 2; }
.report-metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 18px; }
.report-breakdowns { margin-top: 0; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(ellipse at 50% 25%, #f7f8f3 0%, #eff2ec 70%, #e8eee8 100%); }
.auth-shell > .alert { position: absolute; top: 20px; left: 50%; width: min(440px, calc(100% - 40px)); transform: translateX(-50%); }
.auth-card { width: min(420px, 100%); padding: 38px; border: 1px solid #eaede7; border-radius: 10px; background: white; box-shadow: 0 15px 55px rgba(45, 59, 49, .08); }
.auth-brand { padding: 0; margin-bottom: 38px; }
.auth-card h1 { margin: 8px 0 7px; font: 600 31px Georgia, serif; }
.muted { margin: 0 0 24px; color: #858d85; font-size: 14px; line-height: 1.7; }
.auth-card .stack-form { margin-top: 23px; }
.setup-page { min-height: 100vh; }

@media (max-width: 1150px) {
    .main { padding-right: 28px; padding-left: 28px; }
    .content-grid { grid-template-columns: minmax(250px, .7fr) minmax(0, 1.4fr); }
    .payment-form { grid-template-columns: repeat(2, 1fr); }
    .payment-form .button { grid-column: span 2; }
}
@media (max-width: 850px) {
    .sidebar { width: 72px; padding: 22px 10px 14px; align-items: center; }
    .brand { padding: 0; font-size: 27px; }
    .workspace-label, .sidebar nav a:not(.active) { font-size: 0; }
    .workspace-label { width: 30px; height: 1px; margin: 30px 0 14px; overflow: hidden; background: var(--line); }
    .sidebar nav a { width: 46px; justify-content: center; padding: 0; font-size: 0; }
    .nav-dot { width: 9px; height: 9px; }
    .sidebar-user { flex-direction: column; padding-top: 13px; }
    .user-meta, .logout-form { display: none; }
    .main { margin-left: 72px; padding: 28px 22px 45px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid, .team-grid { grid-template-columns: 1fr; }
    .form-panel { position: static; }
}
@media (max-width: 580px) {
    .sidebar { width: 57px; padding-right: 6px; padding-left: 6px; }
    .sidebar nav a { width: 40px; }
    .main { margin-left: 57px; padding: 22px 13px 35px; }
    .topbar { align-items: start; }
    .topbar h1 { font-size: 26px; }
    .topbar-date { max-width: 105px; padding-top: 19px; font-size: 12px; text-align: right; }
    .metric-grid { gap: 9px; }
    .metric-card { min-height: 112px; padding: 14px; }
    .metric-card > strong { font-size: 24px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .panel { padding: 17px 14px; }
    .panel-heading h2 { font-size: 19px; }
    .form-pair { grid-template-columns: 1fr; }
    .item-row { grid-template-columns: minmax(75px, 1fr) 53px 77px 18px; gap: 4px; }
    .item-row input { padding: 7px 5px; font-size: 11px; }
    .payment-form { grid-template-columns: 1fr 1fr; }
    .task-footer { align-items: start; }
    .auth-card { padding: 29px 23px; }
    .report-filter-form { grid-template-columns: 1fr; }
    .report-filter-form .button { grid-column: span 1; }
}
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .no-print, .alert { display: none !important; }
    .main { max-width: none; margin: 0; padding: 0; }
    .panel { border: 0; box-shadow: none; }
    .document-preview { display: block !important; padding: 0; }
    .document-preview .panel-heading { margin-bottom: 30px; }
    .document-preview table { page-break-inside: avoid; }
}
