:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #676767;
  --gold: #e4c24d;
  --gold-deep: #b89325;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #e5e1d6;
  --green: #21734b;
  --red: #b42318;
  --shadow: 0 14px 36px rgba(25, 24, 19, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
button, input, select, textarea { outline-color: var(--gold-deep); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(205, 169, 47, .38); outline-offset: 2px; }
button:focus:not(:focus-visible), input:focus:not(:focus-visible), select:focus:not(:focus-visible), textarea:focus:not(:focus-visible) { outline: none; }
a { color: inherit; }

/* Sign-in */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(350px, 470px); background: #111; }
.login-brand { padding: clamp(26px, 5vw, 72px); display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: radial-gradient(ellipse at 20% 15%, #343022 0, #151515 48%, #090909 100%); }
.brand-top { display: flex; align-items: center; gap: 18px; }
.brand-top img { width: 80px; height: 80px; object-fit: contain; }
.brand-top h1 { margin: 0; font-size: clamp(20px, 2vw, 28px); letter-spacing: .03em; }
.brand-top p { margin: 5px 0 0; color: #d8c579; font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }
.brand-message { max-width: 620px; margin: 70px 0; }
.brand-message .eyebrow { color: var(--gold); font-weight: 750; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }
.brand-message h2 { font-size: clamp(33px, 5vw, 60px); line-height: 1.05; margin: 16px 0; letter-spacing: -.035em; }
.brand-message p { color: #c8c8c8; max-width: 430px; line-height: 1.7; }
.brand-footer { font-size: 12px; color: #a5a5a5; }
.login-panel { background: #fff; display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .mini-logo { display: none; }
.login-card h2 { margin: 0 0 8px; font-size: 29px; }
.login-card .subtext { color: var(--muted); margin: 0 0 28px; line-height: 1.5; }
.login-error { display: none; padding: 12px 14px; margin: 14px 0; border: 1px solid #f2c6c2; background: #fff4f2; color: var(--red); border-radius: 9px; font-size: 13px; }
.login-error.show { display: block; }

/* Main application */
.app-shell { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #111; color: #f9f7ef; padding: 22px 15px; display: flex; flex-direction: column; gap: 24px; }
.sidebar-brand { display: flex; gap: 11px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid #39352a; }
.sidebar-brand img { width: 51px; height: 51px; object-fit: contain; }
.sidebar-brand strong { font-size: 13px; line-height: 1.25; display: block; }
.sidebar-brand small { display: block; color: #d3bf69; font-size: 10px; margin-top: 4px; letter-spacing: .09em; }
.nav-group { display: grid; gap: 6px; }
.nav-label { color: #98958b; text-transform: uppercase; font-size: 10px; letter-spacing: .15em; font-weight: 700; margin: 0 12px 5px; }
.nav-btn { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 9px; padding: 12px 13px; text-align: left; color: #d7d4ca; background: transparent; font-size: 13px; font-weight: 650; }
.nav-btn .nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-btn:hover { background: #25241f; color: white; }
.nav-btn.active { color: #fff; background: #3b3420; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 9px; }
.sidebar-note { color: #908d84; font-size: 11px; line-height: 1.5; padding: 10px 12px; }
.main-area { min-width: 0; }
.topbar { height: 76px; padding: 0 clamp(18px, 3.1vw, 42px); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar-title h1 { font-size: 18px; margin: 0; letter-spacing: -.02em; }
.topbar-title p { font-size: 11px; margin: 5px 0 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-pill { display: flex; align-items: center; gap: 8px; border-left: 1px solid var(--line); padding-left: 14px; color: var(--muted); font-size: 12px; }
.user-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; display: inline-block; }
.content { max-width: 1500px; margin: 0 auto; padding: clamp(18px, 3vw, 38px); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-heading h2 { font-size: clamp(22px, 2vw, 28px); margin: 0; letter-spacing: -.035em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 10px 15px; font-weight: 700; font-size: 12px; text-decoration: none; transition: background .15s ease, transform .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-gold { background: var(--gold); color: #18160c; }
.btn-gold:hover { background: #efd56d; }
.btn-outline { background: #fff; border-color: #dcd7c9; color: #2a2a2a; }
.btn-outline:hover { background: #f8f5eb; }
.btn-danger { background: #fff; border-color: #f0c8c4; color: var(--red); }
.btn-sm { min-height: 32px; padding: 7px 10px; font-size: 11px; }
.btn-icon { width: 36px; height: 36px; min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.lang-toggle { min-width: 88px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; color: var(--ink); font-weight: 750; font-size: 11px; }

.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 19px; box-shadow: 0 2px 8px rgba(0,0,0,.018); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.stat-symbol { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; background: #f8f0cb; color: #57460a; font-size: 16px; }
.stat-value { font-size: clamp(22px, 2.5vw, 31px); line-height: 1.2; margin-top: 15px; font-weight: 800; letter-spacing: -.04em; overflow-wrap: anywhere; }
.stat-foot { color: var(--muted); font-size: 11px; margin-top: 7px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.018); }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 14px; }
.panel-header p { color: var(--muted); margin: 5px 0 0; font-size: 11px; }
.panel-body { padding: 18px 20px; }
.dashboard-grid { grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr); align-items: start; }
.invoice-list { display: grid; }
.invoice-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(120px, 1fr) auto; align-items: center; gap: 14px; padding: 15px 20px; border-bottom: 1px solid #efede7; cursor: pointer; }
.invoice-row:last-child { border-bottom: 0; }
.invoice-row:hover { background: #fdfbf5; }
.invoice-number { font-size: 12px; font-weight: 800; }
.invoice-client { font-size: 12px; color: #3d3d3d; margin-top: 4px; overflow-wrap: anywhere; }
.invoice-meta { font-size: 11px; color: var(--muted); }
.invoice-amount { font-weight: 800; font-size: 13px; text-align: right; }
.type-badge { display: inline-flex; width: fit-content; padding: 4px 7px; border-radius: 6px; font-size: 9px; line-height: 1.2; letter-spacing: .02em; font-weight: 800; text-transform: uppercase; background: #f4f0df; color: #5e4b0d; }
.type-badge.gst { color: #19613d; background: #e7f4e9; }
.type-badge.non-gst { color: #555; background: #eeeeee; }
.type-badge.gst-not-payable { color: #80500e; background: #fff0d0; }
.quick-actions { display: grid; gap: 10px; }
.quick-action { display: flex; text-align: left; align-items: center; gap: 13px; width: 100%; border: 1px solid var(--line); background: white; border-radius: 11px; padding: 14px; }
.quick-action:hover { border-color: #d4bd59; background: #fffdf5; }
.quick-action .qa-icon { width: 37px; height: 37px; display: grid; place-items: center; background: #f7f0d4; border-radius: 10px; font-size: 16px; }
.quick-action strong { display: block; font-size: 12px; }
.quick-action small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.4; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
.empty-state .empty-icon { font-size: 28px; margin-bottom: 10px; }

/* Forms */
.form-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, .8fr); gap: 18px; align-items: start; }
.form-stack { display: grid; gap: 18px; }
.form-section { background: white; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.section-title { padding: 15px 19px; background: #fbfaf5; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.section-number { width: 26px; height: 26px; display: grid; place-items: center; background: var(--gold); border-radius: 8px; font-weight: 800; font-size: 12px; }
.section-title h3 { margin: 0; font-size: 13px; }
.section-content { padding: 19px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.field-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { min-width: 0; display: grid; align-content: start; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11px; font-weight: 750; color: #43423c; }
.field label .optional { font-weight: 500; color: #96938a; }
.field input, .field select, .field textarea, .search-input { width: 100%; min-width: 0; border: 1px solid #d9d5ca; background: #fff; border-radius: 8px; padding: 11px 12px; font-size: 13px; color: var(--ink); }
.field input, .field select { height: 41px; }
.field textarea { resize: vertical; min-height: 86px; line-height: 1.5; }
.field input:read-only { background: #f8f7f1; color: #5c5b55; }
.field-help { font-size: 10px; color: var(--muted); line-height: 1.5; margin-top: -2px; }
.inline-row { display: flex; align-items: center; gap: 8px; }
.inline-row > .field { flex: 1; }
.service-table-wrap { width: 100%; overflow-x: auto; }
.service-table { border-collapse: collapse; width: 100%; min-width: 690px; font-size: 12px; }
.service-table th { background: #f8f6ef; color: #545148; padding: 11px 10px; text-align: left; font-size: 10px; border-bottom: 1px solid var(--line); }
.service-table td { border-bottom: 1px solid #eeeae0; padding: 9px 7px; vertical-align: top; }
.service-table input { width: 100%; min-width: 60px; border: 1px solid #dedacf; padding: 9px 8px; border-radius: 7px; font-size: 12px; }
.service-table .desc-input { min-width: 185px; }
.service-table .amount-cell { min-width: 97px; text-align: right; font-weight: 800; padding-top: 18px; }
.service-table .line-remove { border: 0; color: var(--red); background: transparent; padding: 7px; }
.line-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0 0; }
.line-tools small { color: var(--muted); font-size: 10px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.checkline input { width: 16px; height: 16px; accent-color: var(--gold-deep); }
.totals-card { background: #171717; color: #fff; border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.totals-card h3 { font-size: 13px; margin: 0 0 5px; }
.totals-card .muted { color: #bab6a8; font-size: 11px; line-height: 1.5; }
.total-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; color: #dedbd3; font-size: 12px; }
.total-line strong { color: #fff; font-size: 13px; }
.total-line.grand { padding-top: 14px; border-top: 1px solid #464239; margin-top: 15px; align-items: end; }
.total-line.grand span { font-size: 12px; color: var(--gold); font-weight: 750; }
.total-line.grand strong { font-size: 25px; color: var(--gold); letter-spacing: -.04em; }
.words-box { margin-top: 16px; padding: 12px; background: #25241f; border-radius: 9px; }
.words-box small { display: block; font-size: 10px; color: #c1b98e; margin-bottom: 6px; }
.words-box p { margin: 0; font-weight: 750; font-size: 12px; line-height: 1.5; }
.submit-stack { display: grid; gap: 9px; margin-top: 17px; }
.note-card { border: 1px solid #ebdb9a; background: #fff9df; padding: 13px 15px; border-radius: 11px; font-size: 11px; line-height: 1.5; color: #59470d; }

/* Invoices and customers */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 15px; }
.search-box { position: relative; flex: 1; min-width: 210px; }
.search-box .search-input { padding-left: 38px; height: 42px; }
.search-box .search-icon { position: absolute; left: 13px; top: 12px; color: #8d897e; }
.toolbar select { min-height: 42px; border: 1px solid #d9d5ca; border-radius: 8px; padding: 9px 12px; background: #fff; font-size: 12px; }
.data-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.data-card-header { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(130px,.7fr) minmax(90px,.6fr) minmax(100px,.6fr) auto; gap: 12px; padding: 12px 17px; background: #f8f6ef; color: #6f6a5e; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.data-row { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(130px,.7fr) minmax(90px,.6fr) minmax(100px,.6fr) auto; gap: 12px; padding: 15px 17px; border-top: 1px solid #eeeae0; align-items: center; cursor: pointer; }
.data-row:hover { background: #fdfbf6; }
.data-row .primary { font-size: 12px; font-weight: 800; overflow-wrap: anywhere; }
.data-row .secondary { font-size: 10px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.data-row .row-amount { font-weight: 800; font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: end; }
.customer-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.customer-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 17px; display: grid; gap: 10px; }
.customer-card h3 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.customer-card .customer-address { color: var(--muted); font-size: 11px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.customer-meta { display: flex; gap: 7px; flex-wrap: wrap; }
.customer-chip { display: inline-flex; border: 1px solid var(--line); padding: 5px 7px; border-radius: 6px; font-size: 10px; color: #57534a; }
.customer-card-actions { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #eeeae0; padding-top: 12px; margin-top: 2px; }
.settings-layout { max-width: 900px; display: grid; gap: 17px; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 5px; }

/* Modal, print, notices */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15,15,13,.65); padding: 25px; display: grid; place-items: center; overflow: auto; }
.modal { width: min(100%, 740px); max-height: calc(100vh - 50px); overflow: auto; background: #fff; border-radius: 15px; box-shadow: 0 25px 70px rgba(0,0,0,.32); }
.modal.modal-wide { width: min(100%, 930px); }
.modal-head { padding: 17px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.invoice-document { background: white; width: 100%; max-width: 850px; margin: 0 auto; color: #181818; padding: 24px; font-family: Arial, Helvetica, sans-serif; font-size: 11px; line-height: 1.35; border: 1px solid #eee; }
.invoice-doc-head { display: grid; grid-template-columns: 70px minmax(0,1fr) auto; gap: 12px; align-items: center; border-bottom: 2px solid #1b1b1b; padding-bottom: 13px; margin-bottom: 14px; }
.invoice-doc-head img { width: 67px; max-height: 77px; object-fit: contain; }
.invoice-doc-company h2 { margin: 0 0 5px; font-size: 17px; letter-spacing: -.02em; }
.invoice-doc-company p { margin: 2px 0; font-size: 10px; overflow-wrap: anywhere; }
.invoice-doc-title { text-align: right; white-space: nowrap; }
.invoice-doc-title strong { display: block; font-size: 17px; text-transform: uppercase; }
.invoice-doc-title span { display: block; margin-top: 7px; font-size: 10px; font-weight: 700; overflow-wrap: anywhere; }
.invoice-doc-info { border: 1px solid #bfbfbf; margin-bottom: 11px; }
.invoice-doc-meta { display: flex; min-width: 0; }
.invoice-doc-meta > div { flex: 1 1 0; min-width: 0; padding: 9px 11px; overflow-wrap: anywhere; }
.invoice-doc-meta > div + div { border-left: 1px solid #bfbfbf; }
.invoice-doc-info p { margin: 3px 0; }
.invoice-doc-info .bill-to { border-top: 1px solid #bfbfbf; padding: 9px 11px; overflow-wrap: anywhere; }
.invoice-doc-info .bill-to strong { display: block; margin-bottom: 4px; }
.invoice-doc-service { margin: 0 0 11px; border: 1px solid #bfbfbf; padding: 8px 10px; }
.invoice-doc-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; table-layout: fixed; }
.invoice-doc-table th, .invoice-doc-table td { border: 1px solid #bfbfbf; padding: 8px 7px; overflow-wrap: anywhere; }
.invoice-doc-table th { background: #f5f3ed; font-size: 10px; }
.invoice-doc-table th:nth-child(1) { width: 6%; }
.invoice-doc-table th:nth-child(2) { width: 37%; }
.invoice-doc-table th:nth-child(3) { width: 8%; }
.invoice-doc-table th:nth-child(4) { width: 10%; }
.invoice-doc-table th:nth-child(5) { width: 20%; }
.invoice-doc-table th:nth-child(6) { width: 19%; }
.invoice-doc-table td:nth-child(n+3), .invoice-doc-table th:nth-child(n+3) { text-align: right; }
.invoice-doc-totals { display: grid; grid-template-columns: 1.2fr .8fr; border: 1px solid #bfbfbf; margin-bottom: 11px; }
.invoice-doc-words { padding: 12px; border-right: 1px solid #bfbfbf; }
.invoice-doc-words small { display: block; color: #585858; margin-bottom: 11px; }
.invoice-doc-words strong { font-size: 12px; }
.invoice-doc-total-lines { padding: 9px 12px; }
.invoice-doc-total-line { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
.invoice-doc-total-line.grand { border-top: 1px solid #ccc; padding-top: 8px; margin-top: 8px; font-size: 13px; font-weight: 800; }
.invoice-doc-bank { padding: 8px 10px; border: 1px solid #bfbfbf; margin-bottom: 11px; font-size: 10px; }
.invoice-doc-terms { border: 1px solid #bfbfbf; padding: 10px 12px; white-space: pre-line; font-size: 9px; }
.invoice-doc-sign { text-align: right; padding-top: 15px; font-size: 10px; font-weight: 700; }
#toast { position: fixed; z-index: 200; right: 22px; bottom: 22px; max-width: min(400px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 10px; background: #171717; color: white; box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #8f201a; }
#print-root { display: none; }
.spinner { width: 16px; height: 16px; border: 2px solid #d5d0c4; border-top-color: #171717; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 210px minmax(0,1fr); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-layout { grid-template-columns: minmax(0,1.35fr) minmax(240px,.8fr); }
  .customer-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .data-card-header, .data-row { grid-template-columns: minmax(0,1.2fr) minmax(120px,.8fr) minmax(85px,.6fr) auto; }
  .data-card-header > :nth-child(3), .data-row > :nth-child(3) { display: none; }
}
@media (max-width: 800px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; align-items: center; padding: 24px; }
  .login-card .mini-logo { display: block; width: 66px; height: 66px; object-fit: contain; margin-bottom: 18px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding: 10px 12px 12px; gap: 8px; position: sticky; top: 76px; z-index: 9; }
  .sidebar-brand { display: none; }
  .sidebar .nav-label, .sidebar-bottom { display: none; }
  .nav-group { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: thin; }
  .nav-btn { flex: 0 0 auto; width: auto; padding: 10px 12px; font-size: 11px; }
  .nav-btn .nav-icon { width: auto; }
  .main-area { min-width: 0; }
  .topbar { height: 76px; }
  .dashboard-grid, .form-layout { grid-template-columns: 1fr; }
  .form-layout .totals-side { order: -1; }
  .data-card-header, .data-row { grid-template-columns: minmax(0,1fr) minmax(90px,.6fr) auto; }
  .data-card-header > :nth-child(2), .data-row > :nth-child(2), .data-card-header > :nth-child(3), .data-row > :nth-child(3) { display: none; }
}
@media (max-width: 540px) {
  .topbar { padding: 0 14px; }
  .topbar-title h1 { font-size: 15px; }
  .topbar-title p { display: none; }
  .topbar-actions { gap: 6px; }
  .user-pill { display: none; }
  .content { padding: 17px 12px 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .page-heading h2 { font-size: 23px; }
  .heading-actions { width: 100%; }
  .heading-actions .btn { flex: 1; }
  .stats-grid { gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-top { font-size: 10px; align-items: start; }
  .stat-symbol { width: 29px; height: 29px; }
  .stat-value { font-size: 22px; }
  .panel-header, .panel-body { padding: 15px; }
  .invoice-row { grid-template-columns: minmax(0,1fr) auto; padding: 13px 14px; gap: 8px; }
  .invoice-row .invoice-middle { display: none; }
  .field-grid, .field-grid.cols-3 { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .section-content { padding: 15px; }
  .section-title { padding: 13px 15px; }
  .data-card-header { display: none; }
  .data-row { grid-template-columns: minmax(0,1fr) auto; padding: 13px 12px; gap: 8px; }
  .data-row > :nth-child(4) { display: none; }
  .row-actions { flex-wrap: wrap; }
  .customer-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 8px; }
  .modal { max-height: calc(100vh - 16px); border-radius: 12px; }
  .modal-body { padding: 12px; }
  .invoice-document { padding: 10px; font-size: 9px; }
  .invoice-doc-head { grid-template-columns: 42px minmax(0,1fr); gap: 7px; }
  .invoice-doc-head img { width: 42px; }
  .invoice-doc-title { grid-column: 1/-1; text-align: left; white-space: normal; }
  .invoice-doc-title strong { font-size: 13px; }
  .invoice-doc-company h2 { font-size: 12px; }
  .invoice-doc-company p { font-size: 8px; }
  .invoice-doc-meta { flex-direction: column; }
  .invoice-doc-meta > div + div { border-left: 0; border-top: 1px solid #bfbfbf; }
  .invoice-doc-table th, .invoice-doc-table td { padding: 5px 3px; font-size: 8px; }
  .invoice-doc-totals { grid-template-columns: 1fr; }
  .invoice-doc-words { border-right: 0; border-bottom: 1px solid #bfbfbf; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; min-height: 0; }
  body * { visibility: hidden !important; }
  #print-root, #print-root * { visibility: visible !important; }
  #print-root { display: block !important; position: absolute; left: 0; top: 0; width: 100%; color: #000; }
  .invoice-document { max-width: none; width: 100%; border: 0; padding: 0; margin: 0; font-size: 9.5pt; }
  .invoice-doc-head { break-inside: avoid; }
  .invoice-doc-table { break-inside: auto; }
  .invoice-doc-table tr, .invoice-doc-totals, .invoice-doc-bank, .invoice-doc-terms { break-inside: avoid; }
  .invoice-doc-sign { padding-top: 20px; }
  .no-print { display: none !important; }
}

/* Small layout utilities used by the UI; kept in this stylesheet to preserve the strict CSP. */
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }
.mt-7 { margin-top: 7px; }
.mt-6 { margin-top: 6px; }
.mb-16 { margin-bottom: 16px; }
.login-submit { width: 100%; margin-top: 22px; min-height: 46px; }
.login-hint { font-size: 11px; color: #777; line-height: 1.55; margin-top: 20px; }
.login-language-row { display: flex; justify-content: flex-end; margin-top: 12px; }
.stat-value-wide { font-size: clamp(20px, 2vw, 28px); }
.modal-footer-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pre-line { white-space: pre-line; }
.coverage-note { margin-top: 4px; color: #444; }
.filter-hidden { display: none !important; }

/* Helpful message shown if someone double-clicks index.html instead of starting the local backend. */
.file-open-body { min-height: 100vh; background: #f4f1e8; }
.file-open-guide { box-sizing: border-box; width: min(100% - 32px, 720px); margin: 6vh auto; padding: clamp(24px, 5vw, 44px); background: #fff; border: 1px solid #e8e2d1; border-radius: 22px; box-shadow: 0 18px 55px rgba(31, 28, 17, .09); color: #202020; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.6; }
.file-open-emblem { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 22px; border: 3px solid #d8b846; border-radius: 16px; background: #171717; color: #e6c653; font-size: 20px; font-weight: 900; }
.file-open-kicker { color: #8a6a0b; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.file-open-guide h1 { margin: 0 0 14px; font-size: clamp(27px, 5vw, 38px); line-height: 1.15; }
.file-open-guide p { color: #555; }
.file-open-step { margin-top: 24px; padding: 22px; border: 1px solid #e9e2cb; border-radius: 14px; background: #fffdf6; }
.file-open-step h2 { margin: 0; font-size: 19px; }
.file-open-step li { margin: 8px 0; }
.file-open-note { padding-top: 12px; border-top: 1px solid #e9e2cb; font-size: 13px; }
.file-open-small { margin-top: 22px; font-size: 12px; }

/* Optional statutory charges on invoices */
.charge-options { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.charge-options .checkline { margin: 0; }
.block-help { display: block; margin-top: 9px; line-height: 1.55; }

/* Invoice print layout: compact by default, designed to fit usual monthly bills on one A4 page. */
.invoice-doc-info > div { min-width: 0; }
.invoice-doc-sign { display: flex; flex-direction: column; align-items: flex-end; padding-top: 5px; font-size: 9px; line-height: 1.2; }
.company-stamp { width: 86px; height: 86px; object-fit: contain; margin-right: 16px; margin-bottom: 0; opacity: .9; }
.sign-label { font-weight: 800; }
@media print {
  @page { size: A4 portrait; margin: 6mm; }
  html, body { margin: 0 !important; padding: 0 !important; width: 100% !important; height: auto !important; background: #fff !important; }
  body * { visibility: hidden !important; }
  #print-root, #print-root * { visibility: visible !important; }
  #print-root { display: block !important; position: absolute !important; left: 0 !important; top: 0 !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .invoice-document { width: 100% !important; max-width: none !important; border: 0 !important; margin: 0 !important; padding: 0 !important; font-size: 8.4pt !important; line-height: 1.2 !important; box-shadow: none !important; break-inside: auto; }
  .invoice-doc-head { grid-template-columns: 48px minmax(0,1fr) auto !important; gap: 7px !important; padding-bottom: 4px !important; margin-bottom: 6px !important; border-bottom-width: 1px !important; }
  .invoice-doc-head > img { width: 45px !important; max-height: 48px !important; }
  .invoice-doc-company h2 { font-size: 11pt !important; margin-bottom: 2px !important; }
  .invoice-doc-company p { font-size: 7.1pt !important; margin: 1px 0 !important; }
  .invoice-doc-title strong { font-size: 11pt !important; }
  .invoice-doc-title span { font-size: 7pt !important; margin-top: 3px !important; }
  .invoice-doc-info { margin-bottom: 5px !important; }
  .invoice-doc-meta > div { padding: 5px 7px !important; }
  .invoice-doc-info .bill-to { padding: 5px 7px !important; }
  .invoice-doc-info p { margin: 1px 0 !important; }
  .invoice-doc-info .bill-to strong { margin-bottom: 1px !important; }
  .invoice-doc-service { margin-bottom: 5px !important; padding: 4px 6px !important; }
  .invoice-doc-table { margin-bottom: 5px !important; }
  .invoice-doc-table th, .invoice-doc-table td { padding: 4px 5px !important; font-size: 7.8pt !important; line-height: 1.15 !important; }
  .invoice-doc-table th { font-size: 7.7pt !important; }
  .invoice-doc-totals { margin-bottom: 5px !important; }
  .invoice-doc-words, .invoice-doc-total-lines { padding: 5px 7px !important; }
  .invoice-doc-words small { margin-bottom: 3px !important; font-size: 6.8pt !important; }
  .invoice-doc-words strong { font-size: 9pt !important; }
  .invoice-doc-total-line { margin: 1px 0 !important; gap: 5px !important; font-size: 7.7pt !important; }
  .invoice-doc-total-line.grand { padding-top: 3px !important; margin-top: 3px !important; font-size: 9pt !important; }
  .invoice-doc-bank { padding: 4px 6px !important; margin-bottom: 5px !important; font-size: 7.5pt !important; }
  .invoice-doc-terms { padding: 5px 7px !important; font-size: 7.2pt !important; line-height: 1.15 !important; }
  .invoice-doc-sign { padding-top: 2px !important; font-size: 7pt !important; min-height: 25mm; }
  .company-stamp { width: 24mm !important; height: 24mm !important; margin-right: 10mm !important; margin-bottom: 1mm !important; }
  .invoice-document-tight .invoice-doc-table th, .invoice-document-tight .invoice-doc-table td { padding: 2.2px 3px !important; font-size: 7.1pt !important; }
  .invoice-document-tight .invoice-doc-terms { font-size: 6.6pt !important; }
  .invoice-document-ultra-tight { font-size: 6.4pt !important; line-height: 1.08 !important; }
  .invoice-document-ultra-tight .invoice-doc-table th, .invoice-document-ultra-tight .invoice-doc-table td { padding: 1.3px 2px !important; font-size: 6.2pt !important; }
  .invoice-document-ultra-tight .invoice-doc-meta > div, .invoice-document-ultra-tight .invoice-doc-info .bill-to, .invoice-document-ultra-tight .invoice-doc-terms { padding: 3px !important; }
  .invoice-doc-head, .invoice-doc-info, .invoice-doc-service, .invoice-doc-table tr, .invoice-doc-totals, .invoice-doc-bank, .invoice-doc-terms, .invoice-doc-sign { break-inside: avoid !important; page-break-inside: avoid !important; }
  .invoice-doc-table { break-inside: auto !important; }
  .invoice-doc-table thead { display: table-header-group; }
  .invoice-doc-table tr { break-inside: avoid; }
  .no-print { display: none !important; }
}

/* Per-line duty-day calculation basis selector. */
.service-table .duty-basis-select { width: 100%; min-width: 120px; border: 1px solid #dedacf; padding: 7px 6px; border-radius: 7px; font-size: 11px; background: #fff; }
