:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --surface-3: #e3e9e5;
  --text: #17201b;
  --muted: #637068;
  --border: #d5ddd8;
  --primary: #235d3d;
  --primary-hover: #17482e;
  --primary-soft: #e2f0e8;
  --danger: #a62f32;
  --danger-soft: #f8e8e8;
  --warning: #8a5b10;
  --warning-soft: #fff2d6;
  --info: #285f82;
  --info-soft: #e5f0f7;
  --sidebar: #17231c;
  --sidebar-text: #edf3ef;
  --shadow: 0 10px 30px rgba(20, 35, 26, .12);
  --radius: 6px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151916;
  --surface: #1d231f;
  --surface-2: #242b26;
  --surface-3: #303932;
  --text: #edf2ee;
  --muted: #a6b1aa;
  --border: #3a453e;
  --primary: #66aa7f;
  --primary-hover: #82bd94;
  --primary-soft: #253c2d;
  --danger: #ec7779;
  --danger-soft: #442729;
  --warning: #e2b45d;
  --warning-soft: #3d3320;
  --info: #7eb5d5;
  --info-soft: #213743;
  --sidebar: #101411;
  --sidebar-text: #edf3ef;
  --shadow: 0 14px 34px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.brand { height: 76px; display: flex; align-items: center; gap: 11px; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.55); font-weight: 900; font-size: 13px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { color: rgba(237,243,239,.66); font-size: 11px; margin-top: 2px; }
.nav { padding: 14px 10px; display: grid; gap: 4px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.nav-item { height: 42px; border: 0; background: transparent; color: rgba(237,243,239,.73); display: flex; align-items: center; gap: 11px; padding: 0 12px; cursor: pointer; border-radius: 5px; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(113,188,139,.16); color: #fff; box-shadow: inset 3px 0 #71bc8b; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { margin-top: auto; min-height: 50px; padding: 12px 18px; display: flex; align-items: center; gap: 8px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; color: rgba(237,243,239,.65); }

.workspace { min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-rows: 64px minmax(0, 1fr); overflow: hidden; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 22px; }
.quick-search { width: min(560px, 58vw); height: 38px; border: 1px solid var(--border); background: var(--surface-2); display: flex; align-items: center; gap: 9px; padding: 0 10px; border-radius: var(--radius); }
.quick-search svg { color: var(--muted); width: 17px; }
.quick-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); min-width: 0; }
.quick-search kbd { border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 2px 5px; border-radius: 3px; font-size: 10px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.theme-switch { height: 36px; display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.theme-switch > svg { width: 16px; height: 16px; }
.theme-switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 42px; height: 23px; padding: 3px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border); transition: .18s; }
.switch-track span { display: block; width: 15px; height: 15px; border-radius: 50%; background: var(--primary); transition: transform .18s; }
.theme-switch input:checked + .switch-track span { transform: translateX(19px); }

.view { min-width: 0; min-height: 0; overflow: auto; padding: 24px 28px 34px; outline: 0; overscroll-behavior: contain; scrollbar-gutter: stable; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.page-head p { color: var(--muted); margin: 5px 0 0; font-size: 13px; }
.head-actions, .toolbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button { min-height: 36px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; padding: 7px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-weight: 650; white-space: nowrap; }
.button:hover { border-color: var(--primary); color: var(--primary); }
.button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { color: #fff; background: var(--primary-hover); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.button.danger:hover { background: var(--danger-soft); }
.button.ghost { background: transparent; border-color: transparent; }
.button.small { min-height: 30px; padding: 5px 8px; font-size: 12px; }
.button:disabled, .icon-button:disabled { opacity: .45; cursor: not-allowed; }

.date-toolbar, .filterbar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.date-toolbar { margin-bottom: 18px; }
.field { min-width: 0; }
.field > label, .field-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 5px; }
.field input, .field select, .field textarea, .control { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); outline: 0; }
.field textarea { resize: vertical; min-height: 76px; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus, .control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent); }
.field.grow { flex: 1 1 260px; }
.field.compact { width: 160px; }
.required::after { content: " *"; color: var(--danger); }
.help { color: var(--muted); font-size: 11px; margin-top: 5px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 104px; padding: 15px; display: grid; grid-template-columns: 1fr auto; align-items: start; }
.metric .metric-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric strong { display: block; grid-column: 1 / -1; font-size: 23px; margin-top: 9px; align-self: end; overflow-wrap: anywhere; }
.metric .metric-icon { width: 31px; height: 31px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); border-radius: 5px; }
.metric.warning .metric-icon { background: var(--warning-soft); color: var(--warning); }
.metric.danger .metric-icon { background: var(--danger-soft); color: var(--danger); }
.metric.info .metric-icon { background: var(--info-soft); color: var(--info); }

.band { margin-top: 22px; }
.band-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.band-head h2 { font-size: 15px; margin: 0; }
.surface { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.toolbar { padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar .filterbar { flex: 1 1 auto; }
.receipt-toolbar { display: grid; grid-template-columns: minmax(0,1fr); align-items: stretch; }
.receipt-toolbar-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding-top: 2px; }
.quick-range-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.quick-range-bar > span { color: var(--muted); font-size: 11px; font-weight: 700; margin-right: 2px; }
.number-range { width: 125px !important; }
.search-control { position: relative; min-width: 220px; flex: 1 1 280px; }
.search-control svg { position: absolute; left: 10px; top: 10px; width: 16px; color: var(--muted); }
.search-control input { padding-left: 34px; }

.data-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.receipt-table { min-width: 940px; }
.select-cell { width: 42px; min-width: 42px; text-align: center !important; padding-left: 8px !important; padding-right: 8px !important; }
.select-cell input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.data-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); text-align: left; font-size: 10px; text-transform: uppercase; font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 11px; margin-top: 3px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { text-align: right; white-space: nowrap; font-weight: 750; }
.status { display: inline-flex; align-items: center; gap: 5px; min-height: 23px; padding: 3px 7px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; white-space: nowrap; }
.status.ACEPTADO, .status.EMITIDO, .status.ACTIVO { background: var(--primary-soft); color: var(--primary); }
.status.ANULADO, .status.RECHAZADO, .status.CANCELADO, .status.ARCHIVADO { background: var(--danger-soft); color: var(--danger); }
.status.BORRADOR { background: var(--warning-soft); color: var(--warning); }
.status.ENVIADO, .status.GENERADO { background: var(--info-soft); color: var(--info); }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 9px; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }
.table-foot { min-height: 44px; padding: 8px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.receipt-summary { display: grid; grid-template-columns: repeat(4,minmax(130px,1fr)); gap: 1px; background: var(--border); border-bottom: 1px solid var(--border); }
.receipt-summary > div { min-width: 0; background: var(--surface-2); padding: 11px 13px; }
.receipt-summary span, .receipt-summary strong { display: block; }
.receipt-summary span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.receipt-summary strong { margin-top: 4px; font-size: 15px; overflow-wrap: anywhere; }
.receipt-table-foot > div { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.selection-count { color: var(--primary); font-weight: 750; }
.pagination { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.compact-control { width: auto; min-height: 30px; padding: 4px 7px; font-size: 12px; }

.activity-list { display: grid; }
.activity-row { min-height: 58px; padding: 10px 13px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.activity-row:last-child { border-bottom: 0; }
.activity-row:hover { background: var(--surface-2); }
.activity-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 5px; background: var(--primary-soft); color: var(--primary); }
.activity-row strong { display: block; font-size: 12px; }
.activity-row small { color: var(--muted); display: block; margin-top: 3px; }
.activity-amount { text-align: right; font-weight: 700; font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(7, 12, 9, .55); display: grid; place-items: center; padding: 22px; }
.modal { width: min(920px, calc(100vw - 44px)); max-height: calc(100vh - 44px); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; box-shadow: var(--shadow); display: grid; grid-template-rows: auto minmax(0,1fr) auto; overflow: hidden; }
.modal.wide { width: min(1180px, calc(100vw - 44px)); }
.modal.small { width: min(520px, calc(100vw - 44px)); }
.modal-head { min-height: 58px; padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.modal-body { min-height: 0; overflow: auto; padding: 18px; }
.modal-foot { min-height: 58px; padding: 10px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.close-modal { width: 34px; height: 34px; border: 0; background: transparent; display: grid; place-items: center; border-radius: 4px; cursor: pointer; }
.close-modal:hover { background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); gap: 13px; }
.span-12 { grid-column: span 12; }.span-9 { grid-column: span 9; }.span-8 { grid-column: span 8; }.span-6 { grid-column: span 6; }.span-4 { grid-column: span 4; }.span-3 { grid-column: span 3; }
.section-title { grid-column: span 12; padding-top: 7px; border-bottom: 1px solid var(--border); padding-bottom: 7px; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: space-between; }
.section-title:first-child { padding-top: 0; }
.section-title span { color: var(--muted); font-weight: 500; font-size: 11px; }
.segmented { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border: 1px solid var(--border); padding: 3px; border-radius: 5px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { min-height: 29px; padding: 6px 12px; display: grid; place-items: center; border-radius: 3px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.client-picker { position: relative; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 4; max-height: 260px; overflow: auto; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 5px; }
.picker-result { width: 100%; min-height: 48px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; padding: 8px 10px; cursor: pointer; }
.picker-result:hover { background: var(--surface-2); }
.picker-result strong, .picker-result span { display: block; }
.picker-result span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.selected-client { min-height: 34px; margin-top: 6px; padding: 7px 9px; background: var(--primary-soft); color: var(--primary); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border)); display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 4px; font-size: 12px; }

.items-editor { grid-column: span 12; border: 1px solid var(--border); border-radius: 5px; overflow: auto; }
.items-editor table { width: 100%; min-width: 820px; border-collapse: collapse; }
.items-editor th { background: var(--surface-2); color: var(--muted); text-transform: uppercase; font-size: 9px; text-align: left; padding: 8px; }
.items-editor td { padding: 6px; border-top: 1px solid var(--border); vertical-align: top; }
.items-editor input, .items-editor select { width: 100%; height: 33px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 3px; padding: 5px 7px; }
.items-editor .item-desc { min-width: 230px; }.items-editor .item-number { min-width: 105px; }.items-editor .item-short { min-width: 80px; }
.items-editor .remove-item { width: 32px; height: 32px; border: 0; background: transparent; color: var(--danger); display: grid; place-items: center; cursor: pointer; }
.budget-total { grid-column: 9 / span 4; display: grid; gap: 7px; padding: 12px; background: var(--surface-2); border-radius: 5px; }
.budget-total div { display: flex; justify-content: space-between; gap: 12px; }
.budget-total .grand { font-size: 16px; color: var(--primary); font-weight: 900; padding-top: 8px; border-top: 1px solid var(--border); }
.budget-links { display: grid; gap: 5px; max-height: 210px; overflow: auto; border: 1px solid var(--border); padding: 7px; border-radius: 4px; }
.budget-link { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 7px; min-height: 32px; padding: 4px 6px; }
.budget-link:hover { background: var(--surface-2); }
.budget-link input { width: 15px; height: 15px; accent-color: var(--primary); }
.budget-link small { color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.detail-block { border-top: 1px solid var(--border); padding-top: 9px; min-width: 0; }
.detail-block span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; margin-bottom: 5px; }
.detail-block strong { display: block; overflow-wrap: anywhere; }
.detail-block p { margin: 0; white-space: pre-line; line-height: 1.45; }
.detail-block.full { grid-column: 1 / -1; }
.detail-highlight { grid-column: 1 / -1; background: var(--surface-2); padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 15px; border-radius: 5px; }
.detail-highlight strong { font-size: 21px; }
.related-list { display: grid; border: 1px solid var(--border); border-radius: 5px; }
.related-item { min-height: 43px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.related-item:last-child { border-bottom: 0; }

.client-layout { display: grid; grid-template-columns: minmax(360px, .95fr) minmax(420px, 1.2fr); gap: 14px; min-height: 560px; }
.client-list { min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.client-rows { overflow: auto; }
.client-row { padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.client-row:hover, .client-row.active { background: var(--primary-soft); }
.client-row strong { display: block; }
.client-row span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.client-detail { min-height: 0; padding: 16px; overflow: auto; }
.client-detail.empty { display: grid; place-items: center; color: var(--muted); }
.client-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.client-title h2 { margin: 0; font-size: 18px; }.client-title p { color: var(--muted); margin: 4px 0 0; }
.tabs { display: flex; border-bottom: 1px solid var(--border); margin: 18px 0 10px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 9px 11px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 750; }

.search-hero { max-width: 760px; margin: 12px auto 24px; }
.search-hero .large-search { height: 48px; position: relative; }
.search-hero input { height: 48px; padding-left: 43px; font-size: 15px; }
.search-hero svg { position: absolute; left: 14px; top: 15px; color: var(--muted); }
.result-list { max-width: 1000px; margin: auto; display: grid; gap: 7px; }
.result-row { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; min-height: 68px; padding: 11px 13px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 11px; align-items: center; cursor: pointer; }
.result-row:hover { border-color: var(--primary); }
.result-row .result-icon { width: 33px; height: 33px; display: grid; place-items: center; background: var(--surface-2); border-radius: 4px; color: var(--primary); }
.result-row strong, .result-row span { display: block; }.result-row span { color: var(--muted); font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { text-align: right; }.result-meta b { display: block; margin-top: 4px; }

.config-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.config-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.config-section h2 { font-size: 13px; margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.config-section .config-body { padding: 14px; }
.number-row { padding: 10px 0; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.number-row:last-child { border: 0; }.number-row span { color: var(--muted); }.number-row strong { text-align: right; }
.backup-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.backup-row:last-child { border: 0; }.backup-row strong,.backup-row span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.backup-row span { color:var(--muted);font-size:10px;margin-top:3px; }

.toast-layer { position: fixed; right: 18px; bottom: 18px; z-index: 60; width: min(380px, calc(100vw - 36px)); display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--primary); padding: 11px 12px; box-shadow: var(--shadow); border-radius: 5px; animation: toast-in .18s ease-out; }
.toast.error { border-left-color: var(--danger); }.toast strong { display: block; font-size: 12px; }.toast span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.loading { position: fixed; inset: 0; z-index: 80; background: rgba(10,15,12,.38); display: grid; place-items: center; align-content: center; gap: 10px; color: #fff; font-weight: 700; }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.28); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .brand { justify-content: center; padding: 0; }.brand > div:last-child, .nav-item span, .sidebar-foot span { display: none; }
  .nav-item { justify-content: center; padding: 0; }.nav-item.active { box-shadow: inset 3px 0 #71bc8b; }
  .sidebar-foot { justify-content: center; padding: 12px 0; }
  .metrics { grid-template-columns: repeat(2, minmax(150px,1fr)); }
  .config-layout { grid-template-columns: 1fr; }
  .client-layout { grid-template-columns: minmax(300px,.8fr) minmax(390px,1fr); }
}

@media (max-width: 900px) {
  .view { padding: 18px; }.topbar { padding: 0 14px; }.quick-search { width: 65vw; }
  .page-head { align-items: stretch; flex-direction: column; }.head-actions { justify-content: flex-start; }
  .span-9,.span-8,.span-6,.span-4,.span-3 { grid-column: span 12; }
  .budget-total { grid-column: 1 / -1; }.detail-grid { grid-template-columns: 1fr 1fr; }
  .client-layout { grid-template-columns: 1fr; }.client-list { max-height: 370px; }
  .receipt-toolbar-bottom, .receipt-table-foot { align-items: stretch; flex-direction: column; }
  .receipt-toolbar-bottom .toolbar-actions { justify-content: flex-start; }
  .receipt-summary { grid-template-columns: repeat(2,minmax(130px,1fr)); }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 64px minmax(0,1fr); }
  .brand { padding: 0; justify-content: center; }
  .brand-mark { width: 34px; height: 34px; }
  .topbar { gap: 8px; padding: 0 9px; }
  .quick-search { width: auto; min-width: 0; flex: 1 1 auto; }
  .quick-search kbd, .theme-switch > svg { display: none; }
  .top-actions { gap: 6px; }
  .view { padding: 13px 11px 24px; }
  .metrics { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 8px; }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .modal-body { padding: 13px; }
  .modal-foot { flex-wrap: wrap; padding: 9px; }
  .modal-foot .button { flex: 1 1 145px; }
  .filterbar > .search-control { flex-basis: 100%; }
  .field.compact { flex: 1 1 145px; width: auto; }
  .number-range { width: auto !important; }
  .receipt-toolbar-bottom .toolbar-actions .button { flex: 1 1 155px; }
  .pagination { justify-content: flex-start; }
}

@media (max-height: 620px) {
  .workspace { grid-template-rows: 52px minmax(0,1fr); }
  .brand { height: 54px; }
  .nav { padding-top: 7px; padding-bottom: 7px; gap: 2px; }
  .nav-item { height: 36px; }
  .sidebar-foot { min-height: 40px; padding-top: 7px; padding-bottom: 7px; }
  .view { padding-top: 13px; padding-bottom: 20px; }
  .page-head { margin-bottom: 14px; }
}

/* Client records share the app's forms, tabs and document surfaces. */
.crm-screen{min-width:0}.crm-filters{display:flex;flex-wrap:wrap;align-items:end;gap:16px}.crm-filters>.field:first-child{flex:1;min-width:220px}.crm-filters>.field{min-width:150px}.crm-list-help{padding:0 16px 16px;margin:0}.crm-fieldset{border:0;padding:0;margin:0;min-width:0}.crm-table small{display:block;margin-top:5px;color:var(--muted);font-size:12px;max-width:360px;white-space:normal;overflow-wrap:anywhere}.crm-table td{vertical-align:top}.crm-table td .button+.button{margin-top:6px}.crm-payment-form{margin-top:24px}.crm-screen .hr-identity{overflow-wrap:anywhere}.crm-screen .hr-tabs{overflow-x:auto}.crm-screen .field input,.crm-screen .field select,.crm-screen .field textarea{min-width:0;max-width:100%}.crm-screen #client-page{display:flex;flex-wrap:wrap;gap:12px;justify-content:space-between}.crm-screen .pagination{display:flex;gap:8px}@media(max-width:680px){.crm-filters>.field{flex:1 1 100%;min-width:0}.crm-screen .hr-tabs{gap:4px}.crm-screen .hr-tabs .button{white-space:nowrap}.crm-screen .page-head h1{overflow-wrap:anywhere}}

.crm-screen .config-section{margin-bottom:24px}.crm-screen .config-section>h2{padding:18px 24px;font-size:1.0625rem}.crm-screen .crm-fieldset>.hr-form-grid{padding:0}.crm-screen .field>label{font-size:.875rem;font-weight:500;color:var(--text)}.crm-screen input,.crm-screen select,.crm-screen textarea{font-size:.9375rem;min-height:44px}.crm-screen .hr-tabs{display:flex;flex-wrap:wrap}.crm-screen .page-head{flex-wrap:wrap}.crm-screen .data-wrap{max-width:100%;overflow-x:auto}.crm-screen .config-body>.hr-form-actions{margin-top:18px}

.record-back-row{display:flex;align-items:center;justify-content:flex-start;flex-wrap:wrap;gap:8px 18px;margin:0 0 14px}.record-back-button.button{display:inline-flex;align-items:center;gap:7px;min-height:32px;padding:6px 0;background:transparent;border-color:transparent;color:var(--muted)}.record-back-button.button:hover{color:var(--text)}.record-back-button svg{width:16px;height:16px}.record-back-button:focus-visible{outline:2px solid var(--accent,var(--primary));outline-offset:3px}@media(max-width:600px){.record-back-row{margin-bottom:10px}}

/* Square controls throughout the application. */
button,.button,.icon-button,input[type=button],input[type=submit],[role=button],summary{border-radius:0!important}