@import url('https://fonts.googleapis.com/css2?family=Shadows+Into+Light&display=swap');

@font-face { font-family: 'Noto Sans Devanagari'; src: url('/fonts/NotoSansDevanagari.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Noto Sans Kannada'; src: url('/fonts/NotoSansKannada.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Noto Sans Tamil'; src: url('/fonts/NotoSansTamil.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Noto Sans Telugu'; src: url('/fonts/NotoSansTelugu.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }


/* Local font example (put the file in /fonts and uncomment):
@font-face {
  font-family: 'ClinicLocal';
  src: url('/fonts/ClinicLocal.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}
*/

:root {
  color-scheme: light;
  --ink: #182520;
  --ink-soft: #55645d;
  --green: #194c3a;
  --green-deep: #103829;
  --green-soft: #eaf2ed;
  --green-faint: #f5f8f5;
  --line: #e2e9e4;
  --line-strong: #cbd8cf;
  --canvas: #f5f7f5;
  --surface: #fff;
  --danger: #a63c34;
  --shadow: 0 16px 48px rgba(21, 52, 37, .08);
  font-family: 'Segoe UI', Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 78px; padding: 12px clamp(18px, 4vw, 56px);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-mark { width: 43px; height: 43px; object-fit: contain; }
.eyebrow { margin: 0 0 5px; color: #65806f; font-size: 10px; line-height: 1.15; letter-spacing: .16em; font-weight: 700; }
.brand-lockup h1 { margin: 0; font: 700 17px/1.15 'Segoe UI', Arial, sans-serif; letter-spacing: -.03em; }
.view-switch { display: flex; gap: 4px; padding: 4px; background: #f2f5f2; border-radius: 13px; }
.view-button { min-height: 40px; border: 0; border-radius: 10px; padding: 0 16px; background: transparent; color: #68766e; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .16s ease, color .16s ease, box-shadow .16s ease; }
.view-button.is-active { color: var(--green); background: #fff; box-shadow: 0 2px 8px rgba(21,52,37,.09); }

.workspace { max-width: 1540px; padding: 28px clamp(16px, 3vw, 48px) 112px; margin: 0 auto; }
.editor-view { display: grid; grid-template-columns: minmax(360px, 510px) minmax(500px, 1fr); align-items: start; gap: clamp(26px, 4vw, 64px); }
.form-column { min-width: 0; }
.section-heading, .preview-heading, .section-title-row, .repeat-heading, .records-header, .record-primary, .record-bottom, .action-bar, .action-buttons { display: flex; align-items: center; justify-content: space-between; }
.section-heading { margin: 0 0 16px; }
h2, h3, h4, p { overflow-wrap: anywhere; }
.section-heading h2, .preview-heading h2, .records-header h2 { margin: 0; font: 750 24px/1.2 'Segoe UI', Arial, sans-serif; letter-spacing: -.04em; }
.form-section { padding: 20px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 3px 12px rgba(25,76,58,.025); }
.section-title-row { justify-content: flex-start; gap: 11px; margin-bottom: 17px; }
.section-title-row h3 { margin: 0; font: 700 15px/1.3 'Segoe UI', Arial, sans-serif; letter-spacing: -.02em; }
.section-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 800; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px 12px; }
.field, .age-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span, .field legend { padding: 0; color: #43534a; font-size: 12px; font-weight: 650; }
.field input, .field select, .field textarea, .repeat-item textarea, .followup-row input {
  width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; padding: 10px 12px;
  background: #fff; color: var(--ink); font-size: 14px; transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .repeat-item textarea:focus, .followup-row input:focus, .search-field:focus-within { border-color: #5e9676; box-shadow: 0 0 0 3px rgba(45,119,77,.12); }
.field input::placeholder, .field textarea::placeholder { color: #9aa79f; }
.field input[aria-invalid="true"] { border-color: #c96c61; }
.age-inputs { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 8px; }
.age-inputs label { display: grid; gap: 6px; }
.age-inputs label span { color: #78867e; font-size: 10px; line-height: 1.2; }
.age-inputs input { min-width: 0; padding: 9px; }
.field-hint { color: #839088; font-size: 10px; margin-top: -2px; }
.field-error { color: var(--danger); font-size: 11px; min-height: 0; line-height: 1.3; }
.field-error:empty { display: none; }
.repeat-heading { margin: 20px 0 10px; align-items: flex-end; }
.repeat-heading h4 { margin: 0 0 3px; font: 700 12px/1.3 'Segoe UI', Arial, sans-serif; }
.repeat-heading p { margin: 0; color: #8a968e; font-size: 10px; }
.text-button { border: 0; padding: 7px 0 7px 10px; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.followup-list { display: grid; gap: 8px; }
.followup-row { display: grid; grid-template-columns: 58px minmax(0,1fr) minmax(92px,.62fr) 32px; gap: 7px; align-items: center; }
.followup-label { color: #728077; font-size: 10px; font-weight: 700; }
.followup-row input { min-height: 38px; padding: 7px 8px; font-size: 11px; }
.remove-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #909b94; font-size: 18px; cursor: pointer; }
.remove-button:hover { color: var(--danger); background: #fbefee; }
.repeat-list { display: grid; gap: 9px; margin-bottom: 10px; }
.repeat-empty { padding: 12px; border: 1px dashed #dbe4dd; border-radius: 11px; color: #87948c; font-size: 11px; text-align: center; }
.repeat-item { display: grid; grid-template-columns: 29px minmax(0,1fr) 32px; gap: 8px; align-items: start; }
.repeat-number { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: #f2f6f3; color: #5f7868; font-size: 10px; font-weight: 700; }
.repeat-item textarea { min-height: 68px; resize: vertical; line-height: 1.45; }
.repeat-editor { display: grid; gap: 7px; min-width: 0; }
.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 0 15px; font-size: 12px; line-height: 1; font-weight: 700; cursor: pointer; transition: transform .14s ease, background .14s ease, border-color .14s ease, box-shadow .14s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .62; cursor: wait; transform: none; }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 5px 13px rgba(25,76,58,.17); }
.button-primary:hover { background: var(--green-deep); }
.button-secondary { color: var(--green); background: #fff; border-color: var(--line-strong); }
.button-secondary:hover { background: var(--green-faint); }
.button-add { width: 100%; border: 1px dashed #bdcfc2; background: #f9fbf9; color: var(--green); min-height: 40px; }
.button-add:hover { border-color: #80a58e; background: var(--green-faint); }
.new-button { min-height: 36px; padding-inline: 12px; }

.preview-column { position: sticky; top: 98px; min-width: 0; }
.preview-heading { margin: 2px 0 14px; gap: 10px; }
.preview-heading h2 { font-size: 18px; }
.preview-heading .eyebrow { margin-bottom: 4px; }
.resolution-tag { display: inline-flex; align-items: center; padding: 7px 10px; border: 1px solid #dbe6de; border-radius: 999px; background: #f8fbf8; color: #5e7667; font-size: 10px; font-weight: 650; white-space: nowrap; }
.preview-frame { padding: clamp(10px, 1.5vw, 20px); border: 1px solid #e1e9e3; border-radius: 18px; background: linear-gradient(145deg,#eef3ef,#e8eee9); box-shadow: var(--shadow); }
.card-preview { width: 100%; overflow: hidden; border-radius: 4px; background: #fff; box-shadow: 0 6px 20px rgba(19,41,29,.17); line-height: 0; }
.card-preview svg { display: block; width: 100%; height: auto; }
.svg2pdf-text-measure { position: absolute; visibility: hidden; }
.preview-caption { margin: 10px 3px 0; color: #839087; font-size: 10px; line-height: 1.5; }
.inline-note { margin: 11px 3px 0; padding: 10px 12px; border-radius: 10px; background: #fff7e7; color: #805a13; font-size: 11px; line-height: 1.4; }

.records-view { max-width: 960px; margin: 18px auto 0; }
.records-header { align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.records-actions { display: flex; align-items: center; gap: 9px; }
.records-header p:not(.eyebrow) { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.records-gate { max-width: 520px; margin: 45px auto; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.records-unlock-form { display: grid; gap: 16px; }
.records-unlock-form .section-icon { display: grid; width: 42px; height: 42px; place-items: center; font-size: 17px; }
.records-unlock-form h3 { margin: 0; font-size: 18px; }
.records-unlock-form p { margin: 6px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.records-gate-error { color: var(--danger); font-size: 12px; }
.search-field { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff; transition: box-shadow .15s,border-color .15s; }
.search-icon { color: #6c8575; font-size: 23px; line-height: 1; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 14px; }
.search-field input::placeholder { color: #9aa79f; }
.search-shortcut { color: #9aa69e; font-size: 9px; font-weight: 700; letter-spacing: .1em; }
.records-status { padding: 20px 4px 12px; color: #7b8980; font-size: 12px; }
.records-list { display: grid; gap: 9px; }
.record-card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; transition: border-color .14s,box-shadow .14s,transform .14s; }
.record-card:hover { transform: translateY(-1px); border-color: #b8cdbd; box-shadow: 0 8px 20px rgba(21,52,37,.06); }
.record-primary { align-items: flex-start; gap: 15px; }
.record-primary strong { display: block; font: 700 14px/1.35 'Segoe UI', Arial, sans-serif; }
.record-primary .record-date { color: #718076; font-size: 11px; }
.record-meta { display: flex; flex-wrap: wrap; gap: 7px 18px; margin-top: 10px; color: #69786f; font-size: 11px; }
.record-number { display: inline-flex; padding: 5px 8px; border-radius: 7px; background: #f1f6f2; color: var(--green); font-size: 10px; font-weight: 700; }

.action-bar { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; min-height: 72px; padding: 11px clamp(16px, 4vw, 56px) calc(11px + env(safe-area-inset-bottom)); border-top: 1px solid #e1e8e2; background: rgba(255,255,255,.97); box-shadow: 0 -8px 26px rgba(25,53,38,.055); backdrop-filter: blur(12px); }
.action-context { display: flex; align-items: center; gap: 8px; color: #738078; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 99px; background: #b8c4bc; }
.status-dot.is-saved { background: #45a26c; box-shadow: 0 0 0 3px #e1f2e6; }
.action-buttons { justify-content: flex-end; gap: 9px; }
.action-buttons .button { min-width: 120px; min-height: 44px; }
.action-buttons .button-primary { min-width: 154px; }
.button-icon { font-size: 16px; line-height: .8; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40; max-width: min(520px, calc(100vw - 30px)); padding: 11px 15px; border-radius: 11px; color: #fff; background: #24372c; box-shadow: 0 10px 28px rgba(17,41,28,.24); font-size: 12px; line-height: 1.45; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .18s,transform .18s; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.toast.is-error { background: #873f38; }

@media (max-width: 1050px) {
  .workspace { padding-top: 22px; }
  .editor-view { grid-template-columns: minmax(320px, .88fr) minmax(420px, 1.12fr); gap: 24px; }
  .form-section { padding: 17px; }
  .preview-column { top: 90px; }
}

@media (max-width: 760px) {
  .topbar { position: sticky; min-height: 66px; padding: 9px 14px; gap: 8px; }
  .brand-lockup { min-width: 0; gap: 8px; }
  .brand-mark { width: 35px; height: 35px; }
  .eyebrow { font-size: 8px; }
  .brand-lockup h1 { max-width: 145px; font-size: 13px; }
  .view-switch { gap: 2px; padding: 3px; border-radius: 11px; }
  .view-button { min-height: 37px; padding: 0 9px; border-radius: 8px; font-size: 10px; }
  .workspace { padding: 16px 13px calc(102px + env(safe-area-inset-bottom)); }
  .editor-view { display: flex; flex-direction: column; gap: 22px; }
  .form-column { width: 100%; }
  .section-heading { margin-bottom: 12px; }
  .section-heading h2, .records-header h2 { font-size: 21px; }
  .form-section { padding: 16px 14px; margin-bottom: 10px; border-radius: 15px; }
  .field-grid { gap: 13px 9px; }
  .field input, .field select { min-height: 45px; }
  .age-inputs { gap: 7px; }
  .age-inputs input { padding-inline: 7px; }
  .followup-row { grid-template-columns: 49px minmax(0,1fr) 88px 28px; gap: 5px; }
  .followup-row input { padding-inline: 6px; font-size: 10px; }
  .remove-button { width: 28px; height: 30px; }
  .preview-column { position: static; order: -1; width: 100%; }
  .preview-heading { margin: 0 2px 9px; }
  .preview-heading h2 { font-size: 16px; }
  .resolution-tag { padding: 6px 8px; font-size: 9px; }
  .preview-frame { padding: 8px; border-radius: 14px; }
  .preview-caption { font-size: 9px; }
  .records-view { margin-top: 6px; }
  .records-header { align-items: flex-start; flex-direction: column; gap: 13px; }
  .records-actions { width: 100%; }
  .records-actions .button { flex: 1; }
  .record-card { padding: 14px; }
  .action-bar { min-height: 68px; padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); gap: 8px; }
  .action-context { max-width: 92px; font-size: 9px; line-height: 1.2; }
  .action-buttons { gap: 7px; }
  .action-buttons .button { min-width: 95px; min-height: 45px; padding: 0 11px; font-size: 11px; }
  .action-buttons .button-primary { min-width: 110px; }
  .action-buttons [data-action="download-pdf"] { min-width: 100px; }
  .button-icon { display: none; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); font-size: 11px; }
}

@media (max-width: 360px) {
  .view-button { padding-inline: 7px; font-size: 9px; }
  .brand-lockup h1 { max-width: 119px; font-size: 12px; }
  .brand-mark { width: 30px; height: 30px; }
  .action-context { display: none; }
  .action-buttons { width: 100%; }
  .action-buttons .button { flex: 1; }
  .action-buttons [data-action="save"] { min-width: 70px; }
  .action-buttons [data-action="download-pdf"] { min-width: 90px; }
  .action-buttons .button-primary { min-width: 100px; }
}

@media (min-width: 761px) {
  .preview-column { order: 0; }
}

/* --- Add-row (note + template button side by side) --- */
.add-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.template-btn { gap: 6px; }

/* --- Template picker modal --- */
.template-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 30, 20, .55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.template-overlay[hidden] { display: none !important; }
.template-modal {
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  width: min(640px, 100%); max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.template-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.template-modal-header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.template-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--ink-soft); cursor: pointer; padding: 4px 8px;
  border-radius: 6px; transition: background .15s;
}
.template-close:hover { background: var(--green-soft); color: var(--green); }
.template-search-label {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.template-search-label .search-icon { font-size: 20px; color: var(--ink-soft); flex-shrink: 0; }
.template-search-label input {
  flex: 1; border: none; outline: none; font-size: 15px;
  background: transparent; color: var(--ink);
}
.template-list { overflow-y: auto; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.template-item {
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 13px 15px; cursor: pointer; transition: border-color .15s, background .15s;
  text-align: left; background: none; width: 100%;
}
.template-item:hover, .template-item:focus-visible { border-color: var(--green); background: var(--green-soft); }
.template-item-label { font-weight: 600; font-size: 14px; color: var(--green); margin-bottom: 4px; }
.template-item-preview { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-item-advice-preview { font-size: 12px; color: #7a9488; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.template-empty { text-align: center; padding: 28px 0; color: var(--ink-soft); font-size: 14px; }

/* Hide Netlify injected badge / drawer / marketing iframes */
iframe,
[id*="netlify"],
[class*="netlify"],
[data-netlify-drawer] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
}

/* --- Split button: Main PNG download + Secondary PDF menu --- */
.split-button-container {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}
.split-button-container .download-main-btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
}
.split-button-container .split-toggle-btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 0 10px;
  min-width: 32px;
  font-size: 13px;
  cursor: pointer;
}
.split-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  padding: 6px;
  min-width: 165px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.split-dropdown[hidden] {
  display: none !important;
}
.split-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.split-dropdown-item:hover, .split-dropdown-item:focus-visible {
  background: var(--green-soft);
  color: var(--green);
}

/* --- Optional billing drawer and clinic receipt --- */
.required-mark { margin-left: 5px; color: #987a3f; font-size: 9px; font-style: normal; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.field input[aria-invalid="true"] { border-color: #c96c61; }
.billing-drawer { padding: 0; overflow: hidden; }
.billing-summary { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 15px 18px; list-style: none; cursor: pointer; }
.billing-summary::-webkit-details-marker { display: none; }
.billing-summary .section-icon { flex: 0 0 34px; width: 34px; height: 34px; font-size: 16px; }
.billing-summary-label { display: grid; gap: 3px; min-width: 0; flex: 1; }
.billing-summary-label strong { font-size: 14px; }
.billing-summary-label small { color: #7c8981; font-size: 10px; }
.billing-summary-total { color: var(--green); font-size: 13px; font-weight: 750; white-space: nowrap; }
.billing-chevron { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--green); font-size: 17px; }
.billing-drawer[open] .billing-chevron { transform: rotate(45deg); }
.billing-content { padding: 0 18px 18px; }
.billing-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 4px; }
.billing-subhead { margin: 22px 0 10px; }
.billing-subhead h4 { margin: 0 0 4px; font-size: 13px; }
.billing-subhead p { margin: 0; color: #7f8b83; font-size: 10px; line-height: 1.45; }
.bill-template-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 9px; position: relative; }
.bill-template-picker .template-search-label { min-height: 42px; padding: 5px 11px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; }
.bill-template-picker .template-search-label input { min-height: 32px; font-size: 12px; }
.bill-template-picker > .button { min-height: 42px; white-space: nowrap; }
.bill-template-results { grid-column: 1 / -1; display: grid; gap: 6px; max-height: 208px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 9px 20px rgba(25,76,58,.08); }
.bill-template-results[hidden] { display: none; }
.bill-template-option { display: grid; gap: 3px; min-height: 54px; padding: 9px 11px; border: 0; border-radius: 8px; background: #fff; text-align: left; cursor: pointer; }
.bill-template-option:hover, .bill-template-option:focus-visible { background: var(--green-faint); outline: 1px solid var(--line-strong); }
.bill-template-option strong { color: var(--green); font-size: 12px; }
.bill-template-option span { color: var(--ink-soft); font-size: 10px; }
.bill-items { display: grid; gap: 10px; margin-top: 12px; }
.bill-empty { margin: 0; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 11px; color: #77857c; font-size: 11px; text-align: center; }
.bill-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.bill-item-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.bill-item-number { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; }
.bill-item-title { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bill-item-title strong { overflow: hidden; color: var(--green); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.bill-item-title small, .optional-label { color: #87948c; font-size: 9px; font-weight: 400; }
.bill-item-fields { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) minmax(66px,.55fr); gap: 9px; }
.bill-item-fields .field { gap: 5px; }
.bill-item-fields .field > span { font-size: 10px; }
.bill-item-fields .field input { min-height: 40px; padding: 8px 9px; font-size: 12px; }
.bill-line-summary { margin: 9px 0 0; color: #61766a; font-size: 10px; text-align: right; }
.bill-totals { display: grid; gap: 8px; max-width: 340px; margin: 15px 0 0 auto; padding: 12px 0; border-top: 1px solid var(--line); }
.bill-totals > div { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: #67756d; font-size: 11px; }
.bill-totals strong { color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.bill-totals .bill-grand-total { margin-top: 3px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--green); font-size: 13px; font-weight: 750; }
.bill-totals .bill-grand-total strong { color: var(--green); font-size: 17px; }
.bill-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.bill-actions > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.bill-save-status { color: #528365; font-size: 10px; }

@media (max-width: 760px) {
  .billing-summary { min-height: 65px; padding: 13px 14px; gap: 9px; }
  .billing-content { padding: 0 14px 15px; }
  .billing-fields { gap: 10px 8px; }
  .bill-template-picker { grid-template-columns: minmax(0,1fr); }
  .bill-template-picker > .button { width: 100%; }
  .bill-item-fields { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .bill-item-fields .field:first-child { grid-column: 1 / -1; }
  .bill-actions { align-items: flex-start; flex-direction: column; }
  .bill-actions > div { width: 100%; }
  .bill-actions .button { flex: 1; min-height: 46px; }
}
