/* ===== CSS Variables ===== */
:root {
  --primary: #1a6fa8;
  --primary-dark: #155a8a;
  --green: #27ae60;
  --yellow: #f39c12;
  --red: #e74c3c;
  --gray: #6c757d;
  --light-bg: #f4f6f9;
  --card-bg: #ffffff;
  --border: #dee2e6;
  --text: #2c3e50;
  --text-light: #5d6d7e;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--light-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.page-wrap { max-width: 960px; margin: 0 auto; padding: 16px; }

/* ===== Navbar ===== */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 52px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.navbar-brand {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.navbar-brand span { font-size: 12px; font-weight: 400; margin-left: 8px; opacity: 0.8; }
.navbar-right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.navbar a { color: rgba(255,255,255,0.85); font-size: 13px; }
.navbar a:hover { color: #fff; text-decoration: none; }

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #219a52; }
.btn-warning { background: var(--yellow); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d68910; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) { background: var(--light-bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Traffic Light ===== */
.traffic-light { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tl-circle {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: #ddd;
  transition: all 0.3s;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.tl-circle.green { background: var(--green); box-shadow: 0 0 20px rgba(39,174,96,0.5); }
.tl-circle.yellow { background: var(--yellow); box-shadow: 0 0 20px rgba(243,156,18,0.5); }
.tl-circle.red { background: var(--red); box-shadow: 0 0 20px rgba(231,76,60,0.5); }
.tl-label { font-size: 15px; font-weight: 600; }
.tl-label.green { color: var(--green); }
.tl-label.yellow { color: var(--yellow); }
.tl-label.red { color: var(--red); }
.tl-text { font-size: 13px; color: var(--text-light); text-align: center; max-width: 320px; line-height: 1.5; }

/* ===== Alert Boxes ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
}
.alert-green { background: #d5f5e3; border-left: 4px solid var(--green); color: #1e8449; }
.alert-yellow { background: #fef9e7; border-left: 4px solid var(--yellow); color: #9a7d0a; }
.alert-red { background: #fdedec; border-left: 4px solid var(--red); color: #922b21; }
.alert-info { background: #eaf4fb; border-left: 4px solid var(--primary); color: #1a5276; }

/* ===== Form ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form-hint { font-size: 11px; color: var(--text-light); margin-top: 3px; }

/* ===== Checklist ===== */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all 0.15s;
  cursor: pointer;
}
.checklist-item:hover { border-color: var(--primary); background: #f0f7ff; }
.checklist-item.checked { background: #d5f5e3; border-color: var(--green); }
.checklist-item input[type="checkbox"] {
  width: 18px; height: 18px;
  flex-shrink: 0;
  accent-color: var(--green);
  margin-top: 2px;
  cursor: pointer;
}
.checklist-item label { cursor: pointer; font-size: 14px; }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; }
.tab-btn {
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--light-bg);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
  transition: all 0.15s;
}
.tab-btn.active { background: #fff; color: var(--primary); font-weight: 600; border-color: var(--primary); }
.tab-btn.complete { background: #d5f5e3; color: var(--green); border-color: var(--green); }
.tab-btn.complete.active { font-weight: 700; }
.tab-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Step Wizard ===== */
.steps-list { list-style: none; padding: 0; }
.step-item {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  position: relative;
}
.step-item::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 38px;
  bottom: -12px;
  width: 2px;
  background: var(--border);
}
.step-item:last-child::before { display: none; }
.step-num {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--border);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 15px;
}
.step-num.done { background: var(--green); }
.step-num.active { background: var(--primary); }
.step-num.checkpoint { background: var(--red); }
.step-num.checkpoint.done { background: var(--green); }
.step-body { flex: 1; }
.step-title { font-weight: 600; font-size: 15px; }
.step-desc { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
}
.step-card.active-step { border-color: var(--primary); background: #f0f7ff; }
.step-card.done-step { border-color: var(--green); background: #f0fff4; }
.step-card.checkpoint-card { border-color: var(--red); background: #fff5f5; }

/* ===== Timer ===== */
.timer-wrap { text-align: center; padding: 24px; }
.timer-display {
  font-size: 52px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  letter-spacing: 2px;
}
.timer-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.timer-progress {
  width: 140px; height: 140px;
  margin: 16px auto;
  position: relative;
}
.timer-progress svg { transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: #e0e0e0; stroke-width: 8; }
.timer-ring { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-inner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.timer-inner-time { font-size: 20px; font-weight: 700; color: var(--primary); }
.timer-inner-label { font-size: 10px; color: var(--text-light); }

/* ===== Reminder Banner ===== */
.reminder-banner {
  background: #fff3cd;
  border: 2px solid var(--yellow);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: none;
}
.reminder-banner.show { display: block; }
.reminder-banner h3 { color: #856404; margin-bottom: 8px; }

/* ===== Chart Container ===== */
.chart-container { width: 100%; height: 320px; }

/* ===== Patient Cards ===== */
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.patient-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-left: 4px solid var(--primary);
  cursor: pointer;
  transition: all 0.15s;
}
.patient-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-1px); }
.patient-card .name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.patient-card .meta { font-size: 12px; color: var(--text-light); }
.patient-card .badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; margin-top: 8px; }
.badge-blue { background: #d6eaf8; color: #1a5276; }
.badge-green { background: #d5f5e3; color: #1e8449; }
.badge-gray { background: #ecf0f1; color: #7f8c8d; }

/* ===== Session Table ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: var(--light-bg); padding: 8px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: #f8f9fa; }

/* ===== Status Badge ===== */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.status-assessment { background: #ebf5fb; color: #1a5276; }
.status-preparation { background: #fef9e7; color: #9a7d0a; }
.status-execution { background: #fdf2f8; color: #76448a; }
.status-monitoring { background: #d5f5e3; color: #1e8449; }
.status-terminating { background: #fdedec; color: #922b21; }
.status-completed { background: #eaecee; color: #555; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== Utilities ===== */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 20px; font-weight: 700; }
.back-link { color: var(--text-light); font-size: 13px; cursor: pointer; }
.back-link:hover { color: var(--primary); }

/* ===== Progress Bar ===== */
.progress-bar-wrap { background: #e0e0e0; border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--green); transition: width 0.3s; border-radius: 4px; }

/* ===== Loading ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tabs Underline Variant (admin) ===== */
.tabs-underline { border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tabs-underline .tab-btn {
  border: none; border-bottom: 2px solid transparent;
  border-radius: 0; background: none; margin-bottom: -2px;
  padding: 8px 20px; font-size: 14px;
}
.tabs-underline .tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: none; }

/* ===== Auth Pages (login/register) ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--light-bg);
}
.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
}
.auth-title { text-align: center; margin-bottom: 8px; font-size: 20px; font-weight: 700; color: var(--primary); }
.auth-subtitle { text-align: center; color: var(--text-light); font-size: 13px; margin-bottom: 28px; }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.auth-error {
  background: #fde8e8; color: var(--red); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px; display: none;
}
.auth-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-light); }
.auth-footer a { color: var(--primary); }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-light); font-size: 12px; margin: 16px 0;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-auth { width: 100%; justify-content: center; font-size: 15px; padding: 10px; }
.hint { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* ===== Vital Card (monitoring latest values) ===== */
.vital-card {
  text-align: center; padding: 8px;
  border: 1px solid var(--border); border-radius: 6px;
}
.vital-card-label { font-size: 11px; color: var(--text-light); }
.vital-card-value { font-size: 18px; font-weight: 700; margin-top: 2px; }

/* ===== Alert Orange (overtime warning) ===== */
.alert-orange { background: #fff3cd; color: #856404; border: 1px solid #ffc107; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }

/* ===== Table Wrapper ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Navbar Simple (auth pages) ===== */
.navbar-simple {
  background: var(--primary);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 52px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ===== Mobile Navbar ===== */
@media (max-width: 768px) {
  .navbar { padding: 0 12px; height: auto; min-height: 48px; flex-wrap: wrap; gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .navbar-brand { font-size: 15px; }
  .navbar-brand span { display: none; }
  .navbar-right { gap: 6px; flex-wrap: wrap; }
  .navbar-right .btn { font-size: 12px; padding: 4px 8px; }
  .navbar-right span { font-size: 11px; }
}

/* ===== Mobile Traffic Light Bar ===== */
@media (max-width: 768px) {
  .tl-sticky-bar {
    position: sticky; top: 52px; z-index: 100;
    background: var(--card-bg); box-shadow: var(--shadow);
    padding: 8px 16px;
    display: flex; align-items: center; gap: 10px;
    margin: -16px -16px 16px;
  }
  .tl-sticky-bar .tl-circle { width: 32px; height: 32px; font-size: 14px; }
  .tl-sticky-bar .tl-label { font-size: 13px; }
}
