/* Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--text-secondary); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.grid-main-aside { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-5); align-items: start; }
.grid-aside-main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
/* The 260px sidebar eats into the viewport, so main/aside layouts only split once the content area itself is wide. */
@media (max-width: 1380px) { .grid-main-aside, .grid-aside-main { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* Shell ----------------------------------------------------------------- */
.hms-shell { display: flex; min-height: 100vh; }
.hms-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg-glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  transition: transform var(--duration) var(--ease);
}
.hms-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.hms-content { flex: 1; padding: var(--space-6) var(--space-8) var(--space-10); max-width: var(--content-max); width: 100%; margin: 0 auto; }
.hms-scrim { display: none; }
@media (max-width: 1024px) {
  .hms-sidebar { transform: translateX(-100%); box-shadow: none; }
  .nav-open .hms-sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .hms-main { margin-left: 0; }
  .hms-content { padding: var(--space-4) var(--space-4) var(--space-8); }
  .hms-scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity var(--duration); }
  .nav-open .hms-scrim { opacity: 1; pointer-events: auto; }
}

.hms-nav-brand { padding: var(--space-5) var(--space-4) var(--space-3); }
.hms-nav-logo { display: flex; align-items: center; gap: var(--space-3); color: var(--text); text-decoration: none !important; }
.hms-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #0a84ff, #5e5ce6); box-shadow: 0 6px 14px rgba(10,132,255,.3); flex-shrink: 0; }
.hms-nav-title { display: flex; flex-direction: column; min-width: 0; }
.hms-nav-title strong { font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hms-nav-title small { color: var(--text-secondary); font-size: var(--text-xs); }
.hms-nav { flex: 1; overflow-y: auto; padding: 0 var(--space-3) var(--space-3); }
.hms-nav-section { margin-top: var(--space-3); }
.hms-nav-section-title { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); padding: var(--space-3) var(--space-3) var(--space-1); }
.hms-nav-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; text-decoration: none !important; border: 0; background: none; cursor: pointer; text-align: left;
  transition: background var(--duration), color var(--duration);
}
.hms-nav-item:hover { background: var(--neutral-soft); color: var(--text); }
.hms-nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.hms-nav-item .hms-icon { flex-shrink: 0; }
.hms-nav-footer { padding: var(--space-3); border-top: 1px solid var(--divider); }
.hms-nav-user { display: flex; flex-direction: column; min-width: 0; }
.hms-nav-user strong { font-size: var(--text-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hms-nav-user small { font-size: var(--text-xs); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hms-nav-signout { margin: 0; }

.hms-topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-height);
  display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-8);
  background: var(--bg-glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 1024px) { .hms-topbar { padding: 0 var(--space-4); } }
.hms-nav-toggle { display: none; }
@media (max-width: 1024px) { .hms-nav-toggle { display: inline-flex; } }
.hms-topbar-search { flex: 1; max-width: 520px; }
.hms-topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.hms-branch-picker { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--text-secondary); }
.hms-select-plain { border: 0; background: transparent; font: inherit; font-weight: 500; color: var(--text); cursor: pointer; }
.hms-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500; }

.hms-global-search { position: relative; display: flex; align-items: center; gap: var(--space-2); height: 38px; padding: 0 var(--space-3); border-radius: var(--radius-sm); background: var(--neutral-soft); color: var(--text-secondary); }
.hms-global-search:focus-within { background: var(--surface); box-shadow: var(--ring); }
.hms-global-search-input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--text); outline: none; min-width: 0; }
.hms-global-search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; max-height: 360px; overflow: auto; }
.hms-global-search-item { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: 8px; border: 0; background: none; border-radius: var(--radius-sm); cursor: pointer; text-align: left; }
.hms-global-search-item:hover { background: var(--surface-hover); }
.hms-global-search-item span { display: flex; flex-direction: column; min-width: 0; }
.hms-global-search-item small { color: var(--text-secondary); }

/* Page ------------------------------------------------------------------ */
.hms-page { display: flex; flex-direction: column; gap: var(--space-5); animation: hms-rise .32s var(--ease); }
.hms-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.hms-page-heading { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hms-page-subtitle { color: var(--text-secondary); }
.hms-eyebrow { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-tertiary); }
.hms-back { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-sm); color: var(--text-secondary); }
.hms-page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.hms-page-toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.hms-page-body { display: flex; flex-direction: column; gap: var(--space-5); }
.hms-page-loading { display: grid; place-items: center; min-height: 50vh; }
@keyframes hms-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Cards ----------------------------------------------------------------- */
.hms-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden; }
.hms-card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--divider); }
.hms-card-heading { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.hms-card-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex-shrink: 0; }
.hms-card-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.hms-card-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.hms-card-flush .hms-card-body { padding: 0; gap: 0; }
.hms-card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--divider); background: var(--surface-hover); }

.hms-stat { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; color: inherit; text-decoration: none !important; }
.hms-stat-link:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); transition: all var(--duration) var(--ease); }
.hms-stat-top { display: flex; align-items: center; justify-content: space-between; }
.hms-stat-label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: 500; }
.hms-stat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--neutral-soft); color: var(--text-secondary); }
.hms-stat-accent .hms-stat-icon { background: var(--accent-soft); color: var(--accent-text); }
.hms-stat-success .hms-stat-icon { background: var(--success-soft); color: var(--success-text); }
.hms-stat-warning .hms-stat-icon { background: var(--warning-soft); color: var(--warning-text); }
.hms-stat-danger .hms-stat-icon { background: var(--danger-soft); color: var(--danger-text); }
.hms-stat-info .hms-stat-icon { background: var(--info-soft); color: var(--info-text); }
.hms-stat-value { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hms-stat-hint { font-size: var(--text-xs); color: var(--text-tertiary); }

/* Buttons --------------------------------------------------------------- */
.hms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 500; font-size: var(--text-sm); cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background var(--duration), color var(--duration), box-shadow var(--duration), transform var(--duration); user-select: none; }
.hms-btn:active { transform: scale(.98); }
.hms-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hms-btn-sm { height: 32px; padding: 0 12px; font-size: var(--text-sm); border-radius: 9px; }
.hms-btn-lg { height: 46px; padding: 0 22px; font-size: var(--text-md); border-radius: 12px; }
.hms-btn-block { width: 100%; }
.hms-btn-icon-only { padding: 0; width: 38px; }
.hms-btn-icon-only.hms-btn-sm { width: 32px; }
.hms-btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.15); }
.hms-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.hms-btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.hms-btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.hms-btn-ghost { background: transparent; color: var(--text-secondary); }
.hms-btn-ghost:hover:not(:disabled) { background: var(--neutral-soft); color: var(--text); }
.hms-btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.hms-btn-soft:hover:not(:disabled) { background: rgba(10,132,255,.2); }
.hms-btn-danger { background: var(--danger); color: #fff; }
.hms-btn-danger:hover:not(:disabled) { filter: brightness(.95); }
.hms-btn-success { background: var(--success); color: #fff; }
.hms-icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; transition: background var(--duration); }
.hms-icon-button:hover { background: var(--neutral-soft); color: var(--text); }
.hms-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* Badges & chips -------------------------------------------------------- */
.hms-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--neutral-soft); color: var(--text-secondary); }
.hms-badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.hms-badge-success { background: var(--success-soft); color: var(--success-text); }
.hms-badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.hms-badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.hms-badge-info { background: var(--info-soft); color: var(--info-text); }
.hms-badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.hms-badge-lg { font-size: var(--text-sm); padding: 4px 12px; }

/* Tables ---------------------------------------------------------------- */
.hms-table-wrap { position: relative; overflow-x: auto; }
.hms-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.hms-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); padding: 10px var(--space-4); background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; }
.hms-table th.sortable { cursor: pointer; user-select: none; }
.hms-table th.sortable:hover { color: var(--text); }
.hms-table th .hms-icon { vertical-align: middle; margin-left: 4px; }
.hms-table td { padding: 12px var(--space-4); border-bottom: 1px solid var(--divider); vertical-align: middle; }
.hms-table tr:last-child td { border-bottom: 0; }
.hms-table tbody tr.clickable { cursor: pointer; }
.hms-table tbody tr.clickable:hover td { background: var(--surface-hover); }
.hms-table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.hms-table .align-center { text-align: center; }
.hms-table-wrap.compact td { padding: 8px var(--space-3); }
.hms-table-loading { padding: var(--space-5); }
.hms-table-refreshing { position: absolute; top: 8px; right: 8px; }
.hms-cell-title { font-weight: 500; color: var(--text); }
.hms-cell-sub { display: block; font-size: var(--text-xs); color: var(--text-tertiary); }
.hms-pager { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--divider); }
.hms-pager-buttons { display: flex; align-items: center; gap: 4px; }
.hms-pager-page { font-size: var(--text-sm); color: var(--text-secondary); min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }

/* Forms ----------------------------------------------------------------- */
.hms-form { display: flex; flex-direction: column; gap: var(--space-4); }
.hms-form-body { display: contents; }
.hms-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4); }
.hms-form-grid > .hms-field { grid-column: span 12; }
.hms-form-grid > .span-6 { grid-column: span 6; }
.hms-form-grid > .span-4 { grid-column: span 4; }
.hms-form-grid > .span-3 { grid-column: span 3; }
.hms-form-grid > .span-8 { grid-column: span 8; }
@media (max-width: 640px) { .hms-form-grid > .hms-field { grid-column: span 12 !important; } }
.hms-form-section { display: flex; flex-direction: column; gap: var(--space-3); padding-top: var(--space-2); }
.hms-form-section-title { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-tertiary); }
.hms-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hms-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.hms-required { color: var(--danger); }
.hms-label-hint { margin-left: auto; font-weight: 400; color: var(--text-tertiary); font-size: var(--text-xs); }
.hms-control { position: relative; display: flex; align-items: center; }
.hms-control.has-adornment .hms-input { padding-left: 36px; }
.hms-adornment { position: absolute; left: 12px; color: var(--text-tertiary); font-size: var(--text-sm); pointer-events: none; }
.hms-input, .hms-select, textarea.hms-input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--text-md); transition: border-color var(--duration), box-shadow var(--duration), background var(--duration);
}
textarea.hms-input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.hms-input:hover, .hms-select:hover { border-color: var(--text-tertiary); }
.hms-input:focus, .hms-select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
/* Invalid: set by Blazor on bound inputs, and by HmsField on its wrapper so raw inputs, lookups and segmented pickers match. */
.hms-input.invalid, .hms-select.invalid,
.hms-field.invalid .hms-input, .hms-field.invalid .hms-select, .hms-field.invalid .hms-lookup-selected { border-color: var(--danger); }
.hms-input.invalid:focus, .hms-select.invalid:focus,
.hms-field.invalid .hms-input:focus, .hms-field.invalid .hms-select:focus { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.hms-field.invalid .hms-segmented, .hms-field.invalid .hms-list { box-shadow: inset 0 0 0 1px var(--danger); }
.hms-field.invalid > .hms-label { color: var(--danger-text); }
.hms-input:disabled, .hms-select:disabled { background: var(--bg-sunken); color: var(--text-tertiary); cursor: not-allowed; }
.hms-select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
input[type="date"].hms-input, input[type="time"].hms-input { padding-right: 8px; }
.hms-validation { font-size: var(--text-xs); color: var(--danger-text); }
.hms-help { font-size: var(--text-xs); color: var(--text-tertiary); }
.hms-checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); cursor: pointer; }
.hms-checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }
.hms-form-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--divider); flex-wrap: wrap; }
.hms-form-footer-actions { display: flex; gap: var(--space-2); margin-left: auto; }
.hms-order-1 { order: 1; }
.hms-order-2 { order: 2; }
.hms-order-3 { order: 3; }
.hms-alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.hms-alert strong { display: block; margin-bottom: 2px; }
.hms-alert-info { background: var(--info-soft); color: var(--info-text); }
.hms-alert-success { background: var(--success-soft); color: var(--success-text); }
.hms-alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.hms-alert-danger { background: var(--danger-soft); color: var(--danger-text); }
.hms-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-sm); }
.hms-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.hms-toggle-track { width: 42px; height: 26px; border-radius: 13px; background: var(--border-strong); position: relative; transition: background var(--duration); }
.hms-toggle-thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--duration) var(--ease); }
.hms-toggle input:checked + .hms-toggle-track { background: var(--success); }
.hms-toggle input:checked + .hms-toggle-track .hms-toggle-thumb { transform: translateX(16px); }
.hms-toggle.disabled { opacity: .5; cursor: not-allowed; }

/* Lookup ---------------------------------------------------------------- */
.hms-lookup { position: relative; }
.hms-lookup-input { position: relative; display: flex; align-items: center; }
.hms-lookup-input > .hms-icon { position: absolute; left: 12px; color: var(--text-tertiary); pointer-events: none; }
.hms-lookup-input .hms-input { padding-left: 36px; }
.hms-lookup-input .hms-spinner { position: absolute; right: 12px; }
.hms-lookup-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; max-height: 300px; overflow: auto; animation: hms-pop .16s var(--ease); }
.hms-lookup-option, .hms-lookup-create { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.hms-lookup-option span { display: flex; flex-direction: column; min-width: 0; }
.hms-lookup-option small { color: var(--text-secondary); font-size: var(--text-xs); }
.hms-lookup-option:hover, .hms-lookup-option.highlight { background: var(--surface-hover); }
.hms-lookup-create { color: var(--accent-text); font-weight: 500; border-top: 1px solid var(--divider); border-radius: 0 0 8px 8px; margin-top: 4px; }
.hms-lookup-create:hover { background: var(--accent-soft); }
.hms-lookup-empty { padding: 10px; font-size: var(--text-sm); }
.hms-lookup-selected { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 6px 8px 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent-soft); }
.hms-lookup-selected-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hms-lookup-selected-text small { color: var(--text-secondary); font-size: var(--text-xs); }
.hms-lookup-clear { border: 0; background: none; cursor: pointer; color: var(--text-secondary); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; }
.hms-lookup-clear:hover { background: rgba(0,0,0,.06); color: var(--text); }
@keyframes hms-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* Search box, segmented, tabs, menus ------------------------------------ */
.hms-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-tertiary); min-width: 240px; }
.hms-search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.hms-search input { flex: 1; border: 0; background: transparent; font: inherit; color: var(--text); outline: none; min-width: 0; }
.hms-search-clear { border: 0; background: none; color: var(--text-tertiary); cursor: pointer; display: grid; place-items: center; }
.hms-segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--neutral-soft); gap: 2px; }
.hms-segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all var(--duration); white-space: nowrap; }
.hms-segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.hms-tab-count { font-size: var(--text-xs); padding: 0 6px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--text-secondary); min-width: 18px; text-align: center; }
.hms-tabs-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.hms-tab { border: 0; background: none; padding: 10px 14px; font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color var(--duration); }
.hms-tab:hover { color: var(--text); }
.hms-tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.hms-tabs-panel { padding-top: var(--space-4); }
.hms-menu { position: relative; display: inline-block; }
.hms-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 200px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; animation: hms-pop .16s var(--ease); }
.hms-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; font: inherit; font-size: var(--text-sm); color: var(--text); text-align: left; text-decoration: none !important; }
.hms-menu-item:hover:not(:disabled) { background: var(--surface-hover); }
.hms-menu-item:disabled { opacity: .5; cursor: not-allowed; }
.hms-menu-item.destructive { color: var(--danger-text); }
.hms-date-nav { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); position: relative; }
.hms-date-nav-label { border: 0; background: none; font: inherit; font-weight: 600; padding: 0 10px; cursor: pointer; min-width: 110px; }
.hms-date-nav-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* Modal ----------------------------------------------------------------- */
.hms-modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: var(--space-6); background: rgba(0,0,0,.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: hms-fade .18s var(--ease); }
.hms-modal { width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--bg-elevated); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: hms-scale .22s var(--ease); overflow: hidden; }
.hms-modal-small { max-width: 440px; }
.hms-modal-medium { max-width: 640px; }
.hms-modal-large { max-width: 860px; }
.hms-modal-extralarge { max-width: 1120px; }
.hms-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6) var(--space-3); }
.hms-modal-header h2 { font-size: var(--text-lg); }
.hms-modal-body { padding: var(--space-2) var(--space-6) var(--space-6); overflow-y: auto; }
.hms-dialog-message { color: var(--text-secondary); margin-bottom: var(--space-3); }
@media (max-width: 640px) { .hms-modal-backdrop { padding: 0; align-items: end; } .hms-modal { max-height: 94vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; } }
@keyframes hms-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hms-scale { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* Toasts ---------------------------------------------------------------- */
.hms-toasts { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); width: min(380px, calc(100vw - 32px)); }
.hms-toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: var(--radius-md); background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: hms-slide .25s var(--ease); }
.hms-toast-text { flex: 1; display: flex; flex-direction: column; font-size: var(--text-sm); }
.hms-toast-text span { color: var(--text-secondary); }
.hms-toast-success > .hms-icon { color: var(--success); }
.hms-toast-warning > .hms-icon { color: var(--warning); }
.hms-toast-danger > .hms-icon { color: var(--danger); }
.hms-toast-info > .hms-icon { color: var(--accent); }
@keyframes hms-slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* Misc ------------------------------------------------------------------ */
.hms-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: var(--space-10) var(--space-5); color: var(--text-secondary); }
.hms-empty-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--neutral-soft); color: var(--text-tertiary); }
.hms-empty h4 { color: var(--text); }
.hms-empty-actions { margin-top: var(--space-2); display: flex; gap: var(--space-2); }
.hms-spinner { display: inline-block; width: var(--size, 22px); height: var(--size, 22px); border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: hms-spin .8s linear infinite; }
@keyframes hms-spin { to { transform: rotate(360deg); } }
.hms-skeleton-group { display: flex; flex-direction: column; gap: 10px; }
.hms-skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--neutral-soft) 25%, var(--surface-active) 37%, var(--neutral-soft) 63%); background-size: 400% 100%; animation: hms-shimmer 1.4s ease infinite; }
@keyframes hms-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.hms-avatar { display: inline-grid; place-items: center; width: var(--size, 36px); height: var(--size, 36px); border-radius: 50%; font-size: calc(var(--size, 36px) * .36); font-weight: 600; color: hsl(var(--hue), 55%, 32%); background: hsl(var(--hue), 70%, 90%); flex-shrink: 0; letter-spacing: .02em; }
:root[data-theme="dark"] .hms-avatar { color: hsl(var(--hue), 70%, 85%); background: hsl(var(--hue), 40%, 24%); }
.hms-details { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.hms-details.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-5); }
.hms-details.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--space-5); }
@media (max-width: 640px) { .hms-details.cols-2, .hms-details.cols-3 { grid-template-columns: 1fr; } }
.hms-detail { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.hms-detail dt { font-size: var(--text-xs); color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.hms-detail dd { margin: 0; font-size: var(--text-sm); color: var(--text); }
.hms-error-panel { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-10); color: var(--danger-text); }
.hms-error-panel h2 { color: var(--text); }
.hms-divider { height: 1px; background: var(--divider); margin: var(--space-2) 0; }
.hms-list { display: flex; flex-direction: column; }
.hms-list-item { display: flex; align-items: center; gap: var(--space-3); padding: 12px 0; border-bottom: 1px solid var(--divider); }
.hms-list-item:last-child { border-bottom: 0; }
.hms-list-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hms-list-item-title { font-weight: 500; }
.hms-list-item-sub { font-size: var(--text-xs); color: var(--text-secondary); }
.hms-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
.hms-token { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.hms-token-lg { min-width: 88px; height: 88px; font-size: 36px; border-radius: 22px; }
.hms-money { font-variant-numeric: tabular-nums; font-weight: 600; }
.hms-blink { animation: hms-blink 1.4s ease-in-out infinite; }
@keyframes hms-blink { 50% { opacity: .35; } }

/* Patient banner -------------------------------------------------------- */
.hms-patient-banner { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); flex-wrap: wrap; }
.hms-patient-banner.deceased { border-color: var(--danger); }
.hms-patient-banner-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.hms-patient-banner-name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hms-patient-banner-name a { font-size: var(--text-lg); font-weight: 600; color: var(--text); }
.hms-patient-banner-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.hms-patient-banner-allergies { display: flex; gap: 6px; flex-wrap: wrap; max-width: 360px; }
.hms-patient-banner-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Bed board ------------------------------------------------------------- */
.hms-bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.hms-bed { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; transition: box-shadow var(--duration), transform var(--duration); min-height: 96px; }
.hms-bed:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.hms-bed.selected { border-color: var(--accent); box-shadow: var(--ring); }
.hms-bed-code { font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.hms-bed-status { font-size: var(--text-xs); }
.hms-bed-available { border-left: 4px solid var(--success); }
.hms-bed-occupied { border-left: 4px solid var(--accent); }
.hms-bed-reserved { border-left: 4px solid var(--info); }
.hms-bed-cleaning { border-left: 4px solid var(--warning); }
.hms-bed-outofservice { border-left: 4px solid var(--text-tertiary); opacity: .7; }
.hms-bed-patient { font-size: var(--text-xs); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Queue ----------------------------------------------------------------- */
.hms-queue-card { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); }
.hms-queue-card.priority { border-color: var(--warning); }
.hms-queue-card.emergency { border-color: var(--danger); background: var(--danger-soft); }
.hms-slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.hms-slot { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 8px 4px; font-size: var(--text-sm); font-weight: 500; cursor: pointer; font-variant-numeric: tabular-nums; transition: all var(--duration); }
.hms-slot:hover:not(:disabled) { border-color: var(--accent); }
.hms-slot.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.hms-slot:disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }

/* Auth pages ------------------------------------------------------------ */
.hms-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 480px) 1fr; }
.hms-auth-panel { display: flex; flex-direction: column; justify-content: center; gap: var(--space-8); padding: var(--space-10); background: var(--surface); }
.hms-auth-brand { display: flex; align-items: center; gap: var(--space-3); }
.hms-auth-tenant { font-weight: 600; font-size: var(--text-lg); }
.hms-auth-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 380px; }
.hms-auth-form h1 { font-size: var(--text-xl); }
.hms-auth-links { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); }
.hms-auth-art { display: flex; align-items: center; justify-content: center; padding: var(--space-10); background: radial-gradient(1200px 600px at 20% 0%, rgba(10,132,255,.18), transparent 60%), radial-gradient(900px 600px at 90% 100%, rgba(94,92,230,.18), transparent 60%), var(--bg); }
.hms-auth-art-card { max-width: 420px; padding: var(--space-8); border-radius: var(--radius-lg); background: var(--bg-glass); border: 1px solid var(--border); backdrop-filter: blur(20px); display: flex; flex-direction: column; gap: var(--space-3); color: var(--text-secondary); }
.hms-auth-art-card h2 { color: var(--text); letter-spacing: -0.02em; }
.hms-auth-art-card .hms-icon { color: var(--accent); }
@media (max-width: 900px) { .hms-auth { grid-template-columns: 1fr; } .hms-auth-art { display: none; } .hms-auth-panel { padding: var(--space-6); } }
.hms-recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-family: var(--font-mono); }
.hms-recovery-codes code { padding: 8px 12px; border-radius: 8px; background: var(--neutral-soft); text-align: center; }
.hms-qr { display: grid; place-items: center; padding: var(--space-4); background: #fff; border-radius: var(--radius-md); border: 1px solid var(--border); width: fit-content; }
.hms-manage { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
@media (max-width: 800px) { .hms-manage { grid-template-columns: 1fr; } }

/* Print ----------------------------------------------------------------- */
.hms-print { max-width: 820px; margin: 0 auto; padding: var(--space-8); background: #fff; color: #111; font-size: 13px; }
.hms-print h1 { font-size: 22px; }
.hms-print table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.hms-print th, .hms-print td { padding: 6px 8px; border-bottom: 1px solid #e5e5e5; text-align: left; }
.hms-print th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #666; }
.hms-print-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 16px; }
.hms-print-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; margin: 12px 0; }
.hms-print-meta div { font-size: 12px; }
.hms-print-meta b { display: block; color: #666; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.hms-print-footer { margin-top: 32px; display: flex; justify-content: space-between; font-size: 11px; color: #666; }
.hms-print-signature { margin-top: 48px; text-align: right; }
.hms-print-signature span { display: inline-block; border-top: 1px solid #111; padding-top: 6px; min-width: 200px; }
.hms-print-toolbar { max-width: 820px; margin: var(--space-5) auto 0; display: flex; gap: 8px; justify-content: flex-end; }
@media print {
  body { background: #fff; }
  .hms-print-toolbar, .hms-sidebar, .hms-topbar, .hms-toasts, #blazor-error-ui { display: none !important; }
  .hms-main { margin: 0; }
  .hms-content { padding: 0; max-width: none; }
  .hms-print { padding: 0; }
}

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: 12px 20px; background: var(--warning-soft); color: var(--warning-text); border-top: 1px solid var(--warning); font-size: var(--text-sm); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

.hms-print { color: #111; }
:root[data-theme="dark"] .hms-print, .hms-print { background: #fff; }

/* Order tests popup: details and selection on the left, browsable catalogue on the right. */
.hms-lab-order { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--space-6); align-items: start; }
.hms-lab-order-catalogue { position: sticky; top: 0; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--bg-sunken); border: 1px solid var(--border); }
.hms-lab-order-catalogue .hms-search { min-width: 0; }
.hms-lab-order-categories { display: flex; flex-wrap: wrap; gap: 6px; }
.hms-lab-order-categories .hms-chip { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: var(--text-sm); }
.hms-lab-order-categories .hms-chip.active { background: var(--accent); color: #fff; }
.hms-lab-order-list { display: flex; flex-direction: column; gap: 2px; max-height: min(52vh, 520px); overflow-y: auto; margin: 0 calc(-1 * var(--space-2)); padding: 0 var(--space-2); }
.hms-lab-order-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.hms-lab-order-option:hover { background: var(--surface); border-color: var(--border); }
.hms-lab-order-option.selected { background: var(--accent-soft); border-color: var(--accent); }
.hms-lab-order-check { flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); color: #fff; }
.hms-lab-order-option.selected .hms-lab-order-check { background: var(--accent); border-color: var(--accent); }
.hms-lab-order-option-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hms-lab-order-option-name { font-weight: 600; }
.hms-lab-order-selected { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 260px; overflow-y: auto; }
.hms-lab-order-selected-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 4px 12px; border-bottom: 1px solid var(--border); }
.hms-lab-order-selected-row:last-child { border-bottom: 0; }
@media (max-width: 900px) { .hms-lab-order { grid-template-columns: 1fr; } .hms-lab-order-catalogue { position: static; } }

/* Reimbursement documents: one claim document per printed page, preparation panel only on screen. */
.hms-claim-panel { margin-bottom: 20px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--bg-sunken); color: var(--text); }
.hms-claim-panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.hms-claim-panel-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.hms-claim-panel-wide { grid-column: 1 / -1; }
.hms-claim-doc { min-height: 960px; display: flex; flex-direction: column; }
.hms-claim-doc + .hms-claim-doc { margin-top: 40px; padding-top: 40px; border-top: 2px dashed #cbd5e1; }
.hms-claim-ref { margin: 18px 0 6px; font-size: 13px; }
.hms-claim-title { margin: 18px 0 10px; text-align: center; font-size: 18px; text-decoration: underline; letter-spacing: .02em; }
.hms-claim-subtitle { margin: 2px 0 10px; text-align: center; font-size: 16px; text-decoration: underline; }
.hms-claim-body { font-size: 13.5px; line-height: 1.8; text-align: justify; text-indent: 48px; }
.hms-lab-report table.hms-claim-table { border: 1px solid #333; margin: 10px 0; }
.hms-lab-report .hms-claim-table th, .hms-lab-report .hms-claim-table td { border: 1px solid #333; padding: 6px 10px; font-size: 13px; }
.hms-claim-total td { font-weight: 700; }
.hms-claim-signature { margin-top: auto; margin-left: auto; padding-top: 48px; display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: 12.5px; gap: 2px; }
.hms-claim-sign-line { width: 220px; height: 36px; border-bottom: 1px solid #111; margin-bottom: 4px; }
@media print {
  .hms-claim-panel { display: none !important; }
  .hms-claim-doc { min-height: calc(100vh - 2px); }
  .hms-claim-doc + .hms-claim-doc { break-before: page; margin-top: 0; padding-top: 0; border-top: 0; }
}
@media (max-width: 640px) { .hms-claim-panel-grid { grid-template-columns: 1fr; } }

/* Lab report in the letterhead format Indian diagnostic labs print: boxed patient block, department banners, End Of Report. */
.hms-lab-report { --lab-accent: #1e3a8a; --lab-name: #b91c1c; font-size: 12.5px; }
.hms-lab-letterhead { display: flex; align-items: center; gap: 16px; padding-bottom: 10px; border-bottom: 3px double var(--lab-accent); }
.hms-lab-letterhead img { width: 76px; height: 76px; object-fit: contain; }
.hms-lab-letterhead-text { flex: 1; text-align: center; }
.hms-lab-report .hms-lab-letterhead h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; letter-spacing: .04em; color: var(--lab-name); text-transform: uppercase; }
.hms-lab-band { display: inline-block; margin: 4px 0; padding: 2px 14px; background: var(--lab-accent); color: #fff; font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.hms-lab-address { font-size: 12.5px; color: #222; }
.hms-lab-amended { border: 1px solid #111; padding: 6px 10px; margin-top: 10px; font-size: 12px; }
.hms-lab-patient { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin-top: 12px; padding: 8px 12px; border: 1px solid #555; }
.hms-lab-patient dl { display: grid; grid-template-columns: 128px 1fr; gap: 3px 8px; margin: 0; }
.hms-lab-patient dt { color: #333; }
.hms-lab-patient dt::after { content: " :"; }
.hms-lab-patient dd { margin: 0; }
.hms-lab-section { margin-top: 14px; break-inside: auto; }
.hms-lab-department { border: 1px solid #555; padding: 4px; text-align: center; font-weight: 700; letter-spacing: .06em; }
.hms-lab-report table { margin-top: 0; }
.hms-lab-report th { color: #111; font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 700; border-bottom: 1px solid #111; padding: 6px 8px; }
.hms-lab-report td { border-bottom: none; padding: 3px 8px; vertical-align: top; }
.hms-lab-test { break-inside: avoid; }
.hms-lab-test-name { font-weight: 700; padding-top: 8px; }
.hms-lab-test-name td { padding-top: 8px; }
.hms-lab-indent { padding-left: 18px !important; }
.hms-lab-subheading td { padding-top: 6px; padding-left: 18px; font-weight: 600; font-size: 11px; text-transform: uppercase; color: #333; }
.hms-lab-abnormal { font-weight: 700; }
.hms-lab-remark td { padding-left: 18px; font-size: 11.5px; color: #333; }
.hms-lab-end { margin-top: 18px; text-align: center; font-family: Georgia, "Times New Roman", serif; }
.hms-lab-signatures { display: flex; justify-content: space-between; gap: 24px; margin-top: 48px; break-inside: avoid; }
.hms-lab-signatures > div { display: flex; flex-direction: column; align-items: center; min-width: 200px; padding-top: 6px; border-top: 1px solid #111; font-size: 12px; text-align: center; }
.hms-lab-signatures > div:only-child { margin-left: auto; }
.hms-lab-footer { margin-top: 20px; padding-top: 8px; border-top: 1px solid #999; font-size: 11.5px; text-align: center; color: #222; }
.hms-lab-note { font-weight: 600; color: var(--lab-accent); margin-bottom: 4px; }
.hms-lab-generated { margin-top: 4px; color: #777; font-size: 10.5px; }

/* Billing block inside walk-in / check-in dialogs */
.hms-charge-panel { width: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius-md); background: var(--bg-sunken); border: 1px solid var(--border); }
.hms-charge-summary { display: flex; flex-direction: column; gap: 4px; padding: var(--space-3) 0 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.hms-charge-summary > div { display: flex; justify-content: space-between; font-size: var(--text-sm); color: var(--text-secondary); }
.hms-charge-summary > div.strong { color: var(--text); font-size: var(--text-md); font-weight: 600; padding-top: 4px; }
.hms-lookup-with-action { display: flex; gap: var(--space-2); align-items: flex-start; }
.hms-lookup-with-action > :first-child { flex: 1; min-width: 0; }

/* Billing counter (cashier desk) */
.counter-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-4); align-items: start; }
@media (max-width: 1100px) { .counter-layout { grid-template-columns: 1fr; } }
.counter-queue-item { width: 100%; text-align: left; background: none; border: 0; cursor: pointer; border-radius: var(--radius-md); font: inherit; color: inherit; }
.counter-queue-item:hover { background: var(--surface-hover); }
.counter-queue-item.active { background: var(--accent-soft); }
.counter-bill.unselected { opacity: .6; }
.counter-check { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.counter-pay-row { display: grid; grid-template-columns: 150px 170px auto minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
@media (max-width: 640px) { .counter-pay-row { grid-template-columns: 1fr 1fr; } }
.counter-advance { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; }

/* Flow hand-offs: bench tabs that wrap on narrow screens, inline result tables inside list items. */
.hms-segmented-wide { flex-wrap: wrap; width: 100%; }
.hms-next-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.hms-next-steps .hms-badge { font-size: var(--text-sm); }
.hms-inline-results { margin: 6px 0 0; width: 100%; }

/* Count-sheet rows with a variance against the record. */
.hms-table tbody tr.hms-row-warning td { background: color-mix(in srgb, var(--warning) 10%, transparent); }

/* Patient 360: grouped action menu, care status strip and the visit track. */
.hms-menu-heading { padding: 8px 10px 4px; font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tertiary); }
.hms-menu-heading:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--divider); padding-top: 10px; }
.hms-menu-list:has(.hms-menu-heading) { min-width: 260px; max-height: min(70vh, 640px); overflow-y: auto; }
.hms-care-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.hms-care-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); font-size: var(--text-sm); text-decoration: none !important; }
a.hms-care-chip[href]:hover { background: var(--surface-hover); }
.hms-care-chip.success { background: var(--success-soft); border-color: transparent; color: var(--success-text); }
.hms-care-chip.warning { background: var(--warning-soft); border-color: transparent; color: var(--warning-text); }
.hms-care-chip.info { background: var(--info-soft); border-color: transparent; color: var(--info-text); }
.hms-care-chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.hms-visit-toolbar { margin-bottom: var(--space-2); }
.hms-visit-track { position: relative; display: flex; flex-direction: column; gap: var(--space-3); padding-left: 22px; }
.hms-visit-track::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--divider); }
.hms-visit { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.hms-visit-dot { position: absolute; left: -21px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text-tertiary); }
.hms-visit.live .hms-visit-dot { border-color: var(--success); background: var(--success); }
.hms-visit.ipd .hms-visit-dot { border-color: var(--accent); }
.hms-visit-head { display: flex; align-items: center; gap: var(--space-4); width: 100%; padding: 12px 14px; border: 0; background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: var(--radius-md); }
.hms-visit-head:hover { background: var(--surface-hover); }
.hms-visit-when { display: flex; flex-direction: column; min-width: 96px; font-size: var(--text-sm); }
.hms-visit-when span { color: var(--text-tertiary); font-size: var(--text-xs); }
.hms-visit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hms-visit-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 500; }
.hms-visit-sub { font-size: var(--text-xs); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hms-visit-body { padding: 0 14px 14px; border-top: 1px solid var(--divider); }
.hms-visit-actions { flex-wrap: wrap; gap: 8px; padding: 10px 0; }
.hms-visit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-5); }
.hms-visit-section { min-width: 0; }
.hms-visit-section.wide { grid-column: 1 / -1; }
.hms-visit-section h4 { margin: 0 0 6px; font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tertiary); }
.hms-visit-chips { flex-wrap: wrap; gap: 6px; }
.hms-visit-dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: var(--text-sm); }
.hms-visit-dl dt { color: var(--text-secondary); font-weight: 500; }
.hms-visit-dl dd { margin: 0; white-space: pre-wrap; }
.hms-visit-text { margin: 0; font-size: var(--text-sm); white-space: pre-wrap; }
.hms-visit-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); }
.hms-visit-note { padding: 8px 10px; margin-bottom: 6px; border-radius: var(--radius-sm); background: var(--bg-sunken); display: flex; flex-direction: column; gap: 4px; }
.hms-visit-lab { padding: 6px 0; border-bottom: 1px solid var(--divider); font-size: var(--text-sm); gap: var(--space-3); }
.hms-visit-lab:last-child { border-bottom: 0; }
@media (max-width: 760px) {
    .hms-visit-grid { grid-template-columns: 1fr; }
    .hms-visit-head { flex-wrap: wrap; gap: var(--space-2); }
}
