:root {
  color-scheme: light;
  --ink: #172321;
  --ink-soft: #41504d;
  --muted: #64736f;
  --line: #e1e7e5;
  --line-strong: #cad4d1;
  --canvas: #f5f7f6;
  --paper: #fff;
  --sidebar: #f0f3f2;
  --green: #17684f;
  --green-dark: #10513d;
  --green-wash: #e9f4ef;
  --amber: #92610a;
  --amber-wash: #fbf3de;
  --red: #a53d34;
  --red-wash: #faecea;
  --radius-sm: 6px;
  --radius-md: 9px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid #8bc7ad;
  outline-offset: 2px;
}
.icon-library, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 27px 15px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; height: 34px; margin: 0 7px 41px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 31px; height: 31px; border-radius: 8px; background: var(--green); color: #fff; display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 19px; font-weight: 720; letter-spacing: -.055em; }
.nav-caption { display: block; padding: 0 11px; margin-bottom: 10px; color: var(--muted); font-size: 10px; letter-spacing: .11em; font-weight: 700; }
.primary-nav { display: grid; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 11px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: #485753; cursor: pointer; text-align: left;
  font-size: 13px; font-weight: 580; transition: background-color .16s ease, color .16s ease;
}
.nav-link svg { width: 17px; height: 17px; }
.nav-link:hover { background: #e6ece9; color: var(--ink); }
.nav-link.is-active { background: #e1ebe6; color: var(--green-dark); font-weight: 680; }
.nav-count { margin-left: auto; color: #76827f; font-size: 11px; font-variant-numeric: tabular-nums; }
.sidebar-bottom { margin-top: auto; }
.local-note { display: flex; align-items: flex-start; gap: 9px; margin: 0 8px 17px; padding: 13px 10px; border-top: 1px solid var(--line); color: #596964; font-size: 11px; line-height: 1.45; }
.local-dot { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: #278462; box-shadow: 0 0 0 3px #dceee5; flex: none; }
.export-link { min-height: 38px; font-size: 12px; }

.main-area { min-width: 0; flex: 1; }
.topbar {
  min-height: 66px; padding: 0 44px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.82);
}
.breadcrumb { display: flex; gap: 10px; align-items: center; color: #74817d; font-size: 12px; }
.breadcrumb svg { width: 13px; height: 13px; }
.breadcrumb strong { color: var(--ink-soft); font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.local-status { display: inline-flex; gap: 8px; align-items: center; color: #65746f; font-size: 11px; }
.local-status .local-dot { width: 6px; height: 6px; margin: 0; box-shadow: none; }
#cloud-action svg, #cloud-import-local svg { width: 14px; height: 14px; }
.view-panel { display: none; max-width: 1320px; margin: 0 auto; padding: 39px 44px 54px; }
.view-panel.is-visible { display: block; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 31px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 27px; line-height: 1.2; letter-spacing: -.035em; font-weight: 700; }
.page-subtitle { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 15px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; font-size: 12px; font-weight: 650; text-decoration: none; transition: background-color .16s ease, border-color .16s ease, transform .16s ease; }
.button svg { width: 16px; height: 16px; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: var(--line-strong); background: #fff; color: var(--ink-soft); }
.button-secondary:hover { background: #f4f7f5; border-color: #b7c5c0; }
.button-small { min-height: 34px; padding: 0 12px; font-size: 11px; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 18px 0 19px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-item { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 10px; row-gap: 5px; padding: 0 20px; border-right: 1px solid var(--line); }
.stat-item:first-child { padding-left: 0; }
.stat-item:last-child { padding-right: 0; border-right: 0; }
.stat-label { grid-column: 1/-1; color: var(--muted); font-size: 11px; font-weight: 570; }
.stat-item strong { font-size: 25px; line-height: 1; font-weight: 680; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.stat-detail { color: #788581; font-size: 10px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(230px, .75fr); gap: 46px; margin-top: 31px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.section-heading h2 { margin-bottom: 4px; font-size: 15px; font-weight: 670; letter-spacing: -.018em; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.text-button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 0; border: 0; background: transparent; color: var(--green); cursor: pointer; font-size: 11px; font-weight: 650; white-space: nowrap; }
.text-button:hover { color: var(--green-dark); text-decoration: underline; text-underline-offset: 3px; }
.text-button svg { width: 14px; height: 14px; }
.ledger-wrap { min-height: 117px; }
.visit-ledger { width: 100%; border-collapse: collapse; text-align: left; }
.visit-ledger th { padding: 10px 12px 9px 0; border-bottom: 1px solid var(--line); color: #75827e; font-size: 9px; font-weight: 650; letter-spacing: .055em; text-transform: uppercase; }
.visit-ledger td { padding: 13px 12px 13px 0; border-bottom: 1px solid #e9eeec; color: #475651; font-size: 11px; vertical-align: middle; }
.visit-ledger tr:last-child td { border-bottom: 0; }
.visit-ledger .visit-pharmacy-name { color: var(--ink); font-size: 12px; font-weight: 650; }
.visit-ledger .visit-pharmacy-region { display: block; margin-top: 3px; color: #78847f; font-size: 10px; }
.date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stock-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.status-badge { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 3px; background: #edf2ef; color: #4a6056; font-size: 9px; font-weight: 650; white-space: nowrap; }
.status-badge.low { background: var(--amber-wash); color: #76500b; }
.status-badge.out { background: var(--red-wash); color: #8d302a; }
.region-list { display: grid; }
.region-row { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid #e9eeec; }
.region-row:first-child { border-top: 1px solid var(--line); }
.region-marker { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; background: #edf2ef; color: var(--green); }
.region-marker svg { width: 14px; height: 14px; }
.region-name { min-width: 0; flex: 1; color: #394742; font-size: 11px; font-weight: 630; overflow-wrap: anywhere; }
.region-total { color: #77837f; font-size: 10px; white-space: nowrap; }
.empty-inline { display: flex; align-items: flex-start; gap: 9px; padding: 15px 0; color: #798681; font-size: 11px; line-height: 1.5; }
.empty-inline svg { width: 16px; height: 16px; color: #7d9690; }
.first-run-note { display: flex; align-items: center; gap: 14px; margin-top: 34px; padding: 16px 18px; background: #edf3f0; border: 1px solid #e2ebe6; border-radius: var(--radius-md); }
.first-run-note[hidden] { display: none; }
.first-run-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 6px; background: #dceae3; color: var(--green); }
.first-run-icon svg { width: 17px; height: 17px; }
.first-run-note div { flex: 1; }
.first-run-note strong { font-size: 12px; font-weight: 670; }
.first-run-note p { max-width: 520px; margin: 4px 0 0; color: #5b6d65; font-size: 11px; line-height: 1.5; }

.toolbar { display: flex; align-items: center; gap: 15px; margin: 0 0 17px; }
.search-field { display: flex; align-items: center; gap: 9px; width: min(390px, 100%); height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; color: #76837f; }
.search-field svg { width: 15px; height: 15px; }
.search-field input { width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-field input:focus-visible { outline: 0; }
.search-field:focus-within { outline: 3px solid #8bc7ad; outline-offset: 2px; }
.search-field input::placeholder { color: #85918d; }
.result-count { margin-left: auto; color: #75827e; font-size: 10px; white-space: nowrap; }
.data-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 11px 15px 10px 0; border-bottom: 1px solid var(--line); color: #74817d; font-size: 9px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 14px 15px 14px 0; border-bottom: 1px solid #e7ecea; color: #52615c; font-size: 11px; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.primary-cell { color: var(--ink) !important; font-size: 12px !important; font-weight: 650; }
.pharmacy-name-button { padding: 0; border: 0; background: none; color: var(--green-dark); cursor: pointer; text-align: left; font-size: 12px; font-weight: 680; }
.pharmacy-name-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.secondary-cell { display: block; margin-top: 4px; color: #798580; font-size: 10px; font-weight: 400; }
.table-actions { display: flex; justify-content: flex-end; gap: 3px; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #66746f; cursor: pointer; }
.icon-button svg { width: 15px; height: 15px; }
.icon-button:hover { background: #edf2ef; color: var(--ink); }
.empty-state { display: grid; justify-items: center; padding: 54px 18px 62px; border-top: 1px solid var(--line); text-align: center; }
.empty-state .empty-symbol { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 14px; background: #eaf1ed; border-radius: 8px; color: var(--green); }
.empty-state .empty-symbol svg { width: 20px; height: 20px; }
.empty-state h2 { margin: 0 0 6px; font-size: 15px; letter-spacing: -.015em; }
.empty-state p { max-width: 360px; margin: 0 0 17px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.empty-search { display: grid; justify-items: center; padding: 35px 15px; color: #697771; font-size: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 23px; padding: 5px 0; border: 0; background: none; color: var(--green); cursor: pointer; font-size: 11px; font-weight: 650; }
.back-link svg { width: 15px; height: 15px; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 27px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.detail-heading h1 { margin-bottom: 8px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 13px; color: #697771; font-size: 11px; }
.detail-meta span { display: inline-flex; align-items: center; gap: 6px; }
.detail-meta svg { width: 14px; height: 14px; color: #82908a; }
.detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.detail-section { margin: 25px 0 34px; }
.detail-section-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.detail-section-header h2 { margin: 0; font-size: 15px; font-weight: 680; }
.detail-section-header .section-count { margin-left: 7px; color: #78847f; font-size: 10px; font-weight: 500; }
.pharmacy-notes { max-width: 74ch; margin: 13px 0 0; color: #596862; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.contact-list { display: flex; flex-wrap: wrap; gap: 10px 23px; margin: 14px 0 0 21px; }
.pharmacy-contact-list { margin-left: 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.contact-person { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: #53615b; font-size: 10px; }
.contact-person strong { color: #304039; font-size: 10px; font-weight: 650; }
.contact-person .contact-role { color: #75817c; }
.contact-person a { display: inline-flex; align-items: center; gap: 4px; color: #4f685d; text-decoration: none; }
.contact-person a:hover { text-decoration: underline; }
.contact-person svg { width: 12px; height: 12px; }
.visit-history-list { border-top: 1px solid var(--line); }
.visit-history-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px 0; border-bottom: 1px solid #e6ece9; }
.visit-history-item > div { min-width: 0; }
.visit-history-item strong { color: #394740; font-size: 11px; font-weight: 650; }
.visit-history-item p { margin: 7px 0; color: #586760; font-size: 11px; line-height: 1.55; white-space: pre-wrap; }
.visit-history-item .stock-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; color: #64716c; font-size: 9px; }

.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin: -6px 0 18px; }
.filter-chip { min-height: 30px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 4px; background: #fff; color: #5c6a65; cursor: pointer; font-size: 10px; font-weight: 600; }
.filter-chip:hover { background: #f1f5f3; }
.filter-chip.is-selected { border-color: #a8c8b7; background: #e9f3ed; color: #225d47; }
.stock-table .stock-product { color: var(--ink); font-weight: 650; }
.stock-table .stock-pharmacy-region { display: block; margin-top: 4px; color: #75817c; font-size: 10px; font-weight: 400; }
.visit-notes { display: block; max-width: 370px; color: #586760; line-height: 1.5; }
.visit-record { white-space: nowrap; font-variant-numeric: tabular-nums; }
.visit-actions { text-align: right; white-space: nowrap; }

.form-dialog { width: min(520px, calc(100vw - 28px)); max-height: min(88vh, 840px); padding: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--ink); box-shadow: 0 22px 70px rgba(19,34,27,.2); }
.form-dialog::backdrop { background: rgba(22,35,30,.4); }
.dialog-form { display: grid; gap: 16px; padding: 23px 24px 21px; overflow-y: auto; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 4px; }
.dialog-heading h2 { margin: 0 0 5px; font-size: 19px; line-height: 1.25; letter-spacing: -.03em; }
.dialog-heading p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.dialog-heading .icon-button { margin: -5px -5px 0 0; }
.field-label { display: grid; gap: 7px; color: #34443e; font-size: 11px; font-weight: 650; }
.required-mark { color: #9e4a3e; }
.optional-mark { color: #7a8681; font-weight: 450; font-size: 10px; }
.field-label .optional-mark { display: inline; }
.field-label input, .field-label textarea, .field-label select { width: 100%; min-height: 38px; padding: 9px 10px; border: 1px solid #ced8d4; border-radius: 5px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 400; }
.field-label textarea { min-height: 78px; resize: vertical; line-height: 1.5; }
.field-label input::placeholder, .field-label textarea::placeholder { color: #88948f; }
.auth-message { margin: 0; color: #65736d; font-size: 11px; line-height: 1.5; }
.auth-message:empty { display: none; }
.auth-message.is-error { color: #8a332b; }
.cloud-import-summary { padding: 14px 15px; border: 1px solid #dfe8e3; border-radius: 6px; background: #f0f5f2; color: #355347; font-size: 12px; line-height: 1.6; }
.cloud-import-warning { margin: 0; color: #76500b; font-size: 11px; line-height: 1.5; }
.cloud-confirm-label { display: flex; align-items: flex-start; gap: 9px; color: #34443e; font-size: 11px; line-height: 1.5; }
.cloud-confirm-label input { width: 15px; height: 15px; margin: 1px 0 0; flex: none; accent-color: var(--green); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 3px; padding-top: 15px; border-top: 1px solid var(--line); }
.stock-editor { padding-top: 15px; border-top: 1px solid var(--line); }
.stock-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.stock-editor-heading div { display: flex; align-items: center; gap: 8px; }
.stock-editor-heading h3 { margin: 0; font-size: 12px; font-weight: 650; }
.stock-rows { display: grid; gap: 8px; }
.stock-row { display: grid; grid-template-columns: minmax(100px, 1.2fr) minmax(80px, .75fr) minmax(100px, .85fr) minmax(90px, 1fr) 31px; gap: 7px; align-items: center; }
.stock-row input, .stock-row select { width: 100%; min-width: 0; height: 35px; padding: 0 8px; border: 1px solid #d3dcd8; border-radius: 4px; background: #fff; color: var(--ink-soft); font-size: 10px; }
.stock-row .remove-row { width: 30px; height: 30px; }
.stock-row .remove-row svg { width: 14px; height: 14px; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.page-actions .button-secondary { border-color: #cad7d1; color: #35584a; }
.import-dialog { width: min(840px, calc(100vw - 28px)); max-height: min(90vh, 880px); }
.import-content { display: flex; flex-direction: column; gap: 15px; max-height: inherit; padding: 23px 25px 20px; overflow-y: auto; }
.import-content > .dialog-heading { flex: none; }
.import-intro { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 15px; border: 1px solid #dfe8e3; border-radius: 6px; background: #f0f5f2; }
.import-intro-copy strong { color: #294638; font-size: 11px; font-weight: 680; }
.import-intro-copy p { margin: 4px 0 0; color: #53675c; font-size: 10px; line-height: 1.5; }
.template-download { min-width: max-content; min-height: 35px; border-color: #c4d2cb; background: #fff; font-size: 10px; }
.template-download svg { width: 14px; height: 14px; }
.import-sheets { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; padding: 1px 0; }
.import-sheets > div { display: grid; gap: 4px; min-width: 0; }
.import-sheets strong { color: #33423c; font-size: 10px; font-weight: 680; }
.import-sheets .optional-mark { margin-left: 4px; font-size: 9px; }
.import-sheets > div > span { color: #687670; font-size: 9px; line-height: 1.45; }
.import-file-hint { margin: -4px 0 -7px; color: #687670; font-size: 10px; }
.workbook-picker { max-width: 500px; }
.workbook-picker input[type="file"] { padding: 6px 8px; font-size: 10px; }
.import-message { margin: -8px 0 0; color: #65736d; font-size: 10px; line-height: 1.5; }
.import-message.is-error { color: #8a332b; }
.import-preview { display: grid; gap: 11px; }
.import-preview[hidden] { display: none; }
.import-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.import-preview-heading h3 { margin: 0 0 4px; font-size: 13px; font-weight: 680; }
.import-preview-heading p { margin: 0; color: #65736d; font-size: 10px; }
.import-preview-heading .text-button { font-size: 10px; }
.import-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: #66746f; font-size: 9px; }
.preview-pill { display: inline-flex; width: max-content; padding: 4px 7px; border-radius: 3px; font-size: 9px; font-weight: 650; white-space: nowrap; }
.preview-ready { background: #e8f3ec; color: #245c43; }
.preview-existing { background: #edf1ef; color: #53645c; }
.preview-error { background: #faecea; color: #8d302a; }
.import-error-note { margin: 0; color: #8b4038; font-size: 10px; line-height: 1.45; }
.import-error-note[hidden] { display: none; }
.import-table-wrap { max-height: 280px; overflow: auto; border-top: 1px solid var(--line); }
.import-table { width: 100%; border-collapse: collapse; text-align: left; }
.import-table th { position: sticky; top: 0; z-index: 1; padding: 9px 10px 8px; border-bottom: 1px solid var(--line); background: #f5f7f6; color: #73807b; font-size: 8px; font-weight: 670; letter-spacing: .055em; text-transform: uppercase; }
.import-table td { padding: 8px 10px; border-bottom: 1px solid #e8edeb; color: #53615b; font-size: 9px; line-height: 1.4; vertical-align: middle; }
.import-table tbody tr:last-child td { border-bottom: 0; }
.import-table .row-select { width: 34px; text-align: center; }
.import-table input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--green); vertical-align: middle; }
.import-record-type { color: #3c4d45; font-weight: 660; }
.import-record-name { display: block; max-width: 330px; overflow: hidden; color: #394740; text-overflow: ellipsis; white-space: nowrap; }
.import-record-detail { display: block; margin-top: 2px; color: #74807a; }
.import-row-message { min-width: 130px; }
.import-row-message .preview-pill { margin-bottom: 3px; }
.import-actions { flex: none; margin-top: 0; }
.import-actions .button-primary { min-width: 155px; }
.import-actions .button-primary:disabled { opacity: .48; }
.toast-region { position: fixed; right: 22px; bottom: 20px; z-index: 20; display: grid; gap: 8px; }
.toast { max-width: min(420px, calc(100vw - 32px)); padding: 11px 14px; border: 1px solid #d5e0da; border-radius: 6px; background: #fff; color: #30473b; box-shadow: 0 8px 26px rgba(25,41,33,.12); font-size: 11px; line-height: 1.45; animation: toast-in .18s ease-out; }
.toast.error { border-color: #ebc7c2; color: #8a332b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.storage-error { padding: 12px 16px; border-bottom: 1px solid #e7c2be; background: #fff1ef; color: #882f29; font-size: 12px; line-height: 1.5; }
.migration-note { display: flex; align-items: center; justify-content: space-between; gap: 12px 22px; padding: 12px 18px; border-bottom: 1px solid #d5e3db; background: #edf4ef; color: #355347; }
.migration-note[hidden] { display: none; }
.migration-note p { flex: 1; margin: 0; font-size: 10px; line-height: 1.55; }
.migration-note > div { display: flex; flex: none; align-items: center; gap: 16px; }
.migration-note .text-button { font-size: 10px; }
.migration-dismiss { color: #667770; }

@media (max-width: 1050px) {
  .topbar { padding-right: 27px; padding-left: 27px; }
  .view-panel { padding-right: 27px; padding-left: 27px; }
  .overview-grid { gap: 28px; }
  .stat-item { padding-right: 13px; padding-left: 13px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: 100%; padding: 13px 18px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 0 12px 2px; height: 32px; }
  .nav-caption, .sidebar-bottom { display: none; }
  .primary-nav { display: flex; gap: 3px; margin: 0 -2px; overflow-x: auto; }
  .nav-link { justify-content: center; gap: 7px; width: auto; min-width: max-content; min-height: 42px; padding: 0 12px; border-radius: 5px 5px 0 0; }
  .nav-link.is-active { background: transparent; box-shadow: inset 0 -2px var(--green); }
  .nav-count { display: none; }
  .topbar { min-height: 51px; padding: 0 20px; }
  .local-status { display: none; }
  .view-panel { padding: 27px 20px 42px; }
  .migration-note { align-items: flex-start; }
  .migration-note > div { flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; }
  .overview-grid { grid-template-columns: 1fr; gap: 29px; }
  .stat-item { grid-template-columns: 1fr auto; padding: 0 12px; }
  .stat-label { grid-column: auto; grid-row: 1; }
  .stat-item strong { grid-row: 2; }
  .stat-detail { grid-column: 1/-1; grid-row: 3; }
  .first-run-note { align-items: flex-start; flex-wrap: wrap; }
  .first-run-note .text-button { margin-left: 48px; }
  .import-content { gap: 13px; padding: 20px 17px 17px; }
  .import-sheets { grid-template-columns: 1fr; gap: 8px; }
  .import-sheets > div { grid-template-columns: 90px minmax(0,1fr); align-items: baseline; gap: 8px; }
  .import-intro { align-items: flex-start; }
  .import-table-wrap { max-height: 240px; }
  .import-table th, .import-table td { padding-right: 7px; padding-left: 7px; }
}
@media (max-width: 520px) {
  .sidebar { padding-right: 12px; padding-left: 12px; }
  .nav-link { min-height: 40px; padding: 0 9px; font-size: 11px; }
  .nav-link svg { width: 15px; height: 15px; }
  .topbar { padding: 0 16px; }
  .topbar .button { min-height: 31px; padding: 0 9px; font-size: 10px; }
  .view-panel { padding: 24px 16px 34px; }
  .migration-note { display: block; padding: 11px 15px; }
  .migration-note > div { justify-content: flex-start; margin-top: 6px; }
  .page-heading { align-items: flex-start; margin-bottom: 23px; }
  .page-heading h1 { font-size: 24px; }
  .page-heading .button { min-height: 35px; padding: 0 9px; font-size: 10px; }
  .page-heading .button svg { width: 14px; height: 14px; }
  .page-actions { justify-content: flex-end; gap: 6px; }
  .page-actions .button { min-height: 32px; padding: 0 7px; font-size: 9px; }
  .page-actions .button svg { width: 13px; height: 13px; }
  .page-subtitle { max-width: 38ch; font-size: 11px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; padding: 16px 0; }
  .stat-item { padding: 0 11px; }
  .stat-item:nth-child(2) { border-right: 0; }
  .stat-item:nth-child(3) { padding-left: 0; }
  .stat-item strong { font-size: 22px; }
  .stat-detail { font-size: 9px; }
  .visit-ledger { min-width: 510px; }
  .ledger-wrap { overflow-x: auto; }
  .first-run-note { gap: 11px; padding: 13px; }
  .first-run-note .text-button { margin-left: 45px; }
  .toolbar { gap: 9px; }
  .search-field { height: 36px; }
  .data-table th, .data-table td { padding-right: 10px; }
  .detail-heading { display: block; }
  .detail-actions { justify-content: flex-start; margin-top: 17px; }
  .contact-list { display: grid; gap: 9px; margin-left: 0; }
  .pharmacy-contact-list { gap: 9px; }
  .dialog-form { gap: 14px; padding: 20px 17px 17px; }
  .import-intro { display: grid; gap: 10px; }
  .template-download { width: max-content; }
  .import-record-name { max-width: 150px; }
  .import-legend { gap: 5px; }
  .field-row { gap: 9px; }
  .stock-row { grid-template-columns: minmax(0, 1fr) minmax(75px, .8fr) 30px; }
  .stock-row select { grid-column: 1; grid-row: 2; }
  .stock-row input[name="stockNote"] { grid-column: 2; grid-row: 2; }
  .stock-row .remove-row { grid-column: 3; grid-row: 1/3; }
  .visit-table-wrap { overflow-x: auto; }
  .visit-table { min-width: 700px; }
  .stock-table-wrap { overflow-x: auto; }
  .stock-table { min-width: 620px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
