/* Shared colors, type, navigation, buttons, tables and cards come from jwms.css. */
:root { --muted: var(--ink-3); --border: var(--line); --head: var(--surface-2); }
button, a, input, select, textarea { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
.erp-sidebar .sidebar-head, .erp-sidebar .branch-card, .erp-sidebar .sidebar-foot { flex-shrink: 0; }
.erp-module-name { padding: 12px 20px 8px; color: var(--ink-3); font-size: 11px; font-weight: 600; }
.sidebar-scrim { border: 0; padding: 0; }
.erp-main { min-width: 0; }
.erp-header h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
h2 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }
h3 { margin: 0 0 12px; font-size: 14px; }
p { line-height: 1.7; }
.header-actions, .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.button { white-space: nowrap; }
.button.link { border: 0; background: transparent; padding: 5px; color: var(--purple-dark); text-decoration: underline; }
.datebar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 70px; margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.datebar input { width: 165px; min-height: 38px; font-size: 13px; }
.datebar .date-heading { min-width: 160px; text-align: center; font-size: 15px; font-weight: 700; }
.datebar .icon-button { border: 1px solid var(--line); font-size: 18px; }
.badge { white-space: nowrap; }
.badge.good { color: var(--green); background: var(--green-soft); }
.badge.warn { color: var(--orange); background: var(--orange-soft); }
.badge.bad { color: var(--red); background: var(--red-soft); }
.badge.controlled { color: var(--purple-dark); background: var(--purple-light); }
.panel { overflow: hidden; min-width: 0; }
.panel-pad { padding: 18px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 12px; }
.panel-title h2, .panel-title h3 { margin: 0; font-size: 14px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.outbound-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.outbound-workflow { display: grid; grid-template-columns: minmax(240px, .9fr) minmax(280px, 1.1fr); gap: 16px; align-items: start; min-width: 0; }
.outbound-workflow > .panel + .panel { margin-top: 0; }
.outbound-patients .tabs { padding: 8px; gap: 2px; }
.outbound-patients .tabs button { padding: 6px; }
.outbound-patients .patient-row { padding: 14px; }
.outbound-patients .patient-row.selected { padding-left: 11px; }
.issue-fields { display: grid; gap: 16px; border: 0; padding: 0; margin: 0; min-width: 0; }
.issue-fields select, .issue-fields input { width: 100%; min-width: 0; }
.issue-stock { padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); line-height: 1.8; }
.basket-items { max-height: 480px; overflow: auto; }
.outbound-basket .basket-foot .button { width: 100%; }
.outbound-workflow .panel-title { flex-wrap: wrap; gap: 8px; }
.outbound-workflow .patient-details p { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.stack > .panel + .panel { margin-top: 0; }
.muted { color: var(--ink-3); font-size: 12px; }
.erp-main .mono, #erp-dialog .mono { font-family: inherit; font-size: inherit !important; font-variant-numeric: tabular-nums; }
.metric { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid #f1f1f3; min-height: 54px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.metric:last-child { border: 0; }
.metric:hover { background: var(--surface-2); }
.metric .value { color: var(--purple-dark); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric button { border: 0; border-radius: 6px; background: transparent; color: var(--ink-3); width: 30px; height: 30px; }
.metric button:hover { color: var(--purple-dark); background: var(--purple-light); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card b { display: block; margin-top: 5px; color: var(--purple-dark); font-size: 25px; font-weight: 700; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); color: var(--orange); background: var(--orange-soft); font-size: 12px; line-height: 1.7; margin-bottom: 18px; overflow-wrap: anywhere; }
.notice.info { color: var(--purple-dark); background: var(--purple-light); }
.notice.error { color: var(--red); background: var(--red-soft); }
.empty { padding: 40px 24px; text-align: center; color: var(--ink-3); line-height: 1.8; font-size: 13px; }
.tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 7px; color: var(--ink-3); background: transparent; font-size: 12px; }
.tabs button:hover { color: var(--purple-dark); background: var(--surface-2); }
.tabs button.active { color: var(--purple-dark); background: var(--purple-light); font-weight: 600; }
.data-table td strong { display: block; }
.data-table td small { display: block; margin-top: 4px; }
.data-table td.wrap { white-space: normal; min-width: 180px; }
.data-table td.order-category { white-space: normal; min-width: 90px; max-width: 120px; }
.order-actions .button { display: block; width: 100%; }
.order-actions .button + .button { margin-top: 6px; }
.patient-list { max-height: 640px; overflow: auto; }
.patient-row { display: block; width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: var(--surface); text-align: left; }
.patient-row:hover { background: var(--surface-2); }
.patient-row.selected { padding-left: 15px; border-left: 3px solid var(--purple); background: var(--purple-light); }
.patient-row strong { display: block; margin: 6px 0; font-size: 13px; }
.patient-row .muted { line-height: 1.7; }
.patient-top { display: flex; justify-content: space-between; font-size: 12px; }
.patient-details { padding: 18px; border-bottom: 1px solid var(--line); }
.patient-details h2 { margin: 8px 0; }
.patient-details .meta { display: flex; flex-wrap: wrap; gap: 18px; color: var(--ink-3); font-size: 12px; }
.basket-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.basket-row input { width: 86px; }
.basket-row .actions { flex-wrap: nowrap; }
.basket-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.basket-foot { padding: 18px; background: var(--surface-2); }
input, select, textarea { max-width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none; color: var(--ink); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgb(124 58 237 / 10%); }
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
input[type=checkbox] { min-height: 18px; width: 18px; height: 18px; accent-color: var(--purple); }
label.field { display: flex; flex-direction: column; min-width: 0; gap: 6px; margin: 0; color: var(--ink-2); font-size: 12.5px; }
label.field > span { font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.full, .full { grid-column: 1 / -1; }
.form-section { margin: 18px 0; }
.form-lines { display: flex; flex-direction: column; gap: 10px; }
.form-line { display: grid; grid-template-columns: minmax(170px, 2fr) minmax(75px, .7fr) minmax(100px, 1fr) minmax(135px, 1fr) 36px; gap: 8px; align-items: end; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.form-line.simple { grid-template-columns: minmax(170px, 2fr) 100px 36px; }
.form-line.order-request { grid-template-columns: minmax(130px, 1fr) minmax(170px, 2fr) 100px 36px; }
.form-line.direct-receipt { grid-template-columns: minmax(120px, 1fr) minmax(150px, 1.5fr) minmax(75px, .6fr) minmax(135px, 1fr) 36px; }
.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.details-grid span { display: block; margin-bottom: 7px; color: var(--ink-3); font-size: 11px; }
.closing-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid #f1f1f3; }
.closing-row:last-child { border: 0; }
.closing-row strong { font-size: 13px; }
.closing-row .actions { justify-content: flex-end; }
.message { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.message p { margin: 8px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message small { color: var(--ink-3); font-size: 11px; }
.document-content { padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; white-space: pre-wrap; line-height: 1.8; overflow-wrap: anywhere; }
.erp-loading { padding: 80px 24px; text-align: center; color: var(--ink-3); }
#erp-dialog { width: min(820px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-lg); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
#erp-dialog::backdrop { background: rgb(17 24 39 / 45%); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 70px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 18px; }
.dialog-body { padding: 20px 22px; overflow: auto; max-height: 65dvh; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; min-height: 64px; padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface-2); }
#erp-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; max-width: 90%; padding: 14px 24px; border-radius: var(--radius-sm); color: #fff; background: var(--ink); box-shadow: var(--shadow-sm); font-size: 13px; }
.form-error { margin: 0 22px 12px; padding: 12px 16px; border-radius: var(--radius-sm); color: var(--red); background: var(--red-soft); font-size: 13px; }
input.search::before { content: none; }
input.search { min-width: 200px; flex: 1; min-height: 36px; font-size: 12px; }
.toolbar { margin-bottom: 16px; }
.stock-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)); gap: 8px; width: 488px; max-width: 100%; }
.stock-filters > select, .stock-filters > input.search { width: 100%; min-width: 0; height: 38px; min-height: 38px; padding: 8px 12px; font-size: 12px; border-radius: 8px; }
.stock-sort { display: inline-flex; align-items: center; gap: 7px; border: 0; padding: 0; background: transparent; color: inherit; font: inherit; text-align: left; white-space: nowrap; }
.stock-sort span { color: var(--ink-3); }
.stock-sort:hover, .stock-sort.selected, .stock-sort.selected span { color: var(--purple-dark); }

.spaced { justify-content: space-between; }
.check-sign { font-size: 11px; line-height: 1.6; }
.divider { margin: 20px 0; border: 0; border-top: 1px solid var(--line); }
.danger-text { color: var(--red); }
.good-text { color: var(--green); }
.no-wrap { white-space: nowrap; }
.checklist { display: flex; flex-direction: column; gap: 12px; }
.checklist label { display: flex; align-items: center; gap: 10px; font-size: 13px; }

@media (min-width: 1600px) {
  .outbound-grid { grid-template-columns: 280px minmax(0, 1fr); }
}
@media (max-width: 1150px) {
  .two-col { grid-template-columns: 1fr; }
  .outbound-grid { grid-template-columns: 1fr; }
  .outbound-patients .patient-list { display: flex; max-height: 200px; }
  .outbound-patients .patient-row { flex: 0 0 220px; }
}
@media (max-width: 860px) {
  body.sidebar-open { overflow: hidden; }
  .erp-header { align-items: flex-start; flex-direction: row; gap: 10px; }
  .erp-header h1 { font-size: 22px; }
  .erp-header .button { padding: 8px 10px; }
  .topbar-title > strong { font-size: 14px; }
  .outbound-grid { grid-template-columns: 1fr; }
  .patient-list { max-height: 260px; }
  .two-col { gap: 14px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .datebar { padding: 10px; }
  .datebar .date-heading { display: none; }
  .datebar > .actions:first-child { flex-wrap: nowrap; gap: 6px; }
  .datebar input { width: 144px; min-width: 0; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-line, .form-line.direct-receipt, .form-line.order-request { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form-line.simple { grid-template-columns: minmax(0, 1fr) 80px 36px; }
  .form-line > :first-child { grid-column: 1 / -1; }
  .form-line.category-line > :nth-child(2) { grid-column: 1 / -1; }
  .form-line.simple > :first-child { grid-column: auto; }
  .form-line > .remove-line { grid-column: 2; justify-self: end; }
  .form-line.simple > .remove-line { grid-column: auto; }
  .details-grid { grid-template-columns: 1fr 1fr; }
  .closing-row { align-items: flex-start; flex-direction: column; }
  .closing-row .actions { justify-content: flex-start; }
  .dialog-body { padding: 18px; }
  .dialog-header, .dialog-footer { padding-left: 18px; padding-right: 18px; }
  .metric { gap: 10px; padding: 12px 14px; }
  .metric .value { font-size: 17px; }
  input.search { min-width: 0; width: 100%; }
}
@media (max-width: 640px) {
  .outbound-workflow { grid-template-columns: minmax(0, 1fr); }
  .basket-row { flex-wrap: wrap; }
}
@media print {
  .erp-sidebar, .topbar, .sidebar-scrim, .erp-header .header-actions, .datebar, .toolbar, .no-print, #erp-toast, .dialog-footer, .dialog-header button { display: none !important; }
  .erp-workspace, .erp-main { margin: 0; padding: 0; }
  body { background: white; font-size: 11px; }
  .panel { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .data-table { white-space: normal; }
  #erp-dialog[open] { position: absolute; inset: 0; width: 100%; max-height: none; border: 0; box-shadow: none; }
  #erp-dialog[open] .dialog-body { max-height: none; overflow: visible; }
  body:has(dialog[open]) #erp-app { display: none; }
  #erp-dialog::backdrop { background: white; }
}

.receipt-history-filter { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }
.button.danger { color: var(--red); border-color: var(--red); background: var(--surface); }
