:root {
  --navy: #172033;
  --ink: #243044;
  --muted: #66758b;
  --canvas: #f3f6fa;
  --paper: #ffffff;
  --line: #dde4ee;
  --teal: #0d9488;
  --teal-dark: #0f8279;
  --teal-soft: #e6f7f4;
  --blue: #1d4ed8;
  --danger: #c0394b;
  --purple: #7c3aed;
  font-family: "Segoe UI", "Inter", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { width: 1px !important; height: 1px !important; position: absolute !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #21a99d; outline-offset: 1px; }
.desktop-window { min-height: 100vh; padding-bottom: 23px; }

.top-bar { height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 9px 28px; color: white; background: #091124; }
.brand-logo { width: 204px; height: 44px; flex: 0 0 204px; display: block; object-fit: contain; }
.brand-block strong, .brand-block span { display: block; }
.brand-block strong { font-size: 21px; line-height: 1.15; }
.brand-block span { margin-top: 3px; color: #9eacc3; font-size: 12px; }
.top-bar__right { display: flex; align-items: center; gap: 18px; }
.database-name { color: #9eacc3; font-size: 12px; }
.demo-mode { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid rgba(136, 226, 212, .35); border-radius: 8px; color: #b9eee6; background: rgba(13, 148, 136, .12); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.demo-mode i, .local-simulation-pill i { width: 7px; height: 7px; display: block; border-radius: 50%; background: #55d6c8; box-shadow: 0 0 0 3px rgba(85,214,200,.14); }
.local-data-button { min-height: 31px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid #46536a; border-radius: 7px; color: #c5d0e0; background: #202b40; font-size: 11px; font-weight: 600; }
.local-data-button:hover { border-color: #6a7891; color: white; background: #29364c; }
.local-data-button span { width: 15px; height: 15px; color: #55d6c8; }
.workspace { min-height: calc(100vh - 93px); }
.page { display: none; min-height: calc(100vh - 93px); padding: 30px 42px 25px; background: var(--canvas); animation: page-in .16s ease; }
.page.is-active { display: flex; flex-direction: column; }
@keyframes page-in { from { opacity: 0; transform: translateY(2px); } }
h1 { margin: 0; color: var(--navy); font-size: 28px; line-height: 1.2; }

.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.dashboard-heading > div { min-width: 0; }
.dashboard-heading p, .page-heading p { margin: 9px 0 0; color: var(--muted); }
.version-badge { padding: 5px 11px; border: 1px solid #a7ded7; border-radius: 10px; color: #0f766e; background: var(--teal-soft); font-size: 12px; font-weight: 700; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(2, minmax(185px, 1fr)); gap: 20px 22px; flex: 1; margin-top: 10px; }
.dashboard-card { min-height: 185px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; border: 1px solid var(--line); border-radius: 16px; color: var(--navy); background: white; transition: .14s ease; }
.dashboard-card:hover { border-color: #41b9ad; background: #f5fffd; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(34, 60, 77, .07); }
.dashboard-card:active { background: #eefaf8; transform: none; }
.dashboard-icon { width: 78px; height: 78px; margin-bottom: 11px; color: var(--teal); }
.dashboard-card strong { font-size: 18px; font-weight: 650; }
.dashboard-card small { max-width: 100%; margin-top: 5px; color: var(--ink); font-size: 14px; overflow-wrap: anywhere; text-align: center; }
.local-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 20px 0 0; color: var(--muted); font-size: 12px; }
.local-note span { width: 14px; height: 14px; color: var(--teal); }

.table-page { padding: 25px 32px 27px; }
.page-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 14px; }
.page-heading .back-button { flex: 0 0 auto; }
.back-button { min-height: 36px; padding: 0 8px; border: 0; border-radius: 7px; color: #5c6b80; background: transparent; font-weight: 600; }
.back-button:hover { color: var(--ink); background: #e9eef5; }
.toolbar { min-height: 45px; display: flex; align-items: center; gap: 8px; margin-bottom: 13px; overflow-x: auto; }
.toolbar-spacer { flex: 1; }
.toolbar-divider { width: 1px; height: 28px; flex: 0 0 auto; margin: 0 6px; background: #d8e0ea; }
.btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 15px; border: 1px solid #cfd8e6; border-radius: 7px; color: #29364b; background: white; font-weight: 600; white-space: nowrap; transition: .12s; }
.btn:hover { border-color: #9eacc0; background: #f5f8fc; }
.btn:active { background: #eaf0f7; }
.btn:disabled { border-color: #e1e5eb; color: #9da9ba; background: #f3f5f8; cursor: default; }
.btn--primary { border-color: var(--teal); color: white; background: var(--teal); }
.btn--primary:hover { border-color: var(--teal-dark); color: white; background: var(--teal-dark); }
.btn--danger { border-color: #edbdc5; color: var(--danger); background: #fffafb; }
.btn--danger:hover { border-color: #df8997; background: #fff0f2; }
.btn--ghost { border: 0; color: #5c6b80; background: transparent; }
.btn--ghost:hover { color: var(--ink); background: #e9eef5; }
.btn--icon { width: 42px; padding: 8px; }
.btn--icon span { width: 22px; height: 22px; }
.btn--important { min-height: 40px; padding: 0 20px; border-color: var(--blue); color: white; background: var(--blue); font-weight: 700; }
.btn--important:hover { border-color: #1e40af; color: white; background: #1e40af; }
.btn--important:disabled { border-color: #d5dbe4; color: #8d99aa; background: #e5e9ef; }
.btn--retry { min-height: 40px; padding: 0 20px; border-color: #c2410c; color: white; background: #c2410c; font-weight: 700; }
.btn--retry:hover { border-color: #9a3412; color: white; background: #9a3412; }
.btn--retry:disabled { border-color: #e1e5eb; color: #9da9ba; background: #f3f5f8; }
.btn--wide { width: 100%; }
.btn--with-icon span { width: 20px; height: 20px; color: var(--teal); }
.excel-group { display: inline-flex; gap: 6px; padding: 4px 6px; border: 1px solid #9edbd4; border-radius: 9px; background: var(--teal-soft); }
.excel-group .btn { min-height: 32px; border-color: #86cfc7; }

.aeat-action-bar { min-height: 70px; display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 12px 16px; border: 1px solid #93c5fd; border-radius: 10px; background: #eff6ff; }
.aeat-copy { display: flex; flex-direction: column; flex: 1; min-width: 260px; }
.aeat-copy strong { color: #1e3a8a; }
.aeat-copy span { margin-top: 3px; color: #526077; font-size: 13px; }
.local-simulation-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #9edbd4; border-radius: 7px; color: #0f766e; background: #f4fffd; font-size: 9px; font-weight: 800; letter-spacing: .06em; white-space: nowrap; }

.table-card { flex: 1; min-height: 240px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; }
.simple-table-card { overflow: auto; }
.simple-table-card table { min-width: 880px; }
.data-table-card { min-height: 355px; }
.filter-table-wrap { width: 100%; height: 100%; overflow: auto; scrollbar-color: #bac5d4 #f1f4f8; scrollbar-width: thin; }
#page-clientes .data-table-card, #page-facturas .data-table-card { display: flex; min-height: 0; }
#page-clientes .filter-table-wrap, #page-facturas .filter-table-wrap { height: auto; min-height: 0; flex: 1; }
table { width: 100%; border-collapse: collapse; color: var(--ink); }
th { height: 43px; padding: 10px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid #d6dee9; color: #435168; background: #eef2f7; font-weight: 650; text-align: left; white-space: nowrap; }
th button { width: 23px; height: 23px; float: right; padding: 0; border: 1px solid #cbd5e2; border-radius: 4px; color: #526077; background: white; }
th button:hover { border-color: #62c9bf; color: #087f75; background: #dff5f2; }
td { height: 46px; padding: 7px 10px; border-bottom: 1px solid #e9edf3; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #eefaf8; }
tbody tr.is-selected { color: var(--navy); background: #cceeea; }
.filter-table { min-width: 1820px; table-layout: auto; }
.filter-table thead { position: sticky; top: 0; z-index: 3; }
.filter-table .filters th { height: 48px; padding: 6px; }
.filters input, .filters select { width: 100%; min-width: 110px; height: 34px; padding: 2px 7px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; font-size: 12px; }
.invoice-table thead > tr:first-child th { height: 43px; padding: 6px 7px; vertical-align: middle; }
.invoice-column-heading { min-height: 25px; display: flex; align-items: center; justify-content: space-between; gap: 8px; line-height: 1.2; }
.invoice-column-heading > span:first-child { min-width: 0; }
.invoice-column-heading--center { justify-content: center; }
.invoice-column-heading .sort-button { width: 24px; height: 24px; flex: 0 0 24px; float: none; }
.filters .date-range-filter { width: 100%; min-width: 170px; height: 34px; float: none; padding: 2px 9px; border: 1px solid #cfd8e6; border-radius: 7px; color: #435168; background: white; font-size: 12px; font-weight: 600; }
.filters .date-range-filter:hover, .filters .date-range-filter.is-active { border-color: #38b7ab; color: #0f766e; background: #f1fbf9; }
#clients-table { min-width: 2200px; }
#clients-table th:nth-child(1), #clients-table td:nth-child(1) { min-width: 135px; }
#clients-table th:nth-child(2), #clients-table td:nth-child(2) { min-width: 150px; }
#clients-table th:nth-child(3), #clients-table td:nth-child(3) { min-width: 210px; }
#clients-table th:nth-child(4), #clients-table td:nth-child(4) { min-width: 135px; }
#clients-table th:nth-child(5), #clients-table td:nth-child(5) { min-width: 220px; }
#clients-table th:nth-child(6), #clients-table td:nth-child(6) { min-width: 230px; }
#clients-table th:nth-child(7), #clients-table td:nth-child(7) { min-width: 190px; }
#clients-table th:nth-child(8), #clients-table td:nth-child(8) { min-width: 260px; }
#clients-table th:nth-child(9), #clients-table td:nth-child(9) { min-width: 125px; }
#clients-table th:nth-child(10), #clients-table td:nth-child(10), #clients-table th:nth-child(11), #clients-table td:nth-child(11) { min-width: 150px; }
#clients-table th:nth-child(12), #clients-table td:nth-child(12) { min-width: 130px; }
.invoice-table th[data-column-name="id"], .invoice-table td[data-column-name="id"] { min-width: 150px; }
.invoice-table th[data-column-name="history"], .invoice-table td[data-column-name="history"] { min-width: 145px; text-align: center; }
.invoice-table th[data-column-name="state"], .invoice-table td[data-column-name="state"] { min-width: 145px; }
.invoice-table th[data-column-name="number"], .invoice-table td[data-column-name="number"] { min-width: 145px; }
.invoice-table th[data-column-name="date"], .invoice-table td[data-column-name="date"] { min-width: 230px; }
.invoice-table th[data-column-name="operationDate"], .invoice-table td[data-column-name="operationDate"] { min-width: 195px; }
.invoice-table th[data-column-name="createdAt"], .invoice-table td[data-column-name="createdAt"], .invoice-table th[data-column-name="modifiedAt"], .invoice-table td[data-column-name="modifiedAt"] { min-width: 165px; }
.invoice-table th[data-column-name="emailSent"], .invoice-table td[data-column-name="emailSent"] { min-width: 110px; text-align: center; }
.invoice-table th[data-column-name="emailSent"] span { width: 22px; height: 22px; display: inline-block; color: var(--teal); }
.invoice-table th[data-column-name="issuer"], .invoice-table td[data-column-name="issuer"], .invoice-table th[data-column-name="issuerNif"], .invoice-table td[data-column-name="issuerNif"], .invoice-table th[data-column-name="clientNif"], .invoice-table td[data-column-name="clientNif"] { min-width: 150px; }
.invoice-table th[data-column-name="issuerName"], .invoice-table td[data-column-name="issuerName"], .invoice-table th[data-column-name="clientName"], .invoice-table td[data-column-name="clientName"], .invoice-table th[data-column-name="client"], .invoice-table td[data-column-name="client"], .invoice-table th[data-column-name="patient"], .invoice-table td[data-column-name="patient"] { min-width: 190px; }
.invoice-table th[data-column-name="template"], .invoice-table td[data-column-name="template"], .invoice-table th[data-column-name="operation"], .invoice-table td[data-column-name="operation"] { min-width: 230px; }
.invoice-table th[data-column-name="concept"], .invoice-table td[data-column-name="concept"] { min-width: 260px; }
.invoice-table th[data-column-name="base"], .invoice-table td[data-column-name="base"], .invoice-table th[data-column-name="irpf"], .invoice-table td[data-column-name="irpf"], .invoice-table th[data-column-name="iva"], .invoice-table td[data-column-name="iva"], .invoice-table th[data-column-name="total"], .invoice-table td[data-column-name="total"] { min-width: 125px; text-align: right; }
.invoice-table th[data-column-name="batch"], .invoice-table td[data-column-name="batch"], .invoice-table th[data-column-name="type"], .invoice-table td[data-column-name="type"], .invoice-table th[data-column-name="rectified"], .invoice-table td[data-column-name="rectified"] { min-width: 145px; }
.invoice-table td[data-column-name="base"], .invoice-table td[data-column-name="irpf"], .invoice-table td[data-column-name="iva"], .invoice-table td[data-column-name="total"] { font-variant-numeric: tabular-nums; }
.email-sent-cell { color: var(--teal); font-size: 17px; font-weight: 800; text-align: center; }
.email-sent-cell svg { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
.history-button { width: 30px; height: 30px; display: grid; place-items: center; margin: auto; padding: 6px; border: 1px solid #9edbd4; border-radius: 7px; color: #0f766e; background: var(--teal-soft); }
.history-button:hover { border-color: #41b9ad; background: #cceeea; }
.history-button--sent { border-color: #9db9f3; color: #2563eb; background: #eff6ff; }
.history-button--sent:hover { border-color: #6e95ed; background: #dbeafe; }
.history-button span { width: 16px; height: 16px; }
.invoice-state { font-weight: 700; }
.state-draft { color: #66758b; }
.state-accepted { color: #087f5b; }
.state-error { color: var(--purple); }
.summary-line { margin: 10px 1px 0; color: var(--muted); font-size: 12px; }
.status-bar { height: 23px; position: fixed; inset: auto 0 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; border-top: 1px solid var(--line); color: var(--muted); background: white; font-size: 11px; }
.status-bar i { width: 10px; height: 10px; border-right: 1px dotted #9aa7b8; transform: rotate(45deg); }

dialog { padding: 0; border: 0; color: var(--ink); background: transparent; }
dialog::backdrop { background: rgba(20, 30, 48, .38); }
.record-dialog { width: min(720px, calc(100vw - 24px)); max-height: min(720px, calc(100vh - 24px)); border-radius: 10px; background: var(--canvas); box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.record-dialog form { height: min(720px, calc(100vh - 24px)); display: flex; flex-direction: column; padding: 22px 24px 20px; }
.record-dialog__heading { flex: 0 0 auto; }
.record-dialog h2, .message-dialog h2, .confirm-dialog h2, .process-dialog h2, .preview-dialog h2, .history-dialog h2, .columns-dialog h2 { margin: 0; color: var(--navy); font-size: 28px; line-height: 1.2; }
.record-dialog__heading p, .message-dialog header p, .columns-dialog header p { margin: 8px 0 16px; color: var(--muted); }
.record-form-card { flex: 1; padding: 20px 22px; overflow: auto; border: 1px solid #dde4ee !important; outline: 0; border-radius: 11px; background: white; scrollbar-color: #bac5d4 #f1f4f8; scrollbar-width: thin; }
.invoice-editor-layout { min-height: 0; flex: 1; display: flex; gap: 6px; overflow: hidden; }
.invoice-editor-layout > .record-form-card { min-width: 0; }
.invoice-dialog--rectification { width: min(1240px, calc(100vw - 24px)); max-height: min(800px, calc(100vh - 24px)); }
.invoice-dialog--rectification form { height: min(800px, calc(100vh - 24px)); }
.rectified-original-panel { min-width: 320px; flex: 1; padding: 20px 22px; overflow: auto; border: 1px solid #d8e0ea; border-radius: 11px; background: #f8fafc; }
.rectified-original-panel h3 { margin: 0; color: var(--navy); font-size: 19px; }
.rectified-original-panel > p { margin: 7px 0 14px; color: var(--muted); }
.rectified-original-panel dl { margin: 0; }
.rectified-original-panel dl div { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(0, 1.2fr); gap: 10px; align-items: start; margin-bottom: 8px; }
.rectified-original-panel dt { padding-top: 7px; font-weight: 600; }
.rectified-original-panel dd { min-width: 0; margin: 0; padding: 6px 8px; overflow-wrap: anywhere; border: 1px solid #d8e0ea; border-radius: 6px; color: #3d4a5f; background: #edf1f6; }
.record-field { min-height: 52px; display: grid; grid-template-columns: 38% 1fr; align-items: center; gap: 24px; margin-bottom: 8px; }
.record-field label { color: var(--ink); font-weight: 600; }
.record-field input, .record-field select, .record-field textarea, .single-field input { width: 100%; min-width: 0; height: 39px; padding: 7px 9px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.record-field input:focus, .record-field select:focus, .record-field textarea:focus { border: 2px solid #21a99d; outline: 0; }
.record-field input[readonly] { color: #526077; background: #e4e8ee; }
.record-field--area { align-items: start; }
.record-field--area label { padding-top: 10px; }
.record-field textarea { height: 78px; resize: vertical; }
.record-field--checkbox > label:empty { min-height: 1px; }
.record-field--checkbox input[type="checkbox"], .checkbox-line input, .check-with-help input, .date-check input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--teal); }
.record-field--checkbox > label:last-child, .checkbox-line, .check-with-help > label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check-with-help, .date-check { display: flex; align-items: center; gap: 9px; }
.help-dot { width: 23px; height: 23px; border: 1px solid #93c5c0; border-radius: 50%; color: #087f75; background: #f1fffd; font-weight: 800; }
.readonly-output { min-height: 39px; display: flex; align-items: center; padding: 7px 9px; border: 1px solid #d7dee8; border-radius: 7px; color: #526077; background: #e9edf3; }
.patient-editor { padding: 0; }
.patient-editor-field { align-items: start; }
.patient-editor-field > label { padding-top: 8px; }
.patient-editor__heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.patient-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 7px; }
.patient-row input { width: 100%; height: 37px; padding: 7px 9px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.patient-row .btn { border: 0; color: #5c6b80; background: transparent; }
.patient-row .btn:hover { color: var(--danger); background: #fff0f2; }
.add-patient-button { min-height: 28px; margin-top: 9px; padding: 0 10px; border-color: #bfdbfe; color: #1d4ed8; background: #eff6ff; font-size: 12px; }
.client-address-reminder-row { min-height: auto; margin-top: -3px; }
.client-address-reminder-row .helper-copy { margin: 0; }
.inline-action-status { display: flex; align-items: center; gap: 10px; }
.inline-action-status small { color: #b26a00; }
.safe-disabled-box { display: flex; align-items: center; gap: 11px; margin: 10px 0 15px; padding: 12px; border: 1px solid #cbd5e1; border-radius: 9px; color: #475569; background: #f8fafc; }
.safe-disabled-box > span { width: 28px; height: 28px; flex: 0 0 auto; color: var(--teal); }
.safe-disabled-box strong, .safe-disabled-box small { display: block; }
.safe-disabled-box small { margin-top: 3px; line-height: 1.4; }
.series-editor { display: grid; grid-template-columns: 1fr 94px 80px; gap: 7px; }
.series-editor select { min-width: 0; }
.helper-copy { margin: 3px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.number-control, .money-input { display: flex; align-items: center; border: 1px solid #cfd8e6; border-radius: 7px; background: white; overflow: hidden; }
.number-control > span { padding-left: 10px; font-weight: 700; }
.number-control input, .money-input input { border: 0; border-radius: 0; background: transparent; }
.money-input span { padding-right: 10px; color: var(--muted); }
.money-input.is-locked { background: #e4e8ee; }
.record-dialog__actions { display: flex; justify-content: flex-end; gap: 7px; flex: 0 0 auto; padding-top: 16px; }
.record-dialog__actions .btn { min-width: 128px; }
.template-record-dialog { width: min(1136px, calc(100vw - 48px)); max-width: none; height: min(842px, calc(100vh - 48px)); max-height: calc(100vh - 48px); margin: max(24px, calc((100vh - 878px) / 2)) auto auto; overflow: hidden; border-radius: 10px; color: #071d3d; background: #f2f5fa; box-shadow: 0 24px 48px rgba(10, 18, 31, .36); }
.template-record-dialog:focus { outline: 0; }
.template-record-dialog::backdrop { background: rgba(10, 20, 36, .08); }
.template-record-dialog form { width: 100%; height: 100%; min-height: 0; padding: 0; overflow: hidden; }
.template-window-bar { height: 38px; display: flex; flex: 0 0 38px; align-items: center; gap: 7px; padding-left: 9px; color: white; background: #2d1d1d; font-size: 14px; }
.template-window-icon { width: 18px; height: 18px; display: grid; place-items: center; color: #00a899; background: #07162a; font-size: 9px; font-weight: 800; }
.template-window-bar > span:nth-child(2) { flex: 1; }
.template-window-bar button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; color: white; background: transparent; font-size: 25px; font-weight: 200; line-height: 1; }
.template-window-bar button:hover { background: #c42b3b; }
.template-dialog-content { min-height: 0; flex: 1; display: flex; flex-direction: column; padding: 33px 30px 23px; overflow-y: auto; scrollbar-color: #bac5d4 #eef2f7; scrollbar-width: thin; }
.template-record-dialog h2 { font-size: 36px; line-height: 1.1; letter-spacing: -.45px; }
.template-upload-intro { min-height: 54px; display: flex; align-items: center; margin-top: 22px; padding: 12px 20px; border-color: #9ee6dc; border-radius: 11px; color: #075a5d; background: #e4f7f5; font-size: 17px; line-height: 1.45; }
.template-upload-file { margin-top: 23px; }
.template-upload-file h3 { margin: 0 0 20px; color: #071d3d; font-size: 22px; line-height: 1.2; }
.template-file-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; }
.template-file-picker input,
.template-upload-row > select,
.template-upload-dual select,
.template-upload-percent { width: 100%; min-width: 0; height: 47px; border: 1px solid #c5d4e8; border-radius: 9px; color: #102a50; background: white; font-size: 16px; }
.template-file-picker input { padding: 9px 14px; color: #536d92; }
.template-file-picker input::placeholder { color: #71839e; opacity: 1; }
.template-file-picker .btn { min-width: 158px; min-height: 47px; padding: 0 18px; border-radius: 9px; color: #071d3d; font-size: 16px; font-weight: 650; }
.template-upload-file .helper-copy { margin: 21px 0 0; color: #5b74a0; font-size: 14px; line-height: 1.45; }
.template-upload-settings { display: grid; gap: 20px; margin-top: 23px; }
.template-upload-row { min-height: 47px; display: grid; grid-template-columns: 335px minmax(0, 1fr); align-items: center; gap: 18px; }
.template-upload-row > label { color: #071d3d; font-size: 16px; }
.template-upload-row > select,
.template-upload-dual select { padding: 8px 11px; }
.template-upload-dual { min-width: 0; display: grid; grid-template-columns: 215px minmax(0, 1fr); gap: 12px; }
.template-upload-percent { position: relative; display: flex; align-items: center; overflow: hidden; }
.template-upload-percent input { width: 100%; height: 45px; padding: 8px 48px 8px 13px; border: 0; outline: 0; color: #071d3d; background: transparent; font-size: 16px; }
.template-upload-percent span { position: absolute; left: 55px; color: #071d3d; pointer-events: none; }
.template-upload-percent::after { content: "⌃\A⌄"; position: absolute; top: 50%; right: 7px; color: #526077; font-size: 11px; line-height: 9px; white-space: pre; pointer-events: none; transform: translateY(-50%); }
.template-upload-percent:focus-within,
.template-file-picker input:focus,
.template-upload-row > select:focus,
.template-upload-dual select:focus { border-color: #21a99d; outline: 1px solid #21a99d; }
.template-series-help { margin: 25px 0 0; color: #5b74a0; font-size: 14px; line-height: 1.45; }
.template-record-dialog .record-dialog__actions { margin-top: auto; padding-top: 19px; }
.template-record-dialog .record-dialog__actions .btn { min-width: 152px; min-height: 48px; border-radius: 9px; font-size: 16px; }
.dialog-shell { height: min(700px, calc(100vh - 24px)); display: flex; flex-direction: column; padding: 22px 24px 20px; }
.requirements-dialog { width: min(760px, calc(100vw - 24px)); }
.requirements-intro { margin-top: 12px; color: #245c58; line-height: 1.45; }
.requirements-copy { min-height: 0; flex: 1; margin-top: 14px; padding: 18px 21px; overflow: auto; border: 1px solid var(--line); outline: 0; border-radius: 10px; background: white; scrollbar-color: #bac5d4 #f1f4f8; scrollbar-width: thin; }
.requirements-copy .requirements-lead { display: block; margin-bottom: 10px; color: var(--navy); }
.requirements-copy h3 { margin: 14px 0 8px; color: var(--navy); font-size: 15px; }
.requirements-copy p, .requirements-copy ul { margin: 0 0 12px; }
.requirements-copy ul { padding-left: 22px; }
.requirements-copy p, .requirements-copy li { color: #526077; line-height: 1.55; }
.requirements-copy strong { color: var(--navy); }
.requirements-copy em { color: #173b6b; }
.template-fields-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; border-radius: 0; background: var(--canvas); box-shadow: none; }
.template-fields-dialog::backdrop { background: transparent; }
.template-fields-dialog form { width: 100%; height: 100vh; min-height: 100vh; display: block; overflow-y: auto; padding: 12px 16px 14px 14px; scrollbar-width: none; }
.template-fields-dialog form::-webkit-scrollbar { display: none; }
.template-fields-dialog .record-dialog__heading p { margin: 15px 0 12px; color: #5d7190; line-height: 1.35; }
.template-fields-identity { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; padding: 13px 18px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.template-fields-identity__field { min-width: 0; }
.template-fields-identity__field label { display: block; margin-bottom: 7px; color: var(--navy); font-size: 14px; font-weight: 650; }
.template-fields-identity__field input { width: 100%; height: 38px; padding: 7px 11px; overflow: hidden; border: 1px solid #cbd8e8; border-radius: 7px; color: #536d92; background: #f4f7fb; text-overflow: ellipsis; white-space: nowrap; }
.template-tax-strip { border: 1px solid var(--line); border-radius: 9px; background: white; }
.template-fields-settings { display: grid; grid-template-columns: 1fr; gap: 5px; margin-bottom: 14px; padding: 12px 20px 12px 17px; }
.template-fields-row { min-height: 38px; display: grid; grid-template-columns: 254px minmax(0, 1fr); align-items: center; gap: 18px; }
.template-fields-row--irpf { min-height: 40px; }
.template-fields-row > label { display: block; color: #173b6b; font-size: 13px; font-weight: 400; }
.template-fields-row > select, .template-fields-row input, .template-fields-row select { min-width: 0; height: 38px; padding: 7px 9px; border: 1px solid #cbd8e8; border-radius: 7px; color: #173b6b; background: white; }
.template-fields-row--irpf input { height: 40px; }
.template-percent-control { position: relative; min-width: 0; }
.template-percent-control input { width: 100%; padding-right: 42px; }
.template-percent-control span { position: absolute; top: 50%; left: 43px; color: #173b6b; pointer-events: none; transform: translateY(-50%); }
.template-percent-control::after { content: "⌃\A⌄"; position: absolute; top: 50%; right: 6px; color: #526077; font-size: 10px; line-height: 8px; white-space: pre; pointer-events: none; transform: translateY(-50%); }
.template-fields-dual { min-width: 0; display: grid; grid-template-columns: .78fr 1fr; gap: 10px; }
.template-fields-dual select { width: 100%; }
.tax-type-popover { width: min(1200px, calc(100vw - 24px)); max-height: min(270px, calc(100vh - 24px)); position: fixed; z-index: 300; overflow: auto; border: 1px solid #b7c5d8; background: white; box-shadow: 0 4px 8px rgba(23,32,51,.2); }
.tax-type-popover--template { width: min(1076px, calc(100vw - 72px)); }
.tax-type-popover table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; color: #173b6b; }
.tax-type-popover th { height: 43px; padding: 10px 12px; border-right: 1px solid #d5dde8; border-bottom: 1px solid #c4d0df; color: #29466d; background: #eef2f7; font-weight: 400; text-align: center; }
.tax-type-popover th:nth-child(1) { width: 16%; }
.tax-type-popover th:nth-child(2) { width: 9%; }
.tax-type-popover td { height: 54px; padding: 10px 12px; overflow-wrap: anywhere; border-right: 1px solid #d7dee8; border-bottom: 1px solid #d7dee8; color: #173b6b; background: white; white-space: normal; }
.tax-type-popover tr { cursor: pointer; }
.tax-type-popover tbody tr:hover, .tax-type-popover tbody tr:focus { outline: 0; background: #43b6ad; }
.tax-type-popover tbody tr:hover td, .tax-type-popover tbody tr:focus td { background: #43b6ad; }
.template-series-control { min-width: 0; height: 38px; display: grid; grid-template-columns: 45px 8px max-content 35px 1fr; align-items: center; border: 1px solid #cbd8e8; border-radius: 7px; color: #173b6b; background: white; overflow: hidden; }
.template-series-control input, .template-series-control select { width: 100%; height: 36px; padding: 7px 9px; border: 0; border-radius: 0; color: #173b6b; background: transparent; }
.template-series-control input:first-child { padding-right: 0; }
.template-series-control select { padding: 0; appearance: none; text-align: left; }
.template-series-control span { white-space: nowrap; }
.template-series-control input:last-child { padding: 7px 5px 7px 2px; text-align: left; }
.template-series-control select:first-child { padding-left: 8px; }
.template-series-control option:disabled { color: #9aa7b8; }
.template-fields-table { min-height: 250px; overflow: auto; }
.template-fields-table:has(.template-field-add-menu[open]) { overflow: visible; }
.template-fields-table table { min-width: 760px; }
.template-fields-table td:nth-child(1) { width: 26%; font-weight: 650; }
.template-field-editor { min-height: 42px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.template-field-segment { min-width: 0; display: inline-flex; align-items: center; gap: 2px; padding: 2px 3px 2px 7px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.template-field-segment input, .template-field-segment select { height: 30px; padding: 4px 5px; border: 0; border-radius: 4px; color: #173b6b; background: transparent; }
.template-field-segment[data-segment-kind="data"] select { width: min(300px, 32vw); }
.template-field-segment[data-segment-kind="text"] input { width: min(180px, 22vw); }
.template-field-segment-remove { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; color: #69809d; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; }
.template-field-segment-remove:hover { color: #a33b47; background: #fbeaec; }
.template-field-editor option[data-required="true"] { color: #087f5b; font-weight: 700; }
.template-field-editor option[data-emphasis="true"] { color: #173b6b; font-weight: 700; }
.template-field-add-menu { margin: 0; }
.template-field-add-menu > div { min-width: 165px; }
.template-field-add-menu > div button { white-space: nowrap; }
.field-validation-summary { margin-top: 9px; font-size: 12px; }
.field-validation-summary.is-error { border-color: #fecaca; color: #991b1b; background: #fef2f2; }
.series-dialog { width: min(720px, calc(100vw - 24px)); }
.series-dialog form { height: min(700px, calc(100vh - 24px)); }
.series-dialog__info { margin: 2px 0 16px; color: #24645f; background: var(--teal-soft); }
.series-dialog__card { min-height: 210px; }
.series-dialog .help-dot { width: 22px; height: 22px; padding: 0; vertical-align: middle; }
.series-help-popup { width: min(620px, calc(100vw - 24px)); position: fixed; z-index: 500; padding: 18px 20px 14px; border: 2px solid #20b7aa; border-radius: 11px; color: var(--ink); background: white; box-shadow: 0 16px 38px rgba(23, 32, 51, .22); }
.series-help-popup header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.series-help-popup h3 { margin: 0; color: var(--navy); font-size: 21px; line-height: 1.25; }
.series-help-popup header button { width: 30px; height: 30px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 6px; color: #526077; background: transparent; font-size: 24px; line-height: 1; }
.series-help-popup header button:hover { color: var(--navy); background: #edf2f7; }
.series-help-popup__body { max-height: min(430px, calc(100vh - 190px)); padding: 13px 16px; overflow-y: auto; border: 1px solid #d7e2ec; border-radius: 9px; background: #fbfdff; scrollbar-color: #afbdd0 #eef2f7; scrollbar-width: thin; }
.series-help-popup__body p { margin: 0 0 13px; color: #14233d; line-height: 1.48; }
.series-help-popup__body p:last-child { margin-bottom: 0; }
.excel-dialog { width: min(860px, calc(100vw - 24px)); }
.file-picker-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 14px 0; }
.file-picker-row input { height: 39px; padding: 7px 9px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 11px 0; }
.import-preview { min-height: 90px; max-height: 180px; margin-top: 12px; padding: 12px 14px; overflow: auto; border: 1px solid #d7dee8; border-radius: 9px; color: #526077; background: #f8fafc; font-size: 12px; line-height: 1.5; }
.import-preview.is-error { border-color: #fecaca; color: #991b1b; background: #fff7f7; }
.import-options-card { max-height: 280px; margin-top: 12px; }
.configuration-dialog { width: calc(100vw - 80px); max-width: none; max-height: min(650px, calc(100vh - 80px)); }
.configuration-dialog form { height: min(650px, calc(100vh - 80px)); padding: 22px 24px 20px; }
.configuration-dialog h2 { font-size: 34px; }
.configuration-dialog .record-dialog__heading p { margin-top: 12px; margin-bottom: 18px; font-size: 16px; }
.configuration-scroll { flex: 1; overflow: auto; padding-right: 8px; outline: 0; scrollbar-color: #b7c3d3 #eef2f7; scrollbar-width: thin; }
.dialog-section { margin-bottom: 15px; padding: 18px 20px 20px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.dialog-section h3 { margin: 0; color: var(--navy); font-size: 20px; }
.dialog-section > p { margin: 10px 0 15px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.configuration-form-rows { display: grid; gap: 12px; padding: 8px 20px; }
.configuration-form-rows label { display: grid; grid-template-columns: 190px minmax(0, 1fr); align-items: center; gap: 18px; font-weight: 600; }
.configuration-form-rows input { width: 100%; height: 38px; padding: 7px 9px; border: 1px solid #c3ccd8; border-radius: 7px; color: #667286; background: #e4e8ee; }
.demo-safety-note { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; color: #475569; background: #f8fafc; }
.demo-safety-note > span:first-child { width: 25px; height: 25px; flex: 0 0 auto; color: var(--teal); }
.demo-safety-note strong, .demo-safety-note small { display: block; }
.demo-safety-note small { margin-top: 2px; color: var(--muted); line-height: 1.4; }
.configuration-grid { display: grid; grid-template-columns: 1fr; gap: 24px; padding: 18px 20px 14px; }
.configuration-grid label, .wide-setting { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 12px; color: #435168; font-weight: 600; }
.configuration-grid input, .wide-setting input { height: 37px; padding: 7px 9px; border: 1px solid #cfd8e6; border-radius: 7px; }
.payment-column-setting { grid-template-columns: 185px minmax(0, 1fr) !important; align-items: start !important; gap: 16px !important; color: var(--ink) !important; font-size: 15px; font-weight: 400 !important; }
.payment-column-setting > span:first-child { padding-top: 11px; }
.payment-column-setting > span:last-child { display: grid; gap: 5px; }
.payment-column-setting input { width: 100%; height: 44px; color: var(--ink); background: white; font-size: 14px; }
.payment-column-setting small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.4; }
.concept-configuration { background: white; }
.configuration-subcard { margin-top: 16px; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.configuration-subcard h4 { margin: 0; color: var(--navy); font-size: 16px; }
.configuration-subcard > p { margin: 11px 0 13px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.default-concept-layout { display: grid; grid-template-columns: minmax(0, 1fr) 235px; gap: 16px; align-items: stretch; }
.concept-editor-area > label { display: block; margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.concept-editor-with-add { display: flex; align-items: center; gap: 8px; }
.concept-editor-with-add .payment-concept-editor { width: fit-content; max-width: calc(100% - 50px); flex: 0 1 auto; border: 0; padding: 0; background: transparent; }
.concept-add-menu { width: 42px; height: 42px; position: relative; flex: 0 0 auto; }
.concept-add-menu summary { width: 42px; height: 42px; display: grid; place-items: center; border: 3px solid #cff9f1; border-radius: 50%; color: white; background: linear-gradient(145deg, #19c4a4, #007f75); box-shadow: 0 3px 14px rgba(5,116,104,.28); cursor: pointer; font-size: 25px; font-weight: 700; line-height: 1; list-style: none; }
.concept-add-menu summary::-webkit-details-marker { display: none; }
.concept-add-menu[open] summary { transform: translateY(1px); }
.concept-add-menu > div { min-width: 210px; position: absolute; left: 0; top: 48px; z-index: 20; display: grid; gap: 2px; padding: 6px; border: 1px solid #cfd8e6; border-radius: 8px; background: white; box-shadow: 0 10px 26px rgba(23,32,51,.16); }
.concept-add-menu > div button { min-height: 31px; padding: 5px 9px; border: 0; border-radius: 5px; background: white; text-align: left; }
.concept-add-menu > div button:hover { color: #087f75; background: #dff5f2; }
.concept-add-menu > div strong { padding: 6px 9px 3px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.concept-preview { min-height: 92px; display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid #d8e0ea; border-radius: 7px; background: white; }
.concept-preview span { color: #526077; font-size: 12px; }
.concept-preview strong { margin: 6px 0; overflow-wrap: anywhere; color: var(--teal); font-size: 14px; }
.special-concept-empty { min-height: 105px; display: grid; place-items: center; padding: 16px; border: 1px dashed #b9c5d5; border-radius: 8px; color: var(--muted); background: white; font-size: 14px; line-height: 1.55; text-align: center; }
.special-concept-actions { display: flex; gap: 8px; margin-top: 10px; }
.concept-help { display: block; margin-top: 9px; color: var(--muted); line-height: 1.4; }
.wide-setting { grid-template-columns: 220px 1fr; margin-bottom: 12px; }
.concept-default-setting { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 12px; margin: 2px 0 9px; color: #435168; font-weight: 600; }
.concept-default-setting > span { padding-top: 9px; }
.payment-concept-editor { display: flex; min-height: 42px; flex-wrap: wrap; align-items: center; gap: 6px; padding: 5px; border: 1px solid #d8e0ea; border-radius: 7px; background: #f8fafc; }
.payment-concept-segment { display: flex; align-items: center; gap: 2px; min-width: 0; padding: 2px 3px 2px 7px; border: 1px solid #d8e0ea; border-radius: 6px; background: white; }
.payment-concept-segment input, .payment-concept-segment select { width: min(230px, 42vw); min-width: 110px; height: 31px; padding: 5px 6px; border: 0; border-radius: 4px; color: var(--ink); background: transparent; }
.payment-concept-segment select { min-width: 205px; }
#setting-default-concept-editor .payment-concept-segment { min-height: 52px; padding: 6px 7px 6px 13px; background: #f8fafc; }
#setting-default-concept-editor .payment-concept-segment[data-segment-kind="text"] input { width: 145px; }
#setting-default-concept-editor .payment-concept-segment[data-segment-kind="data"] select { width: 290px; }
.payment-concept-segment input:focus, .payment-concept-segment select:focus { outline: 2px solid #21a99d; outline-offset: 1px; }
.payment-concept-segment button { width: 25px; height: 25px; padding: 0; border: 0; border-radius: 4px; color: #64748b; background: transparent; font-size: 19px; line-height: 1; }
.payment-concept-segment button:hover { color: #991b1b; background: #fee2e2; }
.concept-editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 12px 232px; }
.concept-editor-actions .btn { min-height: 31px; }
.concept-editor-actions small { flex: 1 1 240px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.concept-rules-table { max-height: 230px; margin-bottom: 0; overflow: auto; }
.concept-rules-table:has(.concept-add-menu[open]) { overflow: visible; }
.concept-rules-table table { min-width: 690px; }
.concept-rules-table .concept-rule-name { width: 100%; height: 35px; padding: 6px 8px; border: 1px solid #cfd8e6; border-radius: 6px; }
.concept-rules-table tr { cursor: pointer; }
.concept-rules-table tr.is-selected td { background: #ecf9f7; }
.concept-rules-table td:first-child { width: 245px; }
.concept-rules-table td:nth-child(2) { min-width: 420px; }
.concept-rules-table .payment-concept-editor { min-width: 340px; background: white; }
.concept-rule-remove { min-width: 32px; padding: 0 7px; }
.concept-rule-editor-wrap { display: flex; align-items: center; gap: 8px; }
.concept-rule-editor-wrap .payment-concept-editor { flex: 1; }
.concept-rule-editor-wrap .payment-concept-editor:empty { display: none; }
.concept-rule-editor-wrap .concept-add-menu { width: 38px; height: 38px; }
.concept-rule-editor-wrap .concept-add-menu summary { width: 38px; height: 38px; font-size: 22px; }
.concept-rule-editor-wrap .concept-add-menu > div { left: 0; right: auto; }
.email-dialog { width: min(700px, calc(100vw - 24px)); }
.email-dialog form { height: auto; min-height: 540px; }
.email-dialog-body { flex: 1; padding: 18px 20px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.email-provider-panel { margin-top: 8px; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.email-provider-panel > p { margin: 0 0 13px; color: var(--muted); line-height: 1.5; }
.email-connection-status { margin-bottom: 12px; padding: 10px 12px; border-radius: 7px; color: #b26a00; background: #fff8e8; font-weight: 700; }
.correction-dialog { width: min(1120px, calc(100vw - 24px)); max-height: min(760px, calc(100vh - 24px)); }
.correction-dialog form { height: min(760px, calc(100vh - 24px)); }
.correction-scroll { flex: 1; overflow: auto; padding-right: 7px; }
.correction-original-card, .locked-invoice-card { margin-bottom: 13px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.correction-original-card dl { margin: 0; }
.correction-original-card dl div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; margin-bottom: 7px; }
.correction-original-card dl div:last-child { margin-bottom: 0; }
.correction-original-card dt { font-weight: 600; }
.correction-original-card dd { margin: 0; overflow-wrap: anywhere; }
.correction-explanation { margin-bottom: 13px; line-height: 1.45; }
.locked-invoice-card h3, .comparison-heading { margin: 0 0 12px; color: var(--navy); font-size: 18px; }
.locked-invoice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; }
.locked-invoice-grid div { display: grid; grid-template-columns: minmax(125px, .8fr) minmax(0, 1.2fr); align-items: center; gap: 8px; }
.locked-invoice-grid span { font-weight: 600; }
.locked-invoice-grid output { min-height: 36px; padding: 7px 8px; overflow-wrap: anywhere; border: 1px solid #c3ccd8; border-radius: 6px; color: #667286; background: #e4e8ee; }
.correction-comparison { min-height: auto; overflow: auto; }
.correction-comparison table { min-width: 760px; }
.correction-comparison td { white-space: normal; }
.correction-comparison select { width: 100%; min-width: 250px; height: 38px; padding: 6px 8px; border: 2px solid #21a99d; border-radius: 7px; background: white; }
.cancellation-dialog { width: min(820px, calc(100vw - 24px)); }
.cancellation-dialog form { height: auto; min-height: 500px; }
.cancellation-explanation { padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; background: white; line-height: 1.5; }
.cancellation-explanation p:first-child { margin-top: 0; }
.cancellation-explanation p:last-child { margin-bottom: 0; }
.rectification-notice { margin-top: 15px; }
.history-page .info-box { margin-bottom: 0; }
.history-table-card table { min-width: 980px; }

.message-dialog, .confirm-dialog, .process-dialog, .columns-dialog { width: min(520px, calc(100vw - 24px)); padding: 24px; border-radius: 12px; background: var(--canvas); box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.message-dialog h2, .confirm-dialog h2, .process-dialog h2, .columns-dialog h2 { font-size: 23px; }
.message-dialog form > header p, .message-dialog header #help-dialog-copy, .confirm-dialog > p, .process-dialog p { color: var(--muted); line-height: 1.5; }
.message-dialog header #help-dialog-copy { max-height: min(560px, 62vh); margin-top: 12px; overflow: auto; }
.message-dialog header #help-dialog-copy p { margin: 0 0 12px; }
.message-dialog header #help-dialog-copy p:last-child { margin-bottom: 0; }
.message-dialog header #help-dialog-copy ul { margin: 0 0 12px; padding-left: 22px; }
.message-dialog footer, .confirm-dialog footer, .preview-dialog footer, .columns-dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.info-box { padding: 11px 13px; border: 1px solid #b8e9e2; border-radius: 9px; color: #245c58; background: var(--teal-soft); }
.date-filter-dialog { width: min(470px, calc(100vw - 24px)); padding: 0; border-radius: 10px; background: var(--canvas); box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.date-filter-dialog form { padding: 20px; }
.date-filter-dialog h2 { margin: 0 0 18px; color: var(--navy); font-size: 18px; }
.date-filter-dialog h3 { margin: 0 0 22px; color: var(--navy); font-size: 20px; }
.date-filter-dialog .info-box { margin-bottom: 14px; line-height: 1.45; }
.date-filter-limits { display: grid; gap: 12px; }
.date-filter-limits label { display: grid; grid-template-columns: 24px 130px minmax(0, 1fr); align-items: center; gap: 8px; }
.date-filter-limits input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--teal); }
.date-filter-limits input[type="date"] { width: 100%; height: 40px; padding: 6px 10px; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.date-filter-limits input[type="date"]:disabled { color: #8a96a8; background: #edf1f6; }
.date-filter-dialog footer { display: flex; align-items: center; gap: 7px; margin-top: 14px; }
.date-filter-dialog footer span { flex: 1; }
.date-filter-dialog footer .btn { min-width: 120px; }
.single-field { display: block; margin-top: 17px; font-weight: 600; }
.single-field input { display: block; margin-top: 8px; font-weight: 400; }
.confirm-dialog { text-align: center; background: white; }
.confirm-dialog__icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 15px; padding: 13px; border-radius: 14px; color: #1e40af; background: #dbeafe; }
.demo-warning { display: flex; align-items: center; gap: 11px; margin: 16px 0; padding: 12px; border: 1px solid #9edbd4; border-radius: 9px; color: #245c58; background: #f2fbf9; text-align: left; }
.demo-warning > span { width: 28px; height: 28px; flex: 0 0 auto; }
.demo-warning strong, .demo-warning small { display: block; }
.demo-warning small { margin-top: 3px; color: #52726d; line-height: 1.35; }
.confirm-summary { padding: 11px; border-radius: 8px; background: var(--canvas); }
.confirm-summary span, .confirm-summary strong { display: block; }
.confirm-summary span { color: var(--muted); font-size: 11px; }
.confirm-summary strong { margin-top: 5px; }
.process-dialog { background: white; text-align: center; }
.spinner { width: 82px; height: 82px; display: grid; place-items: center; margin: 0 auto 20px; border: 2px solid #cceeea; border-top-color: var(--teal); border-radius: 50%; animation: spin 1.25s linear infinite; }
.spinner span { width: 39px; height: 39px; padding: 8px; border-radius: 10px; color: white; background: var(--teal); animation: anti-spin 1.25s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes anti-spin { to { transform: rotate(-360deg); } }
.process-kicker { color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.progress { height: 6px; margin: 22px 0 16px; overflow: hidden; border-radius: 4px; background: #e5e9ef; }
.progress i { width: 14%; height: 100%; display: block; border-radius: 4px; background: var(--teal); transition: width .65s ease; }
.process-steps { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; color: var(--muted); font-size: 12px; list-style: none; text-align: left; }
.process-steps .is-done { color: #087f5b; font-weight: 700; }
.success-state { animation: success-in .22s ease; }
@keyframes success-in { from { opacity: 0; transform: scale(.98); } }
.success-icon { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 17px; padding: 14px; border-radius: 50%; color: white; background: var(--teal); box-shadow: 0 0 0 9px var(--teal-soft); }
.success-state h2 { margin-top: 7px; }
.success-data { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 17px 0 4px; }
.success-data div { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); }
.success-data span, .success-data strong { display: block; }
.success-data span { color: var(--muted); font-size: 10px; }
.success-data strong { margin-top: 5px; }
.state-text { color: #087f5b; }

.preview-dialog { width: min(830px, calc(100vw - 24px)); padding: 20px; border-radius: 12px; background: var(--canvas); box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.preview-dialog > header, .history-dialog > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.preview-dialog h2, .history-dialog h2 { font-size: 22px; }
.preview-dialog header p, .history-dialog header p { margin: 5px 0 0; color: var(--muted); }
.dialog-x { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; color: var(--muted); background: #e9eef5; font-size: 20px; }
.draft-warning { margin: 15px 0 10px; padding: 7px 11px; border: 1px solid #fecaca; border-radius: 7px; color: #991b1b; background: #fef2f2; font-weight: 700; }
.pdf-viewport { height: 510px; display: grid; place-items: center; overflow: auto; border: 1px solid #c7d0dc; border-radius: 7px; background: #dce2ea; }
.invoice-paper { width: 380px; height: 480px; position: relative; padding: 32px; overflow: hidden; color: #374151; background: white; box-shadow: 0 8px 25px rgba(23,32,51,.18); }
.paper-head { display: flex; justify-content: space-between; padding-bottom: 20px; border-bottom: 2px solid var(--navy); color: var(--navy); font-size: 17px; }
.paper-meta { display: flex; justify-content: space-between; margin-top: 28px; font-size: 11px; }
.paper-meta b { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.paper-meta i { font-style: normal; }
.paper-line { display: flex; justify-content: space-between; margin-top: 50px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 11px; }
.paper-total { display: flex; align-items: baseline; justify-content: flex-end; gap: 24px; margin-top: 22px; }
.paper-total strong { font-size: 20px; }
.watermark { position: absolute; left: 27px; top: 210px; padding: 10px 28px; border: 5px solid rgba(153,27,27,.18); color: rgba(153,27,27,.2); font-size: 32px; font-weight: 800; text-align: center; transform: rotate(-27deg); }
.watermark small { font-size: 15px; }

.history-dialog { width: min(1000px, calc(100vw - 24px)); padding: 24px; border-radius: 12px; background: var(--canvas); box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.history-dialog header .back-button { display: block; margin: 0 0 7px -8px; }
.history-dialog .info-box { margin: 16px 0; }
.history-table-wrap { min-height: 240px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: white; }
.history-table-wrap table { min-width: 800px; }
.column-list { display: flex; flex-direction: column; gap: 5px; max-height: 330px; margin-top: 16px; padding: 6px; overflow: auto; border: 1px solid #cfd8e6; border-radius: 7px; background: white; }
.column-list label { min-height: 34px; display: flex; align-items: center; gap: 9px; padding: 3px 8px; border-radius: 5px; }
.column-list label:nth-child(even) { background: #f4f7fb; }
.column-list label:hover { background: #eaf7f5; }
.column-list label > span:nth-of-type(1) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-list label > button { width: 27px; height: 27px; border: 1px solid #cfd8e6; border-radius: 5px; color: #526077; background: white; }
.columns-dialog footer > span { flex: 1; }
.storage-dialog { width: min(540px, calc(100vw - 24px)); padding: 24px; border-radius: 12px; background: white; box-shadow: 0 22px 64px rgba(23,32,51,.23); }
.storage-dialog > header { display: flex; align-items: center; gap: 13px; }
.storage-dialog h2 { margin: 0; color: var(--navy); font-size: 22px; }
.storage-dialog header p { margin: 5px 0 0; color: var(--muted); }
.storage-icon { width: 44px; height: 44px; flex: 0 0 auto; padding: 10px; border-radius: 11px; color: var(--teal); background: var(--teal-soft); }
.storage-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 20px 0 4px; }
.storage-stats div { padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--canvas); }
.storage-stats span, .storage-stats strong { display: block; }
.storage-stats span { color: var(--muted); font-size: 11px; }
.storage-stats strong { margin-top: 5px; color: var(--navy); font-size: 22px; }
.storage-dialog footer { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.storage-dialog footer > span { flex: 1; }

.toast { min-width: 310px; position: fixed; right: 22px; bottom: 38px; z-index: 200; display: flex; align-items: center; gap: 11px; padding: 13px 15px; border: 1px solid #9edbd4; border-radius: 9px; background: white; box-shadow: 0 12px 36px rgba(23,32,51,.16); animation: toast-in .18s ease; }
.toast > span { width: 28px; height: 28px; padding: 6px; border-radius: 50%; color: white; background: var(--teal); }
.toast strong, .toast small { display: block; }
.toast small { margin-top: 3px; color: var(--muted); }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 1120px) {
  .page { padding-left: 24px; padding-right: 24px; }
  .invoice-toolbar { padding-bottom: 4px; }
  .aeat-action-bar { flex-wrap: wrap; }
  .aeat-copy { width: 100%; flex-basis: 100%; }
}
@media (max-width: 700px) {
  .top-bar { padding: 9px 16px; }
  .brand-logo { width: 168px; height: 38px; flex-basis: 168px; }
  .database-name { display: none; }
  .local-data-button { width: 34px; padding: 8px; overflow: hidden; color: transparent; gap: 0; }
  .demo-mode { max-width: 145px; text-align: center; }
  .page { padding: 22px 16px; }
  .dashboard-heading, .page-heading { align-items: flex-start; }
  .dashboard-heading { flex-direction: column; }
  .dashboard-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .dashboard-card { min-height: 165px; }
  .page-heading { gap: 8px; }
  .page-heading h1 { font-size: 23px; }
  .page-heading p { font-size: 12px; }
  .aeat-action-bar > .btn { flex: 1; }
  .record-field { grid-template-columns: 1fr; gap: 5px; }
  .record-field--area label { padding-top: 0; }
  .record-dialog form { padding: 18px 15px; }
  .record-dialog h2 { font-size: 23px; }
  .configuration-dialog { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
  .configuration-dialog form { height: calc(100vh - 24px); }
  .configuration-grid { padding: 10px 0 4px; }
  .concept-editor-with-add { align-items: flex-start; flex-wrap: wrap; }
  .concept-editor-with-add .payment-concept-editor { width: 100%; max-width: 100%; }
  .pdf-viewport { height: 430px; }
  .invoice-paper { transform: scale(.86); }
  .storage-stats { grid-template-columns: 1fr; }
  .patient-row, .configuration-grid, .template-tax-strip, .template-fields-identity, .default-concept-layout, .locked-invoice-grid { grid-template-columns: 1fr; }
  .template-fields-row { grid-template-columns: 1fr; gap: 4px; }
  .template-fields-dual { grid-template-columns: 1fr; gap: 5px; }
  .template-fields-settings { gap: 10px; }
  .template-series-control { grid-template-columns: minmax(100px, 1fr) 22px max-content 35px 1fr; }
  .template-field-segment[data-segment-kind="data"] select { width: min(270px, 70vw); }
  .template-field-segment[data-segment-kind="text"] input { width: min(180px, 58vw); }
  .payment-column-setting, .concept-default-setting { grid-template-columns: 1fr !important; gap: 5px; }
  .configuration-form-rows label, .correction-original-card dl div { grid-template-columns: 1fr; gap: 4px; }
  .invoice-editor-layout { overflow: auto; }
  .invoice-dialog--rectification .invoice-editor-layout { flex-direction: column; }
  .rectified-original-panel { min-width: 0; }
  .concept-default-setting > span { padding-top: 0; }
  .concept-editor-actions { margin-left: 0; }
  .payment-concept-segment input, .payment-concept-segment select { width: min(240px, 58vw); }
  #setting-default-concept-editor .payment-concept-segment[data-segment-kind="text"] input,
  #setting-default-concept-editor .payment-concept-segment[data-segment-kind="data"] select { width: min(220px, 54vw); }
  .special-concept-actions { flex-wrap: wrap; }
  .series-editor { grid-template-columns: 1fr 80px 70px; }
  .template-record-dialog form { padding: 0; }
  .template-dialog-content { padding: 24px 16px 16px; }
  .template-record-dialog h2 { font-size: 29px; }
  .template-upload-intro { margin-top: 17px; font-size: 15px; }
  .template-upload-file h3 { margin-bottom: 12px; font-size: 20px; }
  .template-file-picker { grid-template-columns: 1fr; gap: 8px; }
  .template-file-picker .btn { width: 100%; }
  .template-upload-settings { gap: 14px; }
  .template-upload-row { grid-template-columns: 1fr; gap: 6px; }
  .template-upload-dual { grid-template-columns: 1fr; gap: 8px; }
  .template-series-help { margin-top: 18px; }
  .template-record-dialog .record-dialog__actions { flex-wrap: wrap; }
  .template-record-dialog .record-dialog__actions .btn { min-width: 120px; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
