:root {
  --blue: #1d3df2;
  --blue-dark: #1435b9;
  --blue-soft: #eef2ff;
  --yellow: #ffc900;
  --yellow-deep: #f0b900;
  --ink: #14213d;
  --muted: #66758f;
  --line: #dce4f2;
  --line-strong: #c9d4e8;
  --canvas: #f4f7fe;
  --panel: #ffffff;
  --danger: #c84242;
  --success: #0c8669;
  --shadow: 0 14px 38px rgba(22, 52, 113, .09);
  --radius: 20px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: not-allowed; }
img { max-width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar { min-height: 100vh; background: #fff; border-right: 1px solid var(--line); padding: 22px 16px 18px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40; }
.sidebar-brand { margin: 3px 2px 26px; min-height: 74px; background: var(--blue); color: #fff; border-radius: 0 24px 24px 0; padding: 9px 15px 9px 8px; display: flex; align-items: center; gap: 11px; overflow: hidden; }
.sidebar-brand .brand-logo { height: 56px; width: 56px; object-fit: contain; background: #fff; border-radius: 0 12px 12px 0; padding: 4px; flex: 0 0 56px; }
.sidebar-brand strong { font-size: 14px; display: block; line-height: 1.15; letter-spacing: .015em; }
.sidebar-brand span { display: block; font-size: 10px; color: rgba(255,255,255,.76); margin-top: 4px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { min-height: 45px; border-radius: 12px; padding: 0 12px; display: flex; align-items: center; gap: 11px; font-weight: 650; color: #52627d; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-item:hover { color: var(--blue); background: var(--blue-soft); transform: translateX(2px); }
.nav-item.is-active { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(29,61,242,.22); }
.nav-icon { width: 18px; text-align: center; font-size: 17px; line-height: 1; }
.nav-divider { color: #93a0b7; font-size: 11px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; margin: 21px 12px 7px; }
.sidebar-foot { margin-top: auto; padding: 13px 12px 3px; color: var(--muted); font-size: 12px; }
.online-dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; background: var(--success); margin-right: 6px; box-shadow: 0 0 0 3px rgba(12,134,105,.12); }
.app-main { min-width: 0; }
.topbar { min-height: 91px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 34px; border-radius: 0 0 0 28px; box-shadow: 0 7px 18px rgba(29,61,242,.12); }
.topbar-title .eyebrow { opacity: .72; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; display: block; margin-bottom: 1px; }
.topbar-title h1 { margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.user-menu { display: flex; align-items: center; gap: 9px; }
.user-avatar { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: #fff; color: var(--blue); font-weight: 800; }
.user-copy { min-width: 100px; line-height: 1.1; }
.user-copy strong { display: block; font-size: 12px; }
.user-copy span { font-size: 10px; opacity: .75; }
.logout-form { margin: 0; }
.text-button { padding: 5px 2px; border: 0; color: rgba(255,255,255,.92); background: transparent; font-weight: 700; font-size: 12px; }
.text-button:hover { color: var(--yellow); }
.page-content { max-width: 1480px; padding: 30px 34px 48px; margin: 0 auto; }

.page-intro { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin: 0 0 22px; }
.page-intro h2 { color: var(--blue-dark); margin: 0 0 5px; font-size: clamp(24px, 2.4vw, 33px); letter-spacing: -.025em; line-height: 1.1; }
.page-intro p { color: var(--muted); margin: 0; max-width: 760px; }
.button-group { display: flex; gap: 9px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid transparent; border-radius: 12px; padding: 0 16px; font-size: 14px; font-weight: 760; white-space: nowrap; transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(29,61,242,.19); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-yellow { color: #182250; background: var(--yellow); box-shadow: 0 7px 16px rgba(255,201,0,.22); }
.btn-yellow:hover { background: var(--yellow-deep); }
.btn-ghost { color: var(--blue-dark); background: #fff; border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--blue); background: var(--blue-soft); }
.btn-small { min-height: 33px; padding: 0 11px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }
.text-link { color: var(--blue); font-weight: 760; font-size: 13px; }
.text-link:hover, .table-link:hover { text-decoration: underline; }
.back-link { display: inline-block; color: var(--blue); font-weight: 700; font-size: 13px; margin-bottom: 8px; }

.panel { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-heading h3 { margin: 0 0 3px; color: var(--blue-dark); font-size: 18px; letter-spacing: -.01em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.table-panel { padding: 13px 18px 18px; }
.form-panel { padding: 27px; }
.compact-form { margin-top: 5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card { min-height: 140px; background: #fff; border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 7px 19px rgba(24,48,103,.06); padding: 18px 18px 15px; display: flex; flex-direction: column; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 650; }
.stat-card strong { color: var(--blue-dark); font-size: clamp(22px,2.2vw,29px); margin: 5px 0 8px; line-height: 1.05; letter-spacing: -.025em; }
.stat-card i { height: 5px; display: block; width: 70%; background: var(--yellow); border-radius: 10px; margin-top: auto; }
.stat-card small { color: #8693a8; font-size: 11px; margin-top: 8px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.22fr) minmax(320px,.88fr); gap: 20px; margin-bottom: 20px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-card { min-height: 57px; padding: 13px 14px; background: var(--blue-soft); color: var(--blue-dark); border-radius: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; text-align: center; transition: transform .18s ease, box-shadow .18s ease; }
.quick-card:hover { transform: translateY(-2px); box-shadow: 0 9px 16px rgba(33,66,149,.1); }
.quick-card.quick-primary { color: #fff; background: var(--blue); }
.quick-card.quick-yellow { color: #182250; background: var(--yellow); }
.simple-list { display: grid; gap: 8px; }
.simple-row { min-height: 55px; padding: 9px 12px; border-radius: 11px; background: #f8faff; border: 1px solid #edf1fa; display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 14px; align-items: center; transition: border-color .16s ease, transform .16s ease; }
.simple-row:hover { border-color: #c7d5f2; transform: translateX(2px); }
.simple-row.no-link:hover { transform: none; }
.simple-row strong { font-size: 13px; display: block; }
.simple-row span:not(.status-pill):not(.type-mini) { color: var(--muted); font-size: 11px; display: block; }
.simple-row > strong { font-size: 12px; white-space: nowrap; }
.ledger-panel { margin-bottom: 0; }
.empty-inline { color: var(--muted); background: #f8faff; border: 1px dashed #d2dced; padding: 20px; border-radius: 13px; font-size: 14px; }
.empty-state { text-align: center; padding: 38px 18px; }
.empty-state h3, .empty-state h2 { color: var(--blue-dark); margin: 10px 0 5px; }
.empty-state p { color: var(--muted); max-width: 480px; margin: 0 auto 18px; }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--blue); border-radius: 15px; background: var(--blue-soft); font-size: 28px; font-weight: 700; margin: 0 auto; }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0 7px; }
.data-table thead th { padding: 0 10px 7px; color: #8090aa; font-size: 11px; text-align: left; font-weight: 780; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.data-table tbody td { background: #f8faff; padding: 11px 10px; font-size: 13px; border-top: 1px solid #edf1fa; border-bottom: 1px solid #edf1fa; vertical-align: middle; }
.data-table tbody td:first-child { border-left: 1px solid #edf1fa; border-radius: 10px 0 0 10px; }
.data-table tbody td:last-child { border-right: 1px solid #edf1fa; border-radius: 0 10px 10px 0; }
.data-table strong { color: var(--ink); }
.data-table .muted { margin-top: 2px; }
.compact-table tbody td { padding: 8px 10px; }
.align-right { text-align: right; }
.muted { color: var(--muted); display: block; font-size: 11px; }
.status-pill, .type-pill, .type-mini { display: inline-flex; align-items: center; gap: 4px; width: fit-content; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 760; white-space: nowrap; }
.status-pending_quote { color: #875b00; background: #fff6cf; }
.status-quoted { color: #7046a7; background: #f1eaff; }
.status-approved { color: #08785e; background: #ddf6ee; }
.status-in_progress { color: #0d55c8; background: #e1ebff; }
.status-completed { color: #52627d; background: #edf1f7; }
.status-muted { color: #6c7482; background: #edf0f4; }
.type-pill.type-expense, .type-mini.type-expense { color: #a23d43; background: #ffe9eb; }
.type-pill.type-income, .type-mini.type-income { color: #08785e; background: #def6ef; }
.type-mini { padding: 3px 6px; font-size: 10px; }
.file-link { color: var(--blue); font-size: 12px; font-weight: 750; }
.table-link { color: var(--blue-dark); }

.filter-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 13px; margin-bottom: 17px; background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 6px 15px rgba(24,48,103,.04); }
.filter-bar label { min-width: 135px; color: var(--muted); font-size: 11px; font-weight: 760; display: grid; gap: 4px; }
.filter-bar select, .filter-bar input { min-height: 39px; }
.search-field { flex: 1 1 300px; position: relative; display: flex !important; align-items: center; color: var(--muted); background: #f7f9ff; border: 1px solid #e7edf8; border-radius: 10px; overflow: hidden; padding: 0 10px; }
.search-field input { border: 0; outline: none; background: transparent; width: 100%; padding-left: 8px; }
.movement-filter { align-items: end; }

.app-form label { display: grid; gap: 6px; color: #465873; font-size: 12px; font-weight: 760; }
.app-form input:not([type=checkbox]), .app-form select, .app-form textarea, .filter-bar select, .filter-bar input:not([type=checkbox]) { width: 100%; border: 1px solid #d8e1ef; border-radius: 10px; background: #fff; color: var(--ink); outline: none; padding: 10px 11px; transition: border-color .16s ease, box-shadow .16s ease; }
.app-form input:not([type=checkbox]), .app-form select, .filter-bar select, .filter-bar input:not([type=checkbox]) { min-height: 42px; }
.app-form textarea { resize: vertical; min-height: 86px; }
.app-form input:focus, .app-form select:focus, .app-form textarea:focus, .filter-bar input:focus, .filter-bar select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,61,242,.1); }
.app-form input[type=file] { padding: 8px; background: #f8faff; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid.three-col { grid-template-columns: repeat(3, minmax(0,1fr)); }
.full-span { grid-column: 1 / -1; }
.checkbox-field { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; font-weight: 650 !important; }
.checkbox-field input { height: 17px; width: 17px; accent-color: var(--blue); }
.form-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid #edf1f7; display: flex; gap: 10px; flex-wrap: wrap; }
.field-help, .label-note { color: var(--muted); font-size: 11px; line-height: 1.35; font-weight: 500; }
.field-help { margin-top: -1px; }
.exchange-field[hidden], [data-expense-only][hidden] { display: none !important; }

.work-hero { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 16px; }
.hero-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-title-row h2 { color: var(--blue-dark); margin: 0; font-size: clamp(26px,3vw,36px); letter-spacing: -.03em; }
.work-hero p { color: var(--muted); margin: 6px 0 0; }
.dot-sep { margin: 0 7px; color: #a2aec0; }
.hero-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.work-stat-strip { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 3px; margin-bottom: 20px; box-shadow: 0 6px 15px rgba(24,48,103,.04); }
.work-stat-strip div { min-height: 76px; padding: 13px 14px; }
.work-stat-strip span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.work-stat-strip strong { color: var(--blue-dark); font-size: 15px; }
.work-grid { grid-template-columns: minmax(0,1.18fr) minmax(320px,.82fr); }
.margin-visual { padding: 4px 4px 0; }
.metric-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 12px 0 5px; color: var(--muted); font-size: 12px; }
.metric-line strong { color: var(--ink); }
.bar-track { background: #ecf0fb; border-radius: 999px; overflow: hidden; height: 10px; }
.bar-track progress { appearance: none; -webkit-appearance: none; border: 0; padding: 0; display: block; width: 100%; height: 10px; overflow: hidden; }
.bar-track progress::-webkit-progress-bar { background: #ecf0fb; }
.bar-track .bar-budget::-webkit-progress-value { background: var(--blue); }
.bar-track .bar-expense::-webkit-progress-value { background: var(--yellow); }
.bar-track .bar-income::-webkit-progress-value { background: var(--success); }
.bar-track .bar-budget::-moz-progress-bar { background: var(--blue); }
.bar-track .bar-expense::-moz-progress-bar { background: var(--yellow); }
.bar-track .bar-income::-moz-progress-bar { background: var(--success); }
.margin-summary { margin-top: 17px; padding-top: 14px; border-top: 1px solid #edf1f7; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.margin-summary strong { color: var(--blue-dark); font-size: 15px; }
.work-detail-grid, .client-detail-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(260px,.46fr); gap: 20px; margin-top: 20px; }
.budget-history { display: grid; gap: 8px; }
.budget-row { display: flex; justify-content: space-between; gap: 15px; padding: 12px 13px; background: #f8faff; border: 1px solid #edf1fa; border-radius: 11px; }
.budget-row span { color: var(--muted); font-size: 11px; display: block; margin-top: 2px; }
.budget-row-actions { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.details-card { margin-top: 20px; border: 1px solid #d9e3f3; border-radius: 13px; background: #fbfcff; overflow: hidden; }
.details-card > summary { padding: 14px 16px; cursor: pointer; color: var(--blue-dark); font-weight: 800; }
.details-card[open] > summary { border-bottom: 1px solid #e2e8f3; }
.details-card > .app-form { padding: 18px; }
.contact-card dl { margin: 0; display: grid; gap: 14px; }
.contact-card dl div { border-bottom: 1px solid #edf1f7; padding-bottom: 12px; }
.contact-card dl div:last-child { border: 0; padding-bottom: 0; }
.contact-card dt { color: var(--muted); font-size: 11px; font-weight: 750; margin-bottom: 3px; }
.contact-card dd { margin: 0; color: var(--ink); font-size: 13px; }
.contact-card dd a { color: var(--blue); font-weight: 700; }

.ai-assistant { padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; border-color: #cbd7fb; background: linear-gradient(120deg, #f7f9ff, #eef2ff); }
.ai-assistant-copy { display: flex; gap: 11px; align-items: center; }
.ai-assistant-copy h3 { color: var(--blue-dark); margin: 0 0 2px; font-size: 16px; }
.ai-assistant-copy p { color: var(--muted); margin: 0; font-size: 12px; }
.ai-badge { height: 35px; min-width: 35px; border-radius: 11px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 900; }
.ai-upload-form { display: flex; gap: 9px; align-items: center; }
.file-drop { min-width: 190px; max-width: 230px; display: grid; gap: 1px; border: 1px dashed #9aadcd; background: #fff; border-radius: 10px; padding: 8px 10px; color: var(--blue-dark); font-size: 12px; font-weight: 750; cursor: pointer; }
.file-drop input { display: none; }
.file-drop small { color: var(--muted); font-size: 10px; font-weight: 500; }
.setup-hint { color: #755700; background: #fff7cf; border: 1px solid #f0dd87; padding: 11px 13px; border-radius: 10px; font-size: 12px; }
.setup-hint code, .config-note code { font-size: 11px; padding: 2px 4px; background: rgba(255,255,255,.7); border-radius: 4px; }
.review-banner { display: flex; gap: 10px; align-items: baseline; padding: 11px 13px; background: #e5efff; color: #164db3; border: 1px solid #c6d9ff; border-radius: 11px; margin-bottom: 17px; font-size: 12px; }
.review-banner span { color: #47699e; }
.form-section { margin-bottom: 26px; }
.document-ready { align-self: end; padding: 10px 12px; background: #edf7f3; border: 1px solid #cbeada; border-radius: 10px; font-size: 12px; }
.document-ready strong { color: var(--success); display: block; }
.line-editor-head { margin: 4px 0 10px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.line-editor-head h3 { margin: 0 0 2px; color: var(--blue-dark); font-size: 17px; }
.line-editor-head p { margin: 0; color: var(--muted); font-size: 12px; }
.line-editor { display: grid; gap: 9px; }
.line-row { display: grid; grid-template-columns: 120px minmax(180px,1.6fr) 78px 116px 110px 135px 110px 32px; gap: 8px; align-items: end; padding: 12px; background: #f8faff; border: 1px solid #e3eaf6; border-radius: 13px; }
.line-row label { font-size: 10px; }
.line-row input, .line-row select { min-height: 38px !important; padding: 8px !important; font-size: 12px; }
.line-total { min-height: 38px; padding-bottom: 7px; }
.line-total span { color: var(--muted); font-size: 10px; display: block; }
.line-total strong { color: var(--blue-dark); font-size: 13px; white-space: nowrap; }
.line-remove { height: 33px; width: 32px; border: 1px solid #f1cfd3; background: #fff; color: var(--danger); border-radius: 9px; font-size: 20px; line-height: 1; }
.line-remove:hover { background: #fff0f1; }
.movement-total { margin-top: 12px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); }
.movement-total span { font-size: 12px; font-weight: 700; }
.movement-total strong { font-size: 18px; }

.admin-split-grid { display: grid; grid-template-columns: minmax(280px,.7fr) minmax(0,1.3fr); gap: 20px; }
.linked-list-panel { height: fit-content; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px solid #f2dadd; }
.text-danger { color: var(--danger); border: 0; background: transparent; font-weight: 750; padding: 0; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 17px; }
.permission-grid fieldset { margin: 0; padding: 13px; border: 1px solid #e0e7f3; border-radius: 12px; display: grid; gap: 8px; }
.permission-grid legend { padding: 0 5px; color: var(--blue-dark); font-size: 12px; font-weight: 800; }

.report-tabs { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.report-tab { min-height: 80px; padding: 13px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 4px 11px rgba(24,48,103,.04); transition: border-color .16s ease, transform .16s ease; }
.report-tab:hover { transform: translateY(-2px); border-color: #a9bcee; }
.report-tab.is-active { background: var(--blue); color: #fff; border-color: var(--blue); }
.report-tab strong { display: block; font-size: 13px; margin-bottom: 4px; }
.report-tab span { display: block; color: var(--muted); font-size: 10px; line-height: 1.3; }
.report-tab.is-active span { color: rgba(255,255,255,.78); }
.report-filter-panel { padding: 12px; margin-bottom: 18px; }
.report-filter-panel .filter-bar { margin: 0; padding: 0; border: 0; box-shadow: none; }
.report-stats { margin-bottom: 18px; }
.report-detail { margin-top: 18px; }

.settings-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(300px,.62fr); gap: 20px; }
.health-list { display: grid; gap: 10px; }
.health-list > div { display: grid; grid-template-columns: 12px 1fr; column-gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid #eef2f7; }
.health-list > div:last-child { border-bottom: 0; }
.health-dot { height: 9px; width: 9px; border-radius: 50%; grid-row: span 2; }
.health-dot.ok { background: var(--success); box-shadow: 0 0 0 3px rgba(12,134,105,.1); }
.health-dot.warn { background: #d69300; box-shadow: 0 0 0 3px rgba(214,147,0,.12); }
.health-list strong { font-size: 12px; }
.health-list small { color: var(--muted); font-size: 11px; }
.config-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.admin-links { margin-top: 20px; padding: 0; display: grid; grid-template-columns: repeat(3,1fr); overflow: hidden; }
.admin-links a { padding: 18px; border-right: 1px solid var(--line); }
.admin-links a:last-child { border-right: 0; }
.admin-links a:hover { background: #f8faff; }
.admin-links strong, .admin-links span { display: block; }
.admin-links strong { color: var(--blue-dark); margin-bottom: 4px; }
.admin-links span { color: var(--muted); font-size: 12px; }

.flash { min-height: 45px; margin-bottom: 15px; padding: 11px 14px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 650; }
.flash-success { background: #e5f7f0; border: 1px solid #bee9d8; color: #08785e; }
.flash-error { background: #fff0f1; border: 1px solid #f3cccf; color: #a6343e; }
.flash-warning { background: #fff7da; border: 1px solid #f0df98; color: #7a5d00; }
.flash-close { border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; }
.change-password-wrap { max-width: 600px; margin: 36px auto; }
.narrow-panel { padding: 30px; }

.login-body { min-height: 100vh; background: linear-gradient(135deg, #eef3ff 0%, #f9fbff 55%, #e1e9ff 100%); display: grid; place-items: center; padding: 24px; }
.login-wrap { width: min(100%, 470px); }
.login-panel { background: #fff; padding: 30px; border: 1px solid #dbe5f6; border-radius: 26px; box-shadow: 0 24px 62px rgba(22,52,113,.15); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 27px; }
.login-brand img { width: 73px; height: 73px; object-fit: contain; background: #fff; border-radius: 19px; padding: 5px; box-shadow: 0 5px 13px rgba(29,61,242,.13); }
.login-brand h1 { margin: 0 0 5px; color: var(--blue-dark); font-size: 22px; line-height: 1.12; letter-spacing: -.025em; }
.login-brand p { color: var(--muted); margin: 0; font-size: 13px; }
.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 6px; color: #465873; font-size: 12px; font-weight: 760; }
.login-form input { min-height: 45px; width: 100%; border: 1px solid #d8e1ef; border-radius: 11px; padding: 0 11px; outline: 0; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,61,242,.1); }
.password-field { position: relative; }
.password-field input { padding-right: 77px; }
.password-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; border-radius: 7px; background: #edf2ff; color: var(--blue); padding: 5px 7px; font-size: 11px; font-weight: 760; }
.login-foot { color: #8794aa; font-size: 11px; text-align: center; margin: 23px 0 0; }

.mobile-only, .mobile-overlay { display: none; }

@media (max-width: 1220px) {
  .line-row { grid-template-columns: 105px minmax(140px,1.4fr) 68px 100px 96px 120px 98px 28px; gap: 6px; padding: 10px; }
  .line-row label { font-size: 9px; }
  .line-row input, .line-row select { font-size: 11px; }
  .report-tabs { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 1060px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 0; left: 0; width: min(300px,86vw); transform: translateX(-104%); transition: transform .22s ease; box-shadow: 16px 0 36px rgba(16,32,74,.16); }
  body.menu-open .sidebar { transform: translateX(0); }
  .mobile-overlay { position: fixed; inset: 0; background: rgba(9,20,47,.34); z-index: 30; }
  body.menu-open .mobile-overlay { display: block; }
  .mobile-only { display: inline-grid; }
  .topbar { border-radius: 0 0 21px 21px; padding: 13px 22px; }
  .icon-button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: rgba(255,255,255,.14); color: #fff; font-size: 21px; place-items: center; }
  .topbar { justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  .user-copy { display: none; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .work-stat-strip { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .line-row { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .line-row .line-description { grid-column: span 2; }
  .line-total { padding-bottom: 0; }
  .line-remove { justify-self: end; align-self: end; }
  .report-tabs { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .topbar { min-height: 72px; gap: 11px; padding: 10px 14px; }
  .topbar-title .eyebrow { display: none; }
  .topbar-title h1 { font-size: 17px; }
  .quick-action { display: none; }
  .user-menu { gap: 0; }
  .logout-form { margin-left: 8px; }
  .page-content { padding: 20px 14px 35px; }
  .page-intro, .work-hero { display: grid; gap: 13px; }
  .page-intro .btn, .page-intro .button-group { width: 100%; }
  .button-group .btn { flex: 1; }
  .panel { border-radius: 16px; padding: 17px; }
  .table-panel { padding: 11px; }
  .form-panel { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 119px; padding: 14px; border-radius: 14px; }
  .stat-card strong { font-size: 20px; }
  .dashboard-grid, .work-detail-grid, .client-detail-grid, .settings-grid, .admin-split-grid { grid-template-columns: 1fr; gap: 15px; }
  .quick-grid { gap: 9px; }
  .simple-row { grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
  .simple-row > strong { display: none; }
  .simple-row .status-pill { grid-column: 2; grid-row: 1; }
  .work-stat-strip { grid-template-columns: 1fr 1fr; padding: 1px; border-radius: 12px; }
  .work-stat-strip div { min-height: 64px; padding: 10px 11px; }
  .work-stat-strip strong { font-size: 13px; }
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-actions .btn { width: 100%; padding: 0 8px; }
  .form-grid.two-col, .form-grid.three-col { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
  .filter-bar .search-field { grid-column: 1 / -1; }
  .filter-bar .btn, .filter-bar .text-link { min-height: 39px; }
  .filter-bar label { min-width: 0; }
  .filter-bar .text-link { align-self: center; justify-self: center; }
  .responsive-table-wrap { overflow: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table { border-spacing: 0; }
  .data-table thead { display: none; }
  .data-table tbody { display: grid; gap: 10px; }
  .data-table tbody tr { border: 1px solid #e2e9f4; border-radius: 12px; background: #f9fbff; padding: 8px 10px; }
  .data-table tbody td { background: transparent; border: 0 !important; border-radius: 0 !important; padding: 5px 0; display: grid; grid-template-columns: minmax(93px,.7fr) minmax(0,1.3fr); gap: 10px; align-items: center; text-align: left; }
  .data-table tbody td::before { content: attr(data-label); color: #8693a8; font-size: 10px; font-weight: 780; text-transform: uppercase; letter-spacing: .03em; }
  .data-table tbody td:empty { display: none; }
  .data-table tbody td.align-right { text-align: left; }
  .data-table tbody td.align-right .btn { justify-self: start; }
  .data-table .muted { margin-top: 0; }
  .ai-assistant { display: grid; padding: 15px; }
  .ai-upload-form { display: grid; grid-template-columns: 1fr; }
  .file-drop { max-width: none; width: 100%; }
  .line-editor-head { align-items: flex-start; }
  .line-editor-head .btn { padding: 0 9px; }
  .line-row { grid-template-columns: 1fr 1fr; gap: 10px; padding: 11px; }
  .line-row .line-description { grid-column: 1 / -1; }
  .line-row .exchange-field { grid-column: auto; }
  .line-total { align-self: end; min-height: 39px; }
  .line-remove { grid-column: 2; grid-row: 5; }
  .review-banner { display: grid; }
  .permission-grid { grid-template-columns: 1fr; }
  .report-tabs { grid-template-columns: 1fr; }
  .report-tab { min-height: 63px; }
  .admin-links { grid-template-columns: 1fr; }
  .admin-links a { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-links a:last-child { border-bottom: 0; }
  .budget-row { display: grid; }
  .budget-row-actions { align-items: flex-start; text-align: left; }
  .change-password-wrap { margin: 0; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
  .work-stat-strip { grid-template-columns: 1fr 1fr; }
  .line-row { grid-template-columns: 1fr; }
  .line-row .line-description { grid-column: auto; }
  .line-row .exchange-field { grid-column: auto; }
  .line-remove { grid-column: auto; grid-row: auto; justify-self: stretch; width: 100%; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar .search-field { grid-column: auto; }
  .login-panel { padding: 23px 18px; }
  .login-brand { align-items: flex-start; }
}

/* SERHO modules: notes, taxes, payroll and salary receipts */
.quick-note-panel { margin-bottom: 20px; border-color: #cfd9ff; background: linear-gradient(135deg,#fff 0%,#f6f8ff 100%); }
.quick-note-form { display: grid; gap: 14px; }
.note-inline-form { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.audio-recorder { min-height: 43px; display: flex; align-items: center; gap: 8px; align-self: end; flex-wrap: wrap; }
.audio-recorder span { color: var(--muted); font-size: 12px; font-weight: 650; }
.is-recording .audio-recorder span { color: var(--danger); }
.is-recording [data-audio-record] { box-shadow: 0 0 0 4px rgba(200,66,66,.12); }
.note-list { display: grid; gap: 11px; }
.note-card { padding: 15px; border: 1px solid #e2e9f5; border-radius: 14px; background: #f9fbff; }
.note-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 8px; }
.note-card-head strong { color: var(--blue-dark); }
.note-card-head span { color: var(--muted); font-size: 11px; }
.note-card p { margin: 7px 0; }
.note-card details { margin: 8px 0; color: var(--muted); }
.note-files { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.file-link { color: var(--blue); font-size: 12px; font-weight: 760; overflow-wrap: anywhere; }
.file-link:hover { text-decoration: underline; }

.budget-extra { border-left: 4px solid var(--yellow) !important; }
.duplicate-warning { grid-column: 1 / -1; border: 2px solid #df7b35; background: #fff5e9; border-radius: 14px; padding: 15px; color: #7d3d12; }
.duplicate-warning strong { display: block; font-size: 16px; }
.duplicate-warning p { margin: 5px 0 0; }
.duplicate-row td { background: #fff8ed !important; border-color: #f0c999 !important; }
.duplicate-mini { display: block; width: fit-content; margin-top: 5px; color: #a55316; background: #ffe4c4; border-radius: 999px; padding: 2px 7px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.tax-total-summary { margin-top: 16px; padding: 13px 15px; border-radius: 12px; background: var(--blue-soft); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tax-total-summary span { color: var(--muted); font-size: 12px; }
.tax-total-summary strong { color: var(--blue-dark); }
.tax-total-summary.has-mismatch { background: #fff2df; border: 1px solid #edbd7f; }
.tax-total-summary.has-mismatch::after { content: "El total final no coincide"; color: #a04d12; font-size: 11px; font-weight: 800; }
.percentage-payment, [data-manual-payment] { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.percentage-payment[hidden], [data-manual-payment][hidden], [data-operating-type][hidden] { display: none !important; }
.calculated-payment { min-height: 69px; border: 1px solid #cdd8f7; border-radius: 12px; background: var(--blue-soft); padding: 11px 13px; display: flex; flex-direction: column; justify-content: center; }
.calculated-payment span { color: var(--muted); font-size: 11px; }
.calculated-payment strong { color: var(--blue-dark); font-size: 17px; }

.payroll-save-status { margin: -10px 0 14px; padding: 10px 13px; border-radius: 11px; color: #52627d; background: #edf1f8; font-size: 12px; font-weight: 760; }
.payroll-save-status[data-state="editing"], .payroll-save-status[data-state="pending"] { color: #704f00; background: #fff3c2; }
.payroll-save-status[data-state="saving"] { color: var(--blue-dark); background: var(--blue-soft); }
.payroll-save-status[data-state="saved"] { color: #086d55; background: #e3f8f1; }
.payroll-save-status[data-state="error"] { color: #9f2e2e; background: #ffe9e9; }
.payroll-panel { padding: 10px; overflow: hidden; }
.payroll-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.payroll-table { width: 100%; min-width: 1180px; border-collapse: separate; border-spacing: 0 7px; }
.payroll-table th { text-align: left; }
.payroll-table thead th { color: #7d8ba3; font-size: 10px; text-transform: uppercase; letter-spacing: .045em; padding: 0 5px 6px; white-space: nowrap; }
.payroll-table tbody th, .payroll-table tbody td { padding: 8px 5px; background: #f8faff; border-top: 1px solid #edf1fa; border-bottom: 1px solid #edf1fa; }
.payroll-table tbody th { position: sticky; left: 0; z-index: 2; min-width: 180px; padding-left: 11px; border-left: 1px solid #edf1fa; border-radius: 10px 0 0 10px; }
.payroll-table tbody th small { color: var(--muted); display: block; font-weight: 500; margin-top: 2px; }
.payroll-table td:last-child { padding-right: 10px; border-right: 1px solid #edf1fa; border-radius: 0 10px 10px 0; }
.payroll-table input { width: 72px; min-height: 39px; padding: 0 7px; text-align: right; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink); }
.payroll-table input:disabled { opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); }
.payroll-panel.is-editing .payroll-table input { border-color: #bfcdf0; background: #fff; }
.payroll-panel.is-editing .payroll-table input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,61,242,.1); }
.payroll-table input.save-error { border-color: var(--danger) !important; background: #fff0f0 !important; }
.payroll-table [data-row-hours], .payroll-table [data-row-total] { white-space: nowrap; color: var(--blue-dark); }

.receipt-actions { max-width: 920px; margin: 0 auto 14px; display: flex; justify-content: space-between; gap: 10px; }
.salary-receipt { max-width: 920px; margin: 0 auto; padding: 34px; background: #fff; color: #111; border: 1px solid #cfd5de; box-shadow: var(--shadow); }
.salary-receipt header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 17px; border-bottom: 3px solid #111; }
.salary-receipt h1 { margin: 0 0 3px; font-size: 24px; letter-spacing: .03em; }
.salary-receipt header p { margin: 0; }
.receipt-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0; border: 1px solid #111; margin-top: 18px; }
.receipt-grid > div { min-height: 65px; padding: 9px; border-right: 1px solid #111; border-bottom: 1px solid #111; }
.receipt-grid > div:nth-child(3n) { border-right: 0; }
.receipt-grid > div:nth-last-child(-n+3) { border-bottom: 0; }
.receipt-grid span { display: block; font-size: 10px; text-transform: uppercase; color: #4b4b4b; }
.receipt-grid strong { display: block; margin-top: 4px; }
.employer-box { border: 1px solid #111; border-top: 0; padding: 9px; font-size: 12px; }
.employer-box p { margin: 3px 0; }
.receipt-lines { width: 100%; border-collapse: collapse; margin-top: 18px; }
.receipt-lines th, .receipt-lines td { border: 1px solid #111; padding: 9px; text-align: left; }
.receipt-lines th:nth-child(3), .receipt-lines th:nth-child(4), .receipt-lines td:nth-child(3), .receipt-lines td:nth-child(4) { text-align: right; }
.receipt-lines tfoot th { font-size: 15px; background: #f1f1f1; }
.receipt-meta { margin-top: 16px; padding: 11px; border: 1px solid #111; font-size: 12px; }
.receipt-meta p { margin: 3px 0; }
.salary-receipt footer { display: grid; grid-template-columns: repeat(3,1fr); gap: 25px; margin-top: 62px; }
.salary-receipt footer div { border-top: 1px solid #111; text-align: center; padding-top: 6px; font-size: 11px; }
.receipt-legal-note { margin: 24px 0 0; font-size: 10px; color: #555; }

@media (max-width: 760px) {
  .audio-recorder { align-self: stretch; }
  .percentage-payment, [data-manual-payment] { grid-template-columns: 1fr; }
  .tax-total-summary { display: grid; }
  .tax-total-summary.has-mismatch::after { display: block; }
  .payroll-panel { padding: 7px; }
  .payroll-scroll { overflow: visible; }
  .payroll-table { min-width: 0; display: block; }
  .payroll-table thead { display: none; }
  .payroll-table tbody { display: grid; gap: 13px; }
  .payroll-table tr { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); padding: 11px; border: 1px solid #dfe7f4; border-radius: 14px; background: #f8faff; }
  .payroll-table tbody th { position: static; grid-column: 1 / -1; min-width: 0; border: 0; border-bottom: 1px solid #e3e9f3; border-radius: 0; padding: 0 0 9px; background: transparent; }
  .payroll-table tbody td { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 5px 0; border: 0; background: transparent; }
  .payroll-table tbody td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 780; text-transform: uppercase; }
  .payroll-table tbody td:last-child { grid-column: 1 / -1; border: 0; padding-top: 9px; }
  .payroll-table input { width: 88px; background: rgba(255,255,255,.75); border-color: #e1e7f0; }
  .payroll-table td:last-child .btn { width: 100%; }
  .salary-receipt { padding: 18px; overflow-x: auto; }
  .salary-receipt header { display: grid; }
  .receipt-grid { grid-template-columns: 1fr 1fr; min-width: 620px; }
  .receipt-grid > div:nth-child(3n) { border-right: 1px solid #111; }
  .receipt-grid > div:nth-child(2n) { border-right: 0; }
  .receipt-grid > div:nth-last-child(-n+3) { border-bottom: 1px solid #111; }
  .receipt-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
  .receipt-lines, .employer-box, .receipt-meta, .salary-receipt footer { min-width: 620px; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff !important; }
  .sidebar, .topbar, .no-print, .mobile-overlay, .flash-stack { display: none !important; }
  .app-shell, .app-main, .page-content { display: block !important; margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .salary-receipt { width: 100%; max-width: none; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .receipt-legal-note { color: #333; }
}

/* Sidebar scrolling and operator discount configuration */
.sidebar { overflow: hidden; }
.sidebar-brand, .sidebar-foot { flex-shrink: 0; }
.nav-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  padding-right: 4px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}
.nav-list::-webkit-scrollbar { width: 7px; }
.nav-list::-webkit-scrollbar-thumb { background: #d3dced; border-radius: 999px; }
.nav-list::-webkit-scrollbar-track { background: transparent; }

.settings-form-panel { max-width: 1040px; }
.form-section-title { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section-title h3 { margin: 0; color: var(--blue-dark); font-size: 18px; }
.form-section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.custom-discount-editor { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #f9fbff; }
.custom-discount-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.custom-discount-list { display: grid; gap: 10px; }
.custom-discount-row { display: grid; grid-template-columns: minmax(180px,1.4fr) minmax(130px,.8fr) minmax(120px,.7fr) auto; gap: 10px; align-items: end; }
.custom-discount-remove { margin-bottom: 1px; }
.history-subheading { margin-top: 26px; }
.receipt-net-row th { font-size: 17px !important; background: #e9e9e9 !important; }

@media (max-width: 760px) {
  .custom-discount-row { grid-template-columns: 1fr; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
  .custom-discount-remove { width: 100%; }
}
