:root { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color:#181818; background:#f5f6f7; }
* { box-sizing:border-box; }
body { margin:0; }
button,input,select { font:inherit; }
button { border:1px solid #d6d9dd; background:#fff; border-radius:9px; padding:9px 13px; cursor:pointer; }
button:hover { background:#f2f3f5; }
button:disabled { opacity:.55; cursor:wait; }
button.primary { background:#111; color:#fff; border-color:#111; }
button.ghost { background:transparent; }
button.danger { color:#b42318; border-color:#f0c9c5; }
button.small { padding:5px 8px; font-size:12px; }
.brand { font-weight:800; letter-spacing:.08em; }
.muted { color:#6c727a; font-size:13px; }
.error { color:#b42318; min-height:20px; margin-top:8px; font-size:13px; }
.hidden { display:none !important; }
.print-only { display:none; }

.app-header { position:sticky; top:0; z-index:10; display:flex; align-items:center; justify-content:space-between; gap:20px; padding:14px 22px; background:rgba(255,255,255,.96); border-bottom:1px solid #e3e5e8; backdrop-filter:blur(10px); }
.header-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.sync-meta { display:flex; flex-direction:column; align-items:flex-end; line-height:1.25; margin-right:4px; }
.toolbar { display:flex; gap:14px; padding:14px 22px; background:#fff; border-bottom:1px solid #e7e8ea; align-items:end; flex-wrap:wrap; }
.toolbar label { font-size:12px; font-weight:650; color:#525862; display:flex; flex-direction:column; gap:5px; }
.toolbar select,.toolbar input { min-width:190px; border:1px solid #d8dadd; border-radius:8px; padding:9px 10px; background:#fff; }
.toolbar input[type="date"] { min-width:155px; }
.toolbar .search-label { flex:1; }
.toolbar .search-label input { width:100%; }
.toolbar .check-label { flex-direction:row; align-items:center; padding-bottom:10px; }

main { max-width:1100px; margin:20px auto 60px; padding:0 20px; }
.print-header { background:#fff; border-radius:14px; padding:22px 24px; display:flex; align-items:center; gap:24px; border:1px solid #e1e3e6; margin-bottom:16px; }
.print-logo-img { width:94px; height:auto; object-fit:contain; flex:0 0 auto; }
.print-header-copy { min-width:0; }
.print-header h1 { margin:0 0 4px; font-size:24px; line-height:1.15; }
.print-org { font-weight:650; font-size:16px; line-height:1.35; }
.print-address { margin-top:2px; font-size:15px; }
.print-effective-date { margin-top:14px; font-size:16px; font-weight:800; }
.print-scope { margin-top:7px; color:#606771; font-size:13px; }

.price-category { background:#fff; border:1px solid #e1e3e6; border-radius:14px; margin:14px 0; overflow:hidden; break-inside:avoid-page; }
.category-heading { display:flex; align-items:center; gap:9px; padding:13px 16px; border-bottom:1px solid #eceef0; }
.category-heading h2 { margin:0; font-size:17px; flex:1; }
.drag-handle { color:#9298a1; cursor:grab; user-select:none; }
table { width:100%; border-collapse:collapse; }
th,td { padding:9px 14px; border-bottom:1px solid #f0f1f2; vertical-align:top; }
th { text-align:left; font-size:12px; color:#676e78; font-weight:700; background:#fafafa; }
td.price, th.price { text-align:right; width:145px; white-space:nowrap; }
/* v0.2.8: with one selected clinic the single cost column is left-aligned. */
body.single-price td.price, body.single-price th.price { text-align:left; }
td.order-cell, th.order-cell { width:34px; color:#a0a5ad; cursor:grab; user-select:none; }
.admin-print-col { width:70px; text-align:center; }
.admin-availability-col { width:210px; }
.availability-btn { max-width:195px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
tr:last-child td { border-bottom:0; }
tr.dragging,.price-category.dragging { opacity:.45; }
tr[draggable="true"] { cursor:move; }
.item-name { display:flex; align-items:center; gap:7px; min-width:0; }
.item-name > span { min-width:0; overflow-wrap:anywhere; }
.edit-btn { opacity:0; padding:2px 6px; font-size:11px; white-space:nowrap; }
tr:hover .edit-btn { opacity:1; }
.print-disabled .item-name > span { color:#8b9098; text-decoration:line-through; text-decoration-thickness:1px; }

.notice { margin:12px 0; padding:12px 14px; border-radius:10px; background:#fff4d6; border:1px solid #f2d58a; white-space:pre-line; }
.empty { padding:28px; text-align:center; color:#777; background:#fff; border:1px solid #e1e3e6; border-radius:14px; }
.overlay { position:fixed; inset:0; z-index:100; background:#f5f6f7; display:grid; place-items:center; }
.login-card { width:min(390px,calc(100% - 32px)); background:#fff; padding:28px; border-radius:16px; border:1px solid #e0e2e5; box-shadow:0 14px 40px rgba(0,0,0,.08); }
.login-card h1 { margin:8px 0 20px; }
.login-card input { width:100%; border:1px solid #d5d8dc; border-radius:9px; padding:11px 12px; margin-bottom:10px; }
.login-card button { width:100%; }

.modal-overlay { position:fixed; inset:0; z-index:80; background:rgba(20,24,29,.46); padding:28px; display:grid; place-items:center; }
.modal-card { width:min(1250px,100%); height:min(820px,calc(100vh - 56px)); background:#fff; border-radius:16px; box-shadow:0 22px 70px rgba(0,0,0,.25); overflow:hidden; display:flex; flex-direction:column; }
.item-modal-card { width:min(680px,100%); max-height:calc(100vh - 56px); background:#fff; border-radius:16px; box-shadow:0 22px 70px rgba(0,0,0,.25); overflow:auto; }
.modal-header { display:flex; justify-content:space-between; gap:20px; align-items:flex-start; padding:18px 20px; border-bottom:1px solid #e7e8ea; }
.modal-header h2 { margin:0 0 4px; }
.modal-body { display:grid; grid-template-columns:340px minmax(0,1fr); min-height:0; flex:1; }
.category-admin { padding:18px; border-right:1px solid #e7e8ea; overflow:auto; }
.mapping-admin { padding:18px; overflow:auto; }
.section-title { font-weight:750; margin-bottom:10px; }
.inline-form { display:flex; gap:7px; margin-bottom:14px; }
.inline-form input { min-width:0; flex:1; border:1px solid #d8dadd; border-radius:8px; padding:9px 10px; }
.category-admin-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:5px; align-items:center; padding:8px 0; border-bottom:1px solid #f0f1f2; }
.category-admin-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.category-count { color:#858b94; font-size:12px; }
.unassigned-info { margin-top:14px; padding:10px; background:#fff5da; border:1px solid #f1d79a; border-radius:9px; font-size:13px; }
.mapping-help { margin-bottom:12px; }
.source-folder-list { border:1px solid #e6e8eb; border-radius:10px; overflow:hidden; }
.source-folder-row { display:grid; grid-template-columns:minmax(270px,1fr) minmax(220px,300px) 110px; gap:10px; align-items:center; min-height:45px; padding:7px 10px; border-bottom:1px solid #eef0f2; }
.source-folder-row:last-child { border-bottom:0; }
.source-folder-row:nth-child(even) { background:#fafbfb; }
.source-folder-name { min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.source-folder-name .inherited { display:block; color:#8a9098; font-size:11px; margin-top:2px; }
.source-folder-row select { width:100%; border:1px solid #d8dadd; border-radius:7px; padding:7px 8px; background:#fff; }
.inherit-check { display:flex; gap:5px; align-items:center; font-size:12px; color:#626872; }

.item-settings-form { padding:20px; display:grid; gap:18px; }
.item-settings-form > label:not(.form-check-row) { display:grid; gap:6px; font-size:13px; font-weight:700; color:#4d535c; }
.item-settings-form input[type="text"] { width:100%; border:1px solid #d8dadd; border-radius:9px; padding:10px 11px; }
.form-check-row { display:flex; gap:10px; align-items:flex-start; padding:12px; border:1px solid #e6e8eb; border-radius:10px; }
.form-check-row input { margin-top:3px; }
.form-check-row span { display:grid; gap:3px; }
.form-check-row small { color:#747b84; font-weight:400; line-height:1.35; }
.availability-fieldset { margin:0; padding:14px; border:1px solid #e1e4e8; border-radius:10px; }
.availability-fieldset legend { font-weight:750; padding:0 6px; }
.branch-checkboxes { display:grid; grid-template-columns:1fr 1fr; gap:9px 14px; margin-top:12px; }
.branch-check { display:flex; gap:8px; align-items:center; min-height:34px; }
.modal-actions { display:flex; justify-content:flex-end; gap:8px; padding-top:4px; }

.sync-progress { margin:12px 0; padding:14px 16px; border:1px solid #dfe2e6; border-radius:11px; background:#fff; }
.sync-progress-top,.sync-progress-bottom { display:flex; justify-content:space-between; gap:14px; align-items:center; }
.sync-progress-top { margin-bottom:9px; }
.sync-progress-bottom { margin-top:8px; font-size:13px; }
.progress-track { height:10px; border-radius:999px; background:#eceff2; overflow:hidden; }
.progress-bar { height:100%; background:#111; border-radius:999px; transition:width .25s ease; }


/* v0.2.4: ordering mode uses the available screen width instead of clipping admin columns. */
/* v0.2.5: larger 20 mm print margins on all sides. */
/* v0.2.6: 24 mm print margins, page-per-category printing, resizable result columns. */
/* v0.2.7: 30 mm physical print margins and reliable proportional resizing in single-clinic view. */
body.edit-mode main { max-width:none; width:100%; padding-left:22px; padding-right:22px; }
body.edit-mode .price-category { overflow-x:auto; overflow-y:hidden; }
body.edit-mode .price-category table { min-width:1380px; }
body.edit-mode .item-name { min-width:360px; }

.mapping-title-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.mapping-title-row .section-title { margin-bottom:0; }
.mapping-actions { display:flex; gap:6px; flex-wrap:wrap; }
.source-folder-title-row { display:flex; align-items:center; gap:7px; min-width:0; }
.source-folder-title { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.folder-toggle { min-width:76px; padding:3px 6px; font-size:11px; flex:0 0 auto; }
.folder-toggle-spacer { width:76px; flex:0 0 76px; }

@media (max-width:900px) {
  .app-header { align-items:flex-start; flex-direction:column; }
  .header-actions { justify-content:flex-start; }
  .sync-meta { align-items:flex-start; width:100%; }
  .modal-body { grid-template-columns:1fr; overflow:auto; }
  .category-admin { border-right:0; border-bottom:1px solid #e7e8ea; overflow:visible; }
  .mapping-admin { overflow:visible; }
  .source-folder-row { grid-template-columns:1fr; }
  .branch-checkboxes { grid-template-columns:1fr; }
}

/* Resizable result table columns. Drag the separator on a table header; widths are shared across categories. */
.price-category { overflow-x:auto; overflow-y:hidden; }
.resizable-price-table { table-layout:fixed; width:100%; min-width:100%; }
.resizable-price-table th.resizable-col { position:relative; }
.col-resizer {
  position:absolute; top:0; right:-5px; width:10px; height:100%; z-index:3;
  cursor:col-resize; touch-action:none; user-select:none; outline:none;
}
.col-resizer::after {
  content:""; position:absolute; top:20%; bottom:20%; left:4px; width:1px;
  background:#c5c9cf; opacity:0; transition:opacity .15s ease, background .15s ease;
}
.resizable-col:hover .col-resizer::after, .col-resizer:focus::after { opacity:1; background:#7b828c; }
body.column-resizing { cursor:col-resize !important; user-select:none !important; }
body.column-resizing * { cursor:col-resize !important; }
.column-reset-btn { align-self:flex-end; margin-bottom:1px; }

/* More generous physical page margins than v0.2.2. */
@page { size:A4; margin:30mm; }
@media print {
  :root { background:#fff; }
  body { background:#fff; font-size:10pt; }
  .no-print { display:none !important; }
  .screen-only { display:none !important; }
  .print-only { display:inline !important; }
  .print-disabled { display:none !important; }
  html, body { margin:0 !important; padding:0 !important; }
  main { max-width:none; margin:0 !important; padding:0 !important; }
  .print-header { border:0; border-radius:0; padding:0 0 7mm; margin:0 0 5mm; border-bottom:1px solid #111; gap:7mm; align-items:center; }
  .print-logo-img { width:27mm; max-height:35mm; }
  .print-header h1 { font-size:16pt; margin-bottom:1.5mm; }
  .print-org { font-size:11.5pt; font-weight:650; }
  .print-address { margin-top:1mm; font-size:11pt; }
  .print-effective-date { margin-top:4mm; font-size:11.5pt; font-weight:800; }
  .print-scope { margin-top:2mm; color:#333; font-size:9pt; }
  .price-category { border:0; border-radius:0; margin:0 0 5mm; overflow:visible; break-inside:auto; }
  #priceContent .price-category + .price-category { break-before:page; page-break-before:always; }
  .category-heading { padding:2.5mm 0 2mm; border-bottom:1px solid #111; break-after:avoid; }
  .col-resizer { display:none !important; }
  .category-heading h2 { font-size:12pt; }
  table { font-size:9.2pt; }
  thead { display:table-header-group; }
  tr { break-inside:avoid; }
  th { background:#fff; color:#222; border-bottom:1px solid #aaa; }
  th,td { padding:2.1mm 1.5mm; }
  td.price,th.price { white-space:normal; line-height:1.2; }
  body.many-prices table { font-size:8.2pt; }
  body.many-prices th.price { font-size:7.4pt; }
}
