/* ===================================================================
   DCHR Design Tokens
   Primary: violet #6D5BD0 | Brand accent: magenta #EC008B (DCHR logo color)
   Success: #2FAE73 | Warning: #F0A93A | Danger: #E4534B
   Background: #F5F6FA | Panel: #FFFFFF | Ink: #1E2233 | Muted: #8A8FA3
   Display font: Plus Jakarta Sans | Body/data font: Inter
=================================================================== */

:root {
  --violet: #6D5BD0;
  --violet-dark: #5641B8;
  --violet-light: #EEEBFB;
  --magenta: #EC008B;
  --magenta-light: #FDE6F3;
  --success: #2FAE73;
  --success-light: #E4F7EE;
  --warning: #F0A93A;
  --warning-light: #FDF1DE;
  --danger: #E4534B;
  --danger-light: #FCE9E8;
  --blue: #3E8EF7;
  --blue-light: #E8F1FE;

  --bg: #F5F6FA;
  --panel: #FFFFFF;
  --ink: #1E2233;
  --muted: #8A8FA3;
  --line: #EBEDF3;
  --line-soft: #F1F2F7;
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
h1, h2, h3, .display { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; }

.app-shell { display: flex; min-height: 100vh; }

/* ================= SIDEBAR ================= */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans'; font-weight: 800; font-size: 17px;
  flex-shrink: 0;
}
.brand-name { font-family: 'Plus Jakarta Sans'; font-weight: 800; font-size: 16.5px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: -1px; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  color: #5D6273;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-icon { font-size: 7px; color: currentColor; opacity: 0.55; }
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(135deg, var(--violet), #7D6DE0);
  color: #fff;
  box-shadow: 0 4px 14px rgba(109,91,208,0.32);
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer { padding-top: 14px; }
.footer-card {
  background: linear-gradient(135deg, var(--violet-light), var(--magenta-light));
  border-radius: 14px;
  padding: 16px;
}
.footer-card-title { font-family: 'Plus Jakarta Sans'; font-weight: 700; font-size: 13px; color: var(--violet-dark); }
.footer-card-sub { font-size: 11.5px; color: #6B6F8A; margin-top: 3px; line-height: 1.4; }

/* ================= TOP BAR ================= */
.content-col { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.search-wrap {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  width: 380px;
  max-width: 40vw;
}
.search-wrap input { border: none; background: none; outline: none; font-size: 13px; flex: 1; font-family: inherit; }
.search-icon { color: var(--muted); font-size: 13px; }
.kbd { font-size: 10.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-logo-wrap { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0 24px; min-width: 0; }
.topbar-logo-wrap img { max-height: 52px; max-width: 100%; object-fit: contain; }
.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-size: 15px; cursor: pointer;
  border: 1px solid var(--line);
}
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--magenta); color: #fff;
  font-size: 9.5px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.profile { display: flex; align-items: center; gap: 9px; padding-left: 8px; border-left: 1px solid var(--line); margin-left: 4px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; font-family: 'Plus Jakarta Sans';
}
.profile-name { font-size: 13px; font-weight: 700; }
.profile-role { font-size: 11px; color: var(--muted); }

/* ================= MAIN ================= */
.main { padding: 28px 32px 60px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; }
.page-header h2 { font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-header p { margin: 0; color: var(--muted); font-size: 13.5px; }
.greet-emoji { display: inline-block; }

.btn {
  background: var(--violet);
  color: #fff; border: none;
  padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--violet-dark); }
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--line-soft); }
.btn.danger { background: var(--danger-light); color: var(--danger); }
.btn.danger:hover { background: #f8d9d7; }
.btn.sm { padding: 6px 13px; font-size: 12px; border-radius: 8px; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px;
}
.stat-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.stat-icon.violet { background: var(--violet-light); }
.stat-icon.success { background: var(--success-light); }
.stat-icon.blue { background: var(--blue-light); }
.stat-icon.magenta { background: var(--magenta-light); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-num { font-size: 25px; font-weight: 800; font-family: 'Plus Jakarta Sans'; letter-spacing: -0.01em; }
.stat-delta { font-size: 11.5px; font-weight: 700; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.sparkline { margin-top: 10px; height: 34px; }

/* ---- Two column panels ---- */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; margin-bottom: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h3 { font-size: 15px; margin: 0; font-weight: 800; }
.panel-link { font-size: 12.5px; color: var(--violet); font-weight: 700; cursor: pointer; text-decoration: none; }

.schedule-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.schedule-row:last-child { border-bottom: none; }
.time-chip { background: var(--violet-light); color: var(--violet-dark); font-size: 11.5px; font-weight: 700; padding: 7px 10px; border-radius: 8px; min-width: 68px; text-align: center; }
.schedule-info { flex: 1; }
.schedule-name { font-size: 13.5px; font-weight: 700; }
.schedule-sub { font-size: 12px; color: var(--muted); }
.status-pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px; }
.status-pill.confirmed { background: var(--success-light); color: var(--success); }
.status-pill.progress { background: var(--warning-light); color: var(--warning); }
.status-pill.upcoming { background: var(--blue-light); color: var(--blue); }

/* ---- Donut chart (CSS conic-gradient, no library needed) ---- */
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut {
  width: 150px; height: 150px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.donut-center { width: 96px; height: 96px; border-radius: 50%; background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center .num { font-size: 22px; font-weight: 800; font-family: 'Plus Jakarta Sans'; }
.donut-center .label { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-row .lname { flex: 1; color: var(--ink); font-weight: 600; }
.legend-row .lval { color: var(--muted); font-weight: 700; }

.mini-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.mini-stat { background: var(--bg); border-radius: 12px; padding: 14px; text-align: left; }
.mini-stat .micon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; margin-bottom: 8px; }
.mini-stat .mval { font-size: 18px; font-weight: 800; font-family: 'Plus Jakarta Sans'; }
.mini-stat .mlabel { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---- Side panels (reminders, quick actions) ---- */
.reminder-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.reminder-row:last-child { border-bottom: none; }
.reminder-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.reminder-title { font-size: 13px; font-weight: 700; }
.reminder-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qa-btn {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 10px; text-align: center; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--ink);
  transition: background 0.15s;
}
.qa-btn:hover { background: var(--line-soft); }
.qa-icon { font-size: 19px; margin-bottom: 7px; display: block; }

/* ---- Tables ---- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 13px 18px; border-bottom: 1px solid var(--line); background: var(--bg); }
td { padding: 13px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover { background: var(--line-soft); cursor: pointer; }

.name-cell { display: flex; align-items: center; gap: 10px; }
.name-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--violet-light); color: var(--violet-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800; font-family: 'Plus Jakarta Sans';
  flex-shrink: 0;
}

.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px; }
.tag.status-active { background: var(--success-light); color: var(--success); }
.tag.status-inactive { background: var(--line-soft); color: var(--muted); }
.tag.status-discharged { background: var(--warning-light); color: var(--warning); }
.dept-tag { background: var(--violet-light); color: var(--violet-dark); font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px; display: inline-block; margin: 0 4px 4px 0; }

.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 100%; max-width: 360px;
  padding: 10px 15px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 13.5px; background: var(--panel); font-family: inherit;
}

.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }

.coming-soon { text-align: center; padding: 90px 20px; }
.coming-soon .icon { font-size: 42px; margin-bottom: 14px; }
.coming-soon h3 { font-size: 18px; margin: 0 0 6px; }
.coming-soon p { color: var(--muted); font-size: 13.5px; max-width: 360px; margin: 0 auto; }

/* ================= MODAL ================= */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(30,34,51,0.5);
  align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--panel); border-radius: 18px; padding: 30px 34px; width: 100%; max-width: 660px; box-shadow: 0 20px 60px rgba(30,34,51,0.25); }
.modal h3 { margin: 0 0 4px; font-size: 19px; font-weight: 800; }
.modal .modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 13.5px; font-family: inherit; background: var(--bg);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--violet); outline-offset: 1px; background: #fff; }
.field textarea { resize: vertical; min-height: 62px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: auto; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.dept-checklist { display: flex; flex-wrap: wrap; gap: 8px; }
.dept-chip { border: 1.5px solid var(--line); padding: 7px 14px; border-radius: 100px; font-size: 13px; cursor: pointer; user-select: none; font-weight: 600; }
.dept-chip.selected { background: var(--violet); border-color: var(--violet); color: #fff; }

.section-divider { grid-column: 1/-1; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--violet-dark); border-top: 1px solid var(--line); padding-top: 15px; margin-top: 4px; }

.toast {
  position: fixed; bottom: 26px; right: 26px;
  background: var(--ink); color: #fff;
  padding: 13px 22px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: none; z-index: 200;
}
.toast.show { display: block; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ================= LOGIN SCREEN ================= */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--violet-light), var(--magenta-light));
  padding: 20px;
}
.login-card {
  background: var(--panel); border-radius: 20px; padding: 36px 34px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(30,34,51,0.15);
}
.dropdown-item:hover { background: var(--line-soft); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; padding: 12px; }
  .brand, .sidebar-footer { display: none; }
  .nav { flex-direction: row; }
  .nav-item { white-space: nowrap; }
  .search-wrap { width: 200px; max-width: 50vw; }
  .main { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .profile-text { display: none; }
}
