/* ============================================================
   Giao ban điện tử BVĐK Mộc Châu — Complete Design System
   Inspired by demo.nguyenthanhluan.fun
   ============================================================ */

/* === CSS Variables / Design Tokens === */
:root {
  --teal: #007185;
  --dark: #004a57;
  --line: #e4e9ec;
  --ink: #1f2937;
  --bg: #f3f6f8;
  --white: #ffffff;
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #28a745;
  --text-muted: #6b7280;
  --border-radius-lg: 12px;
  --border-radius-md: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
  --sidebar-bg: #005469;
  --sidebar-hover: #007185;
  --sidebar-active: #008da0;
}

* { box-sizing: border-box; }

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  font-size: 14px;
  min-height: 100vh;
}

/* ===================== LOGIN PAGE (match demo) ===================== */
.login-page {
  height: 100vh;
  display: grid;
  grid-template-columns: 53% 47%;
  background: #fff;
}

.login-hero {
  background: url('/images/reference-login.png') left center / auto 100% no-repeat;
  background-color: #004a57;
}

.login-side {
  display: grid;
  place-items: center;
  padding: 5%;
  background: #fff;
}

.login-box {
  width: min(620px, 100%);
  border: 1px solid #dce4e9;
  border-radius: 22px;
  padding: 40px 48px;
  box-shadow: 0 4px 18px #17324b18;
  background: #fff;
}

.brand-logo {
  display: block;
  width: 105px;
  height: 105px;
  object-fit: contain;
  border-radius: 50%;
  margin: auto;
}

.login-box .hospital {
  text-align: center;
  color: #087181;
  font-weight: 700;
  margin-top: 10px;
  font-size: 16px;
}

.login-box h1 {
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: #102840;
  margin: 16px 0 4px;
}

.login-box .sub {
  text-align: center;
  font-size: 19px;
  color: #718096;
  margin-bottom: 8px;
}

.login-box label {
  display: block;
  font-weight: 600;
  margin: 20px 0 8px;
  color: #102840;
}

.login-box label.remember-label {
  font-weight: 400;
  margin: 16px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.login-box label.remember-label input {
  width: auto;
  height: auto;
}

.login-box input:not([type="checkbox"]):not([type="hidden"]) {
  height: 54px;
  border: 1px solid #dce4e9;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.2s;
}

.login-box input:not([type="checkbox"]):not([type="hidden"]):focus {
  outline: none;
  border-color: #007287;
  box-shadow: 0 0 0 3px rgba(0,114,135,0.1);
}

.loginbtn {
  width: 100%;
  height: 60px;
  background: #007287;
  color: white;
  border: 0;
  border-radius: 8px;
  font-size: 21px;
  font-weight: 600;
  margin-top: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.loginbtn:hover {
  background: #004a57;
}

.login-box .safe {
  margin-top: 25px;
  padding: 14px;
  border: 1px solid #b6e3d8;
  border-radius: 8px;
  text-align: center;
  color: #087562;
  font-size: 14px;
}

.login-box .foot {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #ddd;
  margin-top: 25px;
  padding-top: 18px;
  color: #718096;
  font-size: 13px;
}

@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-hero { display: none; }
  .login-side { padding: 20px; }
  .login-box { padding: 30px; }
}

/* ===================== SIDEBAR ===================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--white);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-x: hidden;
  overflow-y: auto;
}

.app-sidebar.collapsed {
  width: 72px;
}

.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .sidebar-nav span,
.app-sidebar.collapsed .collapse-btn span,
.app-sidebar.collapsed .collapse span {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-brand {
  height: 72px;
  padding: 12px;
}

.app-sidebar.collapsed .sidebar-logo {
  width: 44px;
  height: 44px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
}

.app-sidebar.collapsed .sidebar-nav .nav-link {
  padding: 0;
  justify-content: center;
  gap: 0;
  height: 46px;
}

.app-sidebar.collapsed .collapse-btn {
  padding: 16px 0;
  justify-content: center;
  gap: 0;
}

.app-sidebar.collapsed .collapse-btn i {
  transform: rotate(180deg);
}

.sidebar-brand {
  height: 100px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 20px;
  transition: all 0.25s ease;
  overflow: hidden;
}

.sidebar-logo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
  transition: all 0.25s ease;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.sidebar-nav .nav-link {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  border-left: 4px solid transparent;
  transition: all 0.2s;
  opacity: 0.85;
  white-space: nowrap;
}

.sidebar-nav .nav-link i,
.sidebar-nav .nav-link .nav-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  opacity: 1;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  border-left-color: #28ded1;
  opacity: 1;
  font-weight: 600;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 16px;
}

.collapse-btn {
  padding: 20px 24px;
  cursor: pointer;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  font-size: 14px;
  transition: opacity 0.2s;
}

.collapse-btn:hover {
  opacity: 1;
}

/* ===================== MAIN LAYOUT ===================== */
.app-main {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  transition: margin-left 0.25s ease;
}

.app-sidebar.collapsed + .app-main {
  margin-left: 72px;
}

.app-topbar {
  height: 72px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 9;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  color: var(--dark);
  text-transform: uppercase;
}

.date-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
}

.date-selector span {
  font-size: 13px;
  color: var(--text-muted);
}

.date-selector input {
  border: none;
  background: transparent;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  font-size: 14px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 24px;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #eefaf2;
  color: #108a3d;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #c7ecd5;
}

.sync-badge i {
  font-size: 15px;
}

.bell {
  font-size: 20px;
  color: var(--text-muted);
  position: relative;
  cursor: pointer;
}

.bell b {
  position: absolute;
  right: -6px;
  top: -6px;
  background: var(--danger);
  color: var(--white);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid var(--white);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 600;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info strong {
  font-size: 14px;
  color: var(--ink);
}

.user-info small {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.topbar-logout:hover {
  background: var(--bg);
  color: var(--danger);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 4px;
}

.sidebar-toggle:hover {
  background: var(--bg);
}

.app-content {
  padding: 24px;
  flex: 1;
}

.app-footer {
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 16px 24px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ===================== CARDS ===================== */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 24px;
}

/* ===================== STATS CARDS ===================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

/* Keep gradient cards for HoiChan / other pages */
.stat-card {
  display: block;
  border-radius: 12px;
  padding: 16px;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  transition: transform .15s, box-shadow .15s;
  height: 100%;
  text-decoration: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  color: #fff;
}

.stat-label {
  font-size: 0.78rem;
  opacity: .9;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-icon {
  font-size: 28px;
  opacity: .85;
  margin-bottom: 6px;
  display: block;
}

.stat-blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-green   { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat-cyan    { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-orange  { background: linear-gradient(135deg, #f97316, #ea580c); }
.stat-purple  { background: linear-gradient(135deg, #a855f7, #9333ea); }
.stat-red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-indigo  { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-pink    { background: linear-gradient(135deg, #ec4899, #db2777); }
.stat-yellow  { background: linear-gradient(135deg, #f59e0b, #d97706); }

/* cardx alias used by demo markup */
.cardx {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.cardx h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
  margin-top: 0;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

/* ===================== WORKFLOW STEPS (match demo) ===================== */
.workflow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 18px;
  background: transparent;
  border: none;
  overflow: visible;
}

.workflow .step {
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 3px solid #d6e0e5;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  position: relative;
}

.workflow .step + .step {
  border-left: none;
}

.workflow .step i,
.workflow .step .step-num {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: transparent;
  border: 2px solid #8796a3;
  color: #8796a3;
  font-style: normal;
  flex-shrink: 0;
}

.workflow .step.done {
  border-bottom-color: #168d43;
  color: var(--ink);
}

.workflow .step.done i,
.workflow .step.done .step-num {
  border-color: #168d43;
  color: #168d43;
  background: transparent;
}

.workflow .step.current {
  border-bottom-color: #1671dd;
  color: #1263bd;
  background: transparent;
}

.workflow .step.current i,
.workflow .step.current .step-num {
  border-color: #1671dd;
  color: #1671dd;
  background: transparent;
}

.workflow .step span,
.workflow .step small {
  display: block;
}

.workflow .step small {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 7-step workflow (Hội chẩn) */
.workflow.workflow-7 {
  grid-template-columns: repeat(7, 1fr);
}

@media (max-width: 1000px) {
  .workflow { grid-template-columns: 1fr 1fr; }
  .workflow.workflow-7 { grid-template-columns: 1fr 1fr; }
}

/* ===================== STATS (match demo .stats/.stat) ===================== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stats .stat,
a.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  text-decoration: none;
  color: var(--ink);
  display: block;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.stats .stat:hover,
a.stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: var(--ink);
}

.stats .stat strong,
a.stat strong {
  display: block;
  font-size: 32px;
  font-weight: 700;
  color: var(--teal);
  margin-top: 6px;
  line-height: 1.1;
}

.stats .stat small,
a.stat small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.stats-row-wide {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* overview filter bar (demo) */
.overview-filter {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  background: #fff;
  padding: 12px 20px;
  margin: -24px -24px 20px;
  border-bottom: 1px solid #d8e1e8;
  flex-wrap: wrap;
}

.overview-filter label {
  font-size: 13px;
  color: #526273;
}

.overview-filter input {
  display: block;
  padding: 8px 12px;
  border: 1px solid #ccd8e3;
  border-radius: 6px;
  margin-top: 4px;
}

.sync-state {
  margin-left: auto;
  color: #168d43;
  font-size: 13px;
}

/* alert boxes (demo right panel) */
.alertbox {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #f8fafc;
}

.alertbox b {
  display: block;
  margin-bottom: 4px;
  color: var(--dark);
}

.alertbox p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===================== TABLE ===================== */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 12px;
  border-bottom: 2px solid var(--line);
  padding: 12px 16px;
  text-align: left;
}

.table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f9fafb;
}

/* ===================== STATUS BADGES ===================== */
.status {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status.success {
  background: #eefaf2;
  color: #108a3d;
  border-color: #c7ecd5;
}

.status.warn {
  background: #fff9e6;
  color: #d97706;
  border-color: #fde68a;
}

.status.danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

/* ===================== BUTTONS ===================== */
.btn {
  padding: 8px 16px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

.btn-primary:hover {
  background: var(--dark);
  border-color: var(--dark);
  color: var(--white);
}

.btn-outline-primary {
  background: transparent;
  color: var(--teal);
  border-color: var(--teal);
}

.btn-outline-primary:hover {
  background: #f0f9fa;
  color: var(--teal);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line);
}

.btn-outline-secondary:hover {
  background: var(--bg);
  color: var(--ink);
}

.btn-outline-success {
  background: transparent;
  color: var(--success);
  border-color: var(--success);
}

.btn-outline-success:hover {
  background: #eefaf2;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-outline-danger:hover {
  background: #fef2f2;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-light {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
}

.btn-light:hover {
  background: var(--bg);
}

/* ===================== FORMS ===================== */
.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
  background: var(--white);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,113,133,0.1);
}

.form-floating {
  position: relative;
}

.form-floating label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 16px 14px 0;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.form-floating .form-control {
  padding: 24px 14px 8px;
  height: 60px;
}

/* ===================== GRID ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
  .app-sidebar {
    width: 72px;
  }
  .sidebar-brand { padding: 10px; }
  .sidebar-logo { width: 40px; height: 40px; }
  .sidebar-nav span,
  .brand-text,
  .collapse-btn span { display: none; }
  .app-main { margin-left: 72px; }
  .user-info,
  .date-selector { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .workflow { flex-wrap: wrap; }
  .workflow .step { flex: 1 1 33%; }
}

@media (max-width: 768px) {
  .app-sidebar {
    width: 0;
    overflow: hidden;
  }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .header-tools .sync-badge { display: none; }
}

/* ===================== ACCOUNT LAYOUT (for login) ===================== */
.account-layout {
  min-height: 100vh;
}

/* ===================== MISC ===================== */
.text-muted { color: var(--text-muted) !important; }
.alert {
  padding: 16px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  margin-bottom: 20px;
}

.alert-warning {
  background: #fff9e6;
  border-color: #fde68a;
  color: #92400e;
}

.alert-success {
  background: #eefaf2;
  border-color: #c7ecd5;
  color: #108a3d;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.alert-info {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #0369a1;
}

a {
  color: var(--teal);
  text-decoration: none;
}

a:hover {
  color: var(--dark);
}

/* ===================== CASE SCREEN (Ca bệnh) ===================== */
.case-screen {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 300px;
  gap: 20px;
  height: calc(100vh - 96px);
  overflow: hidden;
}

.case-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.patient-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
  position: relative;
}

.patient-panel .form-control,
.patient-panel .form-select {
  margin-bottom: 10px;
  background: var(--bg);
}

.patient-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin: 10px -20px -20px;
  padding: 0 20px 20px;
}

.patient-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--ink);
  background: var(--white);
  transition: all 0.2s;
  position: relative;
}

.patient-card:hover {
  border-color: #b4c5ce;
  box-shadow: var(--shadow-sm);
}

.patient-card.active {
  border-color: var(--teal);
  background: #f2fafc;
  box-shadow: 0 0 0 1px var(--teal);
}

.patient-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.patient-card-header b {
  font-size: 15px;
  color: var(--dark);
}

.patient-card-header span {
  font-size: 12px;
  color: var(--text-muted);
}

.patient-card-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  align-items: end;
}

.patient-card-body strong {
  color: var(--ink);
  font-weight: 600;
}

.case-detail {
  overflow-y: auto;
  padding-right: 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.his-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.his-field {
  position: relative;
  background: var(--bg);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  border: 1px dashed #d1d5db;
}

.his-field small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.his-field b {
  display: block;
  font-size: 14px;
  color: var(--ink);
}

.vitals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}

.vital-box {
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.vital-box i {
  font-size: 24px;
  margin-bottom: 8px;
}

.vital-box label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.vital-input-group {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
}

.vital-input-group input {
  width: 60px;
  padding: 4px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.vital-input-group input:focus {
  border-color: var(--teal);
  box-shadow: none;
  outline: none;
}

.vital-input-group span {
  font-size: 12px;
  color: var(--text-muted);
}

.clinical-tabs {
  display: flex;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
  gap: 20px;
  flex-shrink: 0;
}

.clinical-tabs button {
  background: none;
  border: none;
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
}

.clinical-tabs button.active {
  color: var(--teal);
}

.clinical-tabs button.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--teal);
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-height: 0;
}

.classify-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.classify-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.classify-item:hover {
  background: var(--bg);
}

.classify-item:has(input:checked) {
  border-color: var(--teal);
  background: #f0f9fa;
}

.classify-item input {
  width: 16px;
  height: 16px;
  margin-right: 12px;
  accent-color: var(--teal);
}

.classify-item i {
  font-size: 18px;
  margin-right: 12px;
  width: 24px;
  text-align: center;
}

.icon-red { color: var(--danger); }
.icon-yellow { color: var(--warning); }
.icon-blue { color: #3b82f6; }
.icon-purple { color: #8b5cf6; }
.icon-green { color: var(--success); }

.timeline {
  border-left: 2px solid var(--line);
  margin-left: 12px;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -31px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 1px var(--teal);
}

.timeline-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.timeline-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===================== FILTERS (Báo cáo) ===================== */
.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #526273;
}

.filters input,
.filters select {
  width: 100%;
  border: 1px solid #ccd8e3;
  border-radius: 7px;
  padding: 8px;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.report-kpis .kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: var(--ink);
}

.report-kpis .kpi strong {
  display: block;
  font-size: 30px;
  color: var(--teal);
}

.report-kpis .kpi small {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.report-kpis .kpi span {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.report-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.report-actions .button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  background: var(--white);
  transition: all 0.15s;
}

.report-actions .button:hover {
  background: var(--bg);
  border-color: #b8c9d4;
}

.report-actions .button.excel {
  color: #1b5e20;
  border-color: #a5d6a7;
}

.report-actions .button.pdf {
  color: #b71c1c;
  border-color: #ef9a9a;
}

/* ===================== DUTY (Lịch trực) ===================== */
.duty-week-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.duty-week-nav .week-label {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  padding: 10px 20px;
  font-weight: 600;
}

/* ===================== RESPONSIVE refinements ===================== */
@media (max-width: 1024px) {
  .case-screen {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .case-main { min-height: 60vh; }
  .patient-panel { max-height: 50vh; }
  .patient-list { max-height: 40vh; }
  .right-panel { display: none; }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .report-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .vitals,
  .his-info-grid {
    grid-template-columns: 1fr 1fr;
  }
  .filters { grid-template-columns: 1fr; }
}

/* ===================== PRINT ===================== */
@media print {
  .app-sidebar,
  .app-topbar,
  .sidebar-toggle,
  .btn,
  .topbar-logout {
    display: none !important;
  }
  .app-main { margin: 0 !important; }
}

/* ===================== SYNC BADGE & ATTACHMENTS ===================== */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  transition: all 0.2s ease;
}
.sync-badge.sync-ok {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.sync-badge.sync-ok:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}
.sync-badge.sync-running {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.sync-badge.sync-warn {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}
.spin {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.case-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.attachment-card {
  position: relative;
  width: 110px;
  border-radius: 8px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.attachment-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.attachment-card img:hover {
  transform: scale(1.05);
}
.attachment-card .btn-delete-attach {
  position: absolute;
  top: 3px;
  right: 3px;
  background: rgba(220, 53, 69, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.attachment-card .caption {
  font-size: 11px;
  padding: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-muted);
  text-align: center;
}