/* HMS2 — clinical workstation shell (MRS-inspired, original brand) */
:root {
  --side: #2b333d;
  --side-2: #232a32;
  --side-text: #c8d0d8;
  --side-muted: #8b96a3;
  --brand: #1a6fd4;
  --brand-2: #155db3;
  --brand-soft: #e8f1fc;
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --side-w: 64px;           /* collapsed home rail */
  --side-w-full: 232px;     /* expanded on hover */
  --quick-w: 220px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* Critical: unstyled SVGs default to ~300×150 and break the layout */
svg {
  display: inline-block;
  vertical-align: middle;
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ========== Shell ========== */
/* Fixed icon rail + main content offset so pages never sit under the menu */
.shell {
  display: block;
  min-height: 100vh;
  position: relative;
}

/* Dark left rail — icon strip by default; full Home menu on hover (overlays content) */
.sidebar {
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: var(--side-text);
  padding: 1.1rem 0.55rem 1.5rem;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  height: 100vh;
  width: var(--side-w);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 45;
  transition: width 0.22s ease, box-shadow 0.22s ease, padding 0.22s ease;
}
.sidebar:hover,
.sidebar:focus-within {
  width: var(--side-w-full);
  padding: 1.1rem 0.75rem 1.5rem;
  box-shadow: 10px 0 28px rgba(15, 23, 42, 0.22);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.35rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.85rem;
  min-height: 52px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.35);
}
.sidebar:hover .brand-mark,
.sidebar:focus-within .brand-mark {
  margin: 0;
}
.brand-mark svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.2;
}
.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.brand-text {
  min-width: 0;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.18s ease, max-width 0.22s ease;
}
.sidebar:hover .brand-text,
.sidebar:focus-within .brand-text {
  opacity: 1;
  max-width: 180px;
}
.brand strong {
  display: block;
  color: #fff;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.brand small {
  color: var(--side-muted);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: none;
}
.login-brand .brand-mark {
  width: 52px;
  height: 52px;
  margin: 0;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  border: 1px solid var(--line);
}
.login-brand .brand-text {
  opacity: 1;
  max-width: none;
  overflow: visible;
  white-space: normal;
}

.nav-section {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--side-muted);
  padding: 0.85rem 0.7rem 0.35rem;
  white-space: nowrap;
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  transition: opacity 0.15s ease, max-height 0.2s ease, padding 0.2s ease;
}
.sidebar:hover .nav-section,
.sidebar:focus-within .nav-section {
  opacity: 1;
  max-height: 3rem;
  padding: 0.85rem 0.7rem 0.35rem;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.55rem;
  border-radius: 10px;
  color: var(--side-text);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.12rem;
  transition: background .15s, color .15s, padding .2s;
  justify-content: center;
  white-space: nowrap;
}
.sidebar:hover .nav a,
.sidebar:focus-within .nav a {
  justify-content: flex-start;
  padding: 0.7rem 0.75rem;
}
.nav a svg {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  opacity: 0.95;
}
.nav-label {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.15s ease, max-width 0.22s ease;
}
.sidebar:hover .nav-label,
.sidebar:focus-within .nav-label {
  opacity: 1;
  max-width: 180px;
}
.nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.nav a.active {
  background: rgba(26, 111, 212, 0.22);
  color: #fff;
}
.nav a.active svg { stroke: #7cb4f5; }

/* Language switcher */
.nav-lang {
  padding: 0.35rem 0.55rem 0.65rem;
}
.nav-lang-label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--side-muted);
  margin-bottom: 0.3rem;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}
.sidebar:hover .nav-lang-label,
.sidebar:focus-within .nav-lang-label {
  opacity: 1;
  max-height: 2rem;
}
.nav-lang-select {
  width: 100%;
  margin: 0 !important;
  padding: 0.4rem 0.45rem !important;
  font-size: 0.75rem !important;
  background: rgba(255,255,255,0.08) !important;
  border-color: rgba(255,255,255,0.12) !important;
  color: #e2e8f0 !important;
}
.nav-lang-select option { color: #0f172a; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.lang-chip-select {
  margin: 0 !important;
  padding: 0.4rem 0.55rem !important;
  font-size: 0.78rem !important;
  font-weight: 650;
  border-radius: 999px !important;
  background: #fff;
  border: 1px solid #dbe7f5 !important;
  color: #1e40af;
  max-width: 160px;
}
body.lang-km,
body.lang-th,
body.lang-lo,
body.lang-my {
  line-height: 1.55;
}

/* Main column — always leave room for collapsed rail */
.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--side-w);
  width: calc(100% - var(--side-w));
  max-width: calc(100% - var(--side-w));
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

/* Service tabs */
.service-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.85rem 1.25rem 0.5rem;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 30;
}
.service-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  background: #e4e9ef;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.service-tabs a:hover { background: #d8dee6; }
.service-tabs a.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px rgba(26, 111, 212, 0.28);
}
.service-tabs a svg {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.25rem 0.75rem;
}
.sub-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}
.sub-tabs a svg {
  width: 15px;
  height: 15px;
  min-width: 15px;
  min-height: 15px;
}
.sub-tabs a.active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

/* Top bar inside content */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem 0.85rem;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}
.topbar .meta { color: var(--muted); font-size: 0.86rem; margin-top: 0.15rem; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem 0.4rem 0.4rem;
  font-size: 0.84rem;
  box-shadow: var(--shadow);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 0.75rem;
}

/* Work area: quick launch + content */
.work {
  display: grid;
  grid-template-columns: var(--quick-w) 1fr;
  gap: 0;
  flex: 1;
  padding: 0 1rem 1.25rem 0.75rem;
  min-height: 0;
}
.work.no-quick {
  grid-template-columns: 1fr;
  padding-left: 1.25rem;
}

.quick {
  background: transparent;
  padding: 0 0.65rem 1rem 0.5rem;
}
.quick-card {
  background: #f7f9fc;
  border: 1px solid #e5ebf2;
  border-radius: var(--radius);
  padding: 0.85rem 0.75rem 1rem;
}
.quick-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  margin: 0 0 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.quick-group {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.75rem 0 0.4rem;
  padding-left: 0.15rem;
}
.ql-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.ql-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.65rem 0.35rem;
  background: #fff;
  border: 1px solid #e8eef5;
  border-radius: 12px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #334155;
  min-height: 72px;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.ql-item:hover {
  border-color: #b6d0f5;
  box-shadow: 0 4px 12px rgba(26, 111, 212, 0.1);
  transform: translateY(-1px);
}
.ql-item svg {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  stroke: var(--brand);
}
.ql-item span { line-height: 1.2; }

.content {
  min-width: 0;
  padding: 0 0.35rem 0 0.35rem;
}

/* Unit / department cards */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.unit-card {
  position: relative;
  background: #fff;
  border: 1px solid #e8eef4;
  border-radius: 20px;
  padding: 1.35rem 1.2rem 1.2rem;
  min-height: 168px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
  border-color: #c5daf5;
}
.unit-card .blob {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  background:
    radial-gradient(120px 80px at 85% 20%, rgba(26, 111, 212, 0.12), transparent 70%),
    radial-gradient(100px 70px at 10% 90%, rgba(14, 165, 233, 0.1), transparent 65%);
}
.unit-card .illus {
  position: absolute;
  top: 1rem;
  left: 1.1rem;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
}
.unit-card .illus svg {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  stroke: var(--brand);
}
.unit-card h3 {
  margin: 0;
  position: relative;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
  text-transform: uppercase;
}
.unit-card p {
  margin: 0.25rem 0 0;
  position: relative;
  font-size: 0.84rem;
  color: var(--muted);
}

/* KPI strip */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 1.45rem; font-weight: 750; margin-top: 0.15rem; color: var(--ink); }
.kpi .hint { font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; }

/* Panels / forms / tables */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 700;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.card .value { font-size: 1.5rem; font-weight: 750; margin-top: 0.2rem; }
.card .hint { color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td {
  text-align: left;
  padding: 0.65rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  border-radius: 10px;
  padding: 0.58rem 1rem;
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
}
.btn:hover { background: var(--brand-2); }
.btn.secondary { background: #e8edf3; color: var(--ink); }
.btn.secondary:hover { background: #dce3ec; }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.sm { padding: 0.32rem 0.65rem; font-size: 0.78rem; border-radius: 8px; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 650;
  margin: 0.55rem 0 0.25rem;
  color: #334155;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.58rem 0.7rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(26, 111, 212, 0.25);
  border-color: #93c5fd;
}
textarea { min-height: 88px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 0.85rem 0; }

.alert {
  margin: 0 1.25rem 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
.work .alert, .content .alert, .no-quick .alert { margin-left: 0; margin-right: 0; }
.alert.ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert.err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #075985;
}
.badge.open { background: #fef3c7; color: #92400e; }
.badge.done { background: #d1fae5; color: #065f46; }
.badge.cancel { background: #fee2e2; color: #991b1b; }

.vitals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
}
.vital {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}
.vital span { font-size: 0.7rem; color: var(--muted); display: block; margin-bottom: 0.2rem; }

/* Unique HMS2 chips */
.unique-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.unique-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #dbe7f5;
  font-size: 0.78rem;
  font-weight: 650;
  color: #1e40af;
  box-shadow: var(--shadow);
}
.unique-chip svg {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
}

/* User management list */
.ua-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.ua-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.ua-search {
  min-width: 200px;
  margin: 0 !important;
  padding: 0.4rem 0.65rem !important;
}
.ua-filters select {
  margin: 0 !important;
  padding: 0.4rem 0.55rem !important;
  width: auto;
}
.ua-table th {
  white-space: nowrap;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
}
.ua-table td {
  vertical-align: middle;
  font-size: 0.86rem;
}
.ua-row-inactive {
  opacity: 0.72;
  background: #f8fafc;
}
.ua-email { word-break: break-all; max-width: 200px; }
.ua-roles {
  max-width: 240px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.ua-roles .badge { margin: 0; }
.ua-last-login { white-space: nowrap; color: #64748b; font-size: 0.82rem; }
.ua-action-cell { white-space: nowrap; position: relative; }
.ua-menu {
  position: relative;
  display: inline-block;
}
.ua-menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.ua-menu > summary::-webkit-details-marker { display: none; }
.ua-menu-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 220px;
  background: #fff;
  border: 1px solid #dbe7f5;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.ua-menu-panel a,
.ua-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.ua-menu-panel a:hover,
.ua-menu-panel button:hover {
  background: #eff6ff;
  color: #1e40af;
}
.ua-menu-panel button.danger,
.ua-menu-panel button.danger:hover {
  color: #b91c1c;
}
.ua-menu-panel button.danger:hover {
  background: #fef2f2;
}
.ua-menu-panel hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 0.25rem 0;
}
.ua-menu-note {
  display: block;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  color: #64748b;
}
.ua-action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}
.ua-dot-online::before,
.ua-dot-offline::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.ua-dot-online::before { background: #059669; box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2); }
.ua-dot-offline::before { background: #94a3b8; }

/* Cashier dashboard */
.cd-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.cd-crumb a { color: var(--brand); font-weight: 600; }
.cd-crumb strong { color: var(--ink); }
.cd-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.25rem;
  background:
    radial-gradient(500px 180px at 100% 0%, rgba(26, 111, 212, 0.14), transparent 60%),
    linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #1a6fd4 140%);
  color: #e2e8f0;
  border-radius: 18px;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}
.cd-hero h2 {
  margin: 0.15rem 0 0.4rem;
  color: #fff;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}
.cd-hero .muted { color: #94a3b8; max-width: 48ch; }
.cd-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7dd3fc;
  font-weight: 700;
}
.cd-hero-meta { min-width: min(280px, 100%); }
.cd-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.72rem;
  font-weight: 650;
  margin: 0 0.25rem 0.35rem 0;
}
.cd-pill.done { background: rgba(5,150,105,0.25); border-color: rgba(167,243,208,0.35); color: #a7f3d0; }
.cd-pill.warn { background: rgba(217,119,6,0.22); border-color: rgba(253,230,138,0.35); color: #fde68a; }
.cd-updated {
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 0.5rem 0 0.75rem;
}
.cd-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.cd-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.2rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.cd-section-head { margin-bottom: 0.85rem; }
.cd-section-head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}
.cd-section-head .muted { margin: 0; font-size: 0.86rem; }
.cd-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}
.cd-kpi-grid-4 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cd-kpi {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
  overflow: hidden;
}
.cd-kpi::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #cbd5e1;
}
.cd-kpi.accent::after { background: var(--brand); }
.cd-kpi.ok::after { background: var(--ok); }
.cd-kpi.warn::after { background: var(--warn); }
.cd-kpi.danger::after { background: var(--err); }
.cd-kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}
.cd-kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
  line-height: 1.15;
}
.cd-kpi-hint { font-size: 0.75rem; color: #94a3b8; }
.cd-status-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}
.cd-status {
  border-radius: 14px;
  padding: 0.9rem;
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  text-align: center;
}
.cd-status strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
}
.cd-status span {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 0.15rem;
}
.cd-status small {
  display: block;
  color: #94a3b8;
  font-size: 0.72rem;
  margin-top: 0.2rem;
}
.cd-status.accent { border-color: #bfdbfe; background: linear-gradient(180deg, #eff6ff, #fff); }
.cd-status.ok { border-color: #a7f3d0; background: linear-gradient(180deg, #ecfdf5, #fff); }
.cd-status.warn { border-color: #fde68a; background: linear-gradient(180deg, #fffbeb, #fff); }
.cd-status.danger { border-color: #fecaca; background: linear-gradient(180deg, #fef2f2, #fff); }
.cd-status.muted { opacity: 0.92; }
.cd-shift-wrap {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}
.cd-shift-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.1rem;
}
.cd-shift-panel h4 { margin: 0 0 0.25rem; }
.cd-shift-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.65rem;
}
.cd-shift-form .cd-full { grid-column: 1 / -1; }
.cd-shift-form label { margin-top: 0; font-size: 0.78rem; }
.cd-shift-form input { margin: 0; }
.cd-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}
.cd-chart-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  background: #fff;
  min-width: 0;
}
.cd-chart-card.cd-chart-wide { grid-column: 1 / -1; }
.cd-chart-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}
.cd-chart-card h4 { margin: 0 0 0.15rem; font-size: 0.95rem; }
.cd-chart-card .muted { margin: 0; font-size: 0.78rem; }
.cd-badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
}
.cd-chart-box {
  position: relative;
  height: 240px;
}
.cd-chart-square { height: 260px; max-width: 360px; margin: 0 auto; }
@media (max-width: 1200px) {
  .cd-kpi-grid, .cd-status-grid, .cd-kpi-grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cd-shift-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .cd-kpi-grid, .cd-status-grid, .cd-kpi-grid-4, .cd-chart-grid { grid-template-columns: 1fr; }
  .cd-chart-card.cd-chart-wide { grid-column: auto; }
  .cd-shift-form { grid-template-columns: 1fr; }
}

/* IPD ward blocks */
.ward-block {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  background: #fafbfc;
}
.ward-block-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
}
.ward-block-head strong {
  font-size: 1.02rem;
  margin-right: 0.35rem;
}

/* Invoice create (Cashier) */
.inv-create { margin-bottom: 1rem; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}
.inv-subhead {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.95rem;
  color: #1e40af;
}
.inv-walkin {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
}
.inv-walkin summary { cursor: pointer; }
.inv-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.25rem 0.1rem 0.5rem;
}
.inv-cat-group {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.5rem 0.65rem;
  background: #fafbfc;
}
.inv-cat-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.35rem;
}
.inv-cat-item {
  display: grid;
  grid-template-columns: auto 1fr auto 64px;
  gap: 0.4rem;
  align-items: center;
  font-weight: 500;
  font-size: 0.84rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid #f1f5f9;
  margin: 0;
}
.inv-cat-item:last-child { border-bottom: 0; }
.inv-cat-name { min-width: 0; }
.inv-cat-price { color: #1e40af; font-weight: 700; font-size: 0.8rem; white-space: nowrap; }
.inv-qty, .inv-qty-sm {
  width: 64px !important;
  margin: 0 !important;
  padding: 0.3rem 0.35rem !important;
  font-size: 0.8rem !important;
}
.inv-custom-lines { display: flex; flex-direction: column; gap: 0.45rem; }
.inv-line-row {
  display: grid;
  grid-template-columns: 1fr 120px 80px;
  gap: 0.45rem;
}
.inv-line-row input { margin: 0 !important; }
.inv-estimate {
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-size: 0.88rem;
}
@media (max-width: 860px) {
  .inv-grid, .inv-line-row { grid-template-columns: 1fr; }
  .inv-cat-item { grid-template-columns: auto 1fr; }
  .inv-cat-price { grid-column: 2; }
}

/* POS / Cashier */
.pos-tabs { margin-bottom: 1rem; }
.pos-table th { font-size: 0.68rem; }
.pos-highlight td { background: #eff6ff; }
.pos-partial-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0 0.55rem;
}
.pos-partial-form label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  color: #64748b;
}
.pos-receipt {
  max-width: 520px;
  margin: 1rem auto 0;
  padding: 1.25rem 1.5rem;
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  background: #fff;
}
.pos-receipt-head {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}
.pos-receipt-head strong { font-size: 1.15rem; display: block; }
.pos-receipt-meta {
  width: 100%;
  margin-bottom: 1rem;
  font-size: 0.86rem;
}
.pos-receipt-meta td {
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
}
.pos-receipt-meta td:first-child {
  color: #64748b;
  width: 42%;
}
@media print {
  .rail, .service-tabs, .sub-tabs, .topbar, .quick, .unique-strip,
  .mobile-toggle, .pos-tabs, .actions, .alert { display: none !important; }
  .shell, .main, .work, .content, .panel { all: unset; display: block; }
  .pos-receipt {
    border: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
}

/* Keep main grid stable */
.work {
  align-items: start;
}
.content {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}
.unit-grid {
  width: 100%;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(700px 360px at 15% 0%, rgba(26, 111, 212, 0.16), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 0.35rem; font-size: 1.4rem; }
.login-card .brand strong { color: var(--ink); }
.login-card .brand small { color: var(--muted); }

.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(26, 111, 212, 0.4);
  font-size: 1.2rem;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .unit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row, .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work { grid-template-columns: 1fr; }
  .quick { display: none; }
  .work.quick-open .quick { display: block; }
}
@media (max-width: 860px) {
  .main-col {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-105%);
    transition: transform .2s, width .22s ease;
    width: min(280px, 86vw);
    padding: 1.1rem 0.75rem 1.5rem;
    box-shadow: none;
  }
  /* On mobile drawer always show full labels */
  .sidebar .brand-mark { margin: 0; }
  .sidebar .brand-text,
  .sidebar .nav-label,
  .sidebar .nav-section {
    opacity: 1;
    max-width: none;
    max-height: none;
    overflow: visible;
  }
  .sidebar .nav-section {
    padding: 0.85rem 0.7rem 0.35rem;
  }
  .sidebar .nav a {
    justify-content: flex-start;
    padding: 0.7rem 0.75rem;
  }
  .shell.nav-open .sidebar { transform: translateX(0); width: min(280px, 86vw); }
  .mobile-toggle { display: grid; place-items: center; }
  .unit-grid, .grid-2, .row, .row-3, .vitals, .kpi-row, .cards {
    grid-template-columns: 1fr;
  }
  .service-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

/* ========== Patient chart P1 · acuity / peds ========== */
.pat-page { display:flex; flex-direction:column; gap:.75rem; }
.pat-hero { display:flex; flex-wrap:wrap; justify-content:space-between; gap:.75rem; align-items:flex-start; }
.pat-hero-actions { display:flex; flex-wrap:wrap; gap:.35rem; }
.pat-layout { display:grid; grid-template-columns:minmax(0,1.7fr) minmax(240px,.75fr); gap:.75rem; align-items:start; }
@media (max-width:980px){ .pat-layout { grid-template-columns:1fr; } }
.pat-section { margin-top:1rem; padding-top:.85rem; border-top:1px solid var(--line); }
.pat-section-h { font-size:.72rem; font-weight:800; letter-spacing:.04em; text-transform:uppercase; color:#475569; margin-bottom:.5rem; }
.pat-safety { background:linear-gradient(180deg,#fff7ed 0%,#fff 48%); border:1px solid #fed7aa; border-radius:12px; padding:.75rem .85rem; margin-top:1rem; }
.pat-visit-section { background:linear-gradient(180deg,#eff6ff 0%,#fff 55%); border:1px solid #bfdbfe; border-radius:12px; padding:.75rem .85rem; }
.pat-check { display:flex; align-items:center; gap:.45rem; font-weight:650; font-size:.9rem; margin:.35rem 0 .65rem; }
.visit-fields.is-collapsed { display:none; }
.pat-age-badge { display:inline-block; margin-left:.35rem; font-size:.65rem; font-weight:800; padding:.12rem .4rem; border-radius:999px; background:#e2e8f0; color:#334155; vertical-align:middle; }
.pat-age-badge.is-child { background:#fef3c7; color:#92400e; border:1px solid #fcd34d; }
.pat-pill { display:inline-block; font-size:.7rem; font-weight:700; padding:.15rem .45rem; border-radius:999px; background:#f1f5f9; color:#334155; margin:0 .2rem .2rem 0; }
.pat-pill.danger { background:#fef2f2; color:#b91c1c; border:1px solid #fecaca; }
.pat-pill.ok { background:#ecfdf5; color:#047857; border:1px solid #a7f3d0; }
.pat-pill.soft { background:#eff6ff; color:#1d4ed8; border:1px solid #bfdbfe; }
.pat-pill.muted { background:#f8fafc; color:#94a3b8; }
.pat-table td, .pat-table th { vertical-align:top; }
.pat-table tr.is-child-row { background:linear-gradient(90deg,#fffbeb 0%, transparent 40%); }
.table-wrap { overflow-x:auto; }

.acuity-banner { display:flex; flex-wrap:wrap; gap:.35rem .75rem; align-items:baseline; padding:.65rem .8rem; border-radius:12px; margin:.5rem 0 .75rem; border:1px solid; font-size:.88rem; }
.acuity-banner strong { font-weight:800; }
.acuity-banner span { opacity:.9; font-size:.8rem; }
.acuity-banner.acuity-red, .acuity-head.acuity-red { background:#fef2f2; border-color:#fecaca; color:#7f1d1d; }
.acuity-banner.acuity-orange, .acuity-head.acuity-orange { background:#fff7ed; border-color:#fed7aa; color:#9a3412; }
.acuity-banner.acuity-yellow, .acuity-head.acuity-yellow { background:#fefce8; border-color:#fde68a; color:#854d0e; }
.acuity-banner.acuity-green, .acuity-head.acuity-green { background:#f0fdf4; border-color:#bbf7d0; color:#14532d; }
.acuity-banner.acuity-blue, .acuity-head.acuity-blue { background:#eff6ff; border-color:#bfdbfe; color:#1e3a8a; }
.acuity-head { border-left:5px solid #94a3b8; }
.acuity-head.acuity-red { border-left-color:#dc2626; }
.acuity-head.acuity-orange { border-left-color:#ea580c; }
.acuity-head.acuity-yellow { border-left-color:#ca8a04; }
.acuity-head.acuity-green { border-left-color:#16a34a; }
.acuity-head.acuity-blue { border-left-color:#2563eb; }

.acuity-badge { display:inline-block; font-size:.68rem; font-weight:800; letter-spacing:.03em; padding:.2rem .45rem; border-radius:8px; border:1px solid; white-space:nowrap; }
.acuity-badge.acuity-red { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }
.acuity-badge.acuity-orange { background:#fff7ed; color:#c2410c; border-color:#fed7aa; }
.acuity-badge.acuity-yellow { background:#fefce8; color:#a16207; border-color:#fde68a; }
.acuity-badge.acuity-green { background:#f0fdf4; color:#15803d; border-color:#bbf7d0; }
.acuity-badge.acuity-blue { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }

.acuity-row.acuity-red { box-shadow:inset 4px 0 0 #dc2626; }
.acuity-row.acuity-orange { box-shadow:inset 4px 0 0 #ea580c; }
.acuity-row.acuity-yellow { box-shadow:inset 4px 0 0 #ca8a04; }
.acuity-row.acuity-green { box-shadow:inset 4px 0 0 #16a34a; }
.acuity-row.acuity-blue { box-shadow:inset 4px 0 0 #2563eb; }

.illness-block { margin:.55rem 0 .75rem; }
.illness-block-title { font-size:.8rem; font-weight:750; margin-bottom:.25rem; }
.illness-hint { font-size:.78rem; color:var(--muted); margin:0 0 .45rem; }
.illness-hint.peds { color:#92400e; font-weight:600; }
.illness-chips, .chronic-chips { display:flex; flex-wrap:wrap; gap:.4rem; }
/* Checkbox chips: label is the hit target — works without JS */
.illness-chip, .chronic-chip {
  appearance:none; border:1px solid #cbd5e1; background:#fff; color:#334155;
  border-radius:999px; padding:.35rem .7rem; font-size:.78rem; font-weight:650;
  cursor:pointer; transition:background .15s, border-color .15s, box-shadow .15s, color .15s;
  display:inline-flex; align-items:center; gap:.4rem; user-select:none;
  -webkit-user-select:none; margin:0; line-height:1.25; position:relative; z-index:1;
  pointer-events:auto;
}
.illness-chip .chip-check, .chronic-chip .chip-check {
  position:absolute; opacity:0; width:1px; height:1px; margin:-1px; clip:rect(0,0,0,0);
  pointer-events:none;
}
.illness-chip .chip-text, .chronic-chip .chip-text { pointer-events:none; }
.illness-chip:hover, .chronic-chip:hover { border-color:#94a3b8; }
.illness-chip:focus-within, .chronic-chip:focus-within { outline:2px solid rgba(37,99,235,.35); outline-offset:2px; }
.illness-chip.is-on, .chronic-chip.is-on,
.illness-chip:has(.chip-check:checked), .chronic-chip:has(.chip-check:checked) {
  box-shadow:0 0 0 2px rgba(37,99,235,.15); font-weight:800;
}
.chronic-chip:has(.chip-check:checked) { background:#eef2ff; color:#3730a3; border-color:#818cf8; }
.illness-chip.acuity-red { border-color:#fca5a5; }
.illness-chip.acuity-red.is-on { background:#fef2f2; color:#b91c1c; border-color:#ef4444; }
.illness-chip.acuity-orange { border-color:#fdba74; }
.illness-chip.acuity-orange.is-on { background:#fff7ed; color:#c2410c; border-color:#f97316; }
.illness-chip.acuity-yellow { border-color:#fde047; }
.illness-chip.acuity-yellow.is-on { background:#fefce8; color:#a16207; border-color:#eab308; }
.illness-chip.acuity-green { border-color:#86efac; }
.illness-chip.acuity-green.is-on { background:#f0fdf4; color:#15803d; border-color:#22c55e; }
.illness-chip.acuity-blue { border-color:#93c5fd; }
.illness-chip.acuity-blue.is-on { background:#eff6ff; color:#1d4ed8; border-color:#3b82f6; }
.chronic-chip.is-on { background:#eef2ff; color:#3730a3; border-color:#818cf8; }

.acuity-legend { list-style:none; margin:0; padding:0; }
.acuity-legend li { display:flex; align-items:center; gap:.45rem; font-size:.82rem; margin:.28rem 0; }
.acuity-legend .dot { width:.7rem; height:.7rem; border-radius:50%; flex-shrink:0; }
.acuity-legend .acuity-red .dot { background:#dc2626; }
.acuity-legend .acuity-orange .dot { background:#ea580c; }
.acuity-legend .acuity-yellow .dot { background:#ca8a04; }
.acuity-legend .acuity-green .dot { background:#16a34a; }
.acuity-legend .acuity-blue .dot { background:#2563eb; }

.walkin-form .row { align-items:flex-end; }
