/* =========================================================
   MOTHERCARE — Design System
   Rural Health Unit Maternal Tracking System
   ========================================================= */

:root {
  --navy: #16213b;
  --navy-2: #1d2a4a;
  --navy-3: #243356;
  --navy-border: #2b3a5e;
  --burgundy: #8e2437;
  --burgundy-bright: #a92b47;
  --burgundy-dark: #711c2b;
  --magenta: #b02a4a;
  --green: #1e9e6a;
  --green-bg: #e8f6ef;
  --amber: #e8842c;
  --amber-bg: #fdf3e7;
  --red: #d6403f;
  --red-bg: #fdeaea;
  --blue: #2e6fdb;
  --blue-bg: #eaf1fd;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d3d8e0;
  --text: #22303f;
  --text-2: #5b6b7f;
  --text-3: #8a97a8;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(18, 33, 59, .05), 0 1px 3px rgba(18, 33, 59, .06);
  --shadow-md: 0 2px 6px rgba(18, 33, 59, .07), 0 8px 24px rgba(18, 33, 59, .06);
  --shadow-lg: 0 10px 40px rgba(18, 33, 59, .18);
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 78px;
  --header-h: 66px;
  --transition: 160ms cubic-bezier(.4, 0, .2, 1);
  --font: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 21px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13.5px; }

p { margin: 0 0 10px; }

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

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

.app-main { flex: 1; padding: 24px 28px 40px; }
.page-content { max-width: 1440px; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy) 0%, #121c33 100%);
  color: #c6cfdf;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.collapse-btn {
  margin-left: auto; width: 26px; height: 26px; border-radius: 7px;
  background: transparent; border: 1px solid var(--navy-border);
  color: #8fa1c0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.collapse-btn:hover { color: #fff; border-color: #4a5f8c; }
body.sidebar-collapsed .collapse-btn { display: flex; margin-left: 0; transform: rotate(180deg); }

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--navy-border);
  min-height: 74px;
}

.brand-logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(142, 36, 55, .45);
}

.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 14.5px; letter-spacing: .02em; white-space: nowrap; }
.brand-sub { color: #8fa1c0; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0 20px; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--navy-border); border-radius: 3px; }

.nav-group-label {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: #6d7ea0; padding: 14px 20px 6px; white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  color: #b9c3d6;
  border-radius: 8px;
  margin: 2px 10px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-item .icon { flex-shrink: 0; color: #7e8fb1; transition: color var(--transition); }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item:hover .icon { color: #fff; }
.nav-item.is-active {
  background: var(--burgundy);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(142, 36, 55, .35);
}
.nav-item.is-active .icon { color: #fff; }

.sidebar-footer {
  border-top: 1px solid var(--navy-border);
  padding: 14px 16px;
  background: rgba(0, 0, 0, .12);
}
.rhu-box { display: flex; gap: 10px; align-items: center; }
.rhu-box > div { min-width: 0; flex: 1; }
.rhu-pin {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--burgundy-dark);
  display: flex; align-items: center; justify-content: center;
  color: #ffd9e0; flex-shrink: 0;
}
.rhu-title { color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.35; overflow-wrap: break-word; }
.rhu-sub { color: #8fa1c0; font-size: 11px; white-space: nowrap; }

.sidebar-logout-form {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--navy-border);
}
.sidebar-logout {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  border: 0; border-radius: 8px; background: transparent;
  color: #f0b8c2; font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.sidebar-logout .icon { flex-shrink: 0; }
.sidebar-logout:hover { background: rgba(214, 59, 59, .18); color: #fff; }

/* Sidebar collapsed */
body.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .brand-sub,
body.sidebar-collapsed .nav-item span.nav-label,
body.sidebar-collapsed .nav-group-label,
body.sidebar-collapsed .rhu-title,
body.sidebar-collapsed .rhu-sub,
body.sidebar-collapsed .nav-item .nav-caret { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 18px 0; }
body.sidebar-collapsed .brand-logo { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 12px 0; margin: 2px 12px; }
body.sidebar-collapsed .rhu-box { justify-content: center; }
body.sidebar-collapsed .sidebar-logout { justify-content: center; padding: 12px 0; }
body.sidebar-collapsed .sidebar-logout .nav-label { display: none; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
}
.topbar-title h1 { font-size: 17.5px; margin: 0; }
.topbar-title p { margin: 0; font-size: 12px; color: var(--text-2); }
.topbar-spacer { flex: 1; }

.global-search { position: relative; width: 300px; }
.global-search .search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.global-search .search-input:focus {
  border-color: var(--burgundy-bright);
  box-shadow: 0 0 0 3px rgba(169, 43, 71, .12);
  background: #fff;
}
.global-search > svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.search-results {
  position: absolute; top: 110%; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-md);
  max-height: 380px; overflow-y: auto; display: none; z-index: 60;
}
.search-results.is-open { display: block; }
.search-result-item {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid #f0f2f5;
  cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #f7f8fb; }
.sr-name { font-weight: 600; font-size: 13px; }
.sr-meta { font-size: 11.5px; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); background: #fafbfc; }
.icon-btn .notif-dot {
  position: absolute; top: 7px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff;
  border-radius: 8px; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.icon-btn .notif-dot.is-emergency { background: var(--red); animation: pulse-emergency 1.6s infinite; }

@keyframes pulse-emergency {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 64, 63, .5); }
  50% { box-shadow: 0 0 0 5px rgba(214, 64, 63, 0); }
}

.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 10px; }
.user-chip:hover { background: #f5f6f9; }
.user-chip .u-name { font-size: 13px; font-weight: 600; line-height: 1.15; }
.user-chip .u-role { font-size: 11px; color: var(--text-2); line-height: 1.15; }

/* Notification dropdown */
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 360px; max-height: 440px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  display: none; z-index: 60;
}
.dropdown-panel.is-open { display: block; animation: drop-in var(--transition); }
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  font-weight: 650; font-size: 13.5px;
}
.notif-item { display: flex; gap: 11px; padding: 12px 16px; border-bottom: 1px solid #f1f3f6; cursor: pointer; }
.notif-item:hover { background: #f8f9fb; }
.notif-item.unread { background: #fdf4f6; }
.notif-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.notif-item .n-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.notif-item .n-msg { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.notif-item .n-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--burgundy); color: #fff; box-shadow: 0 2px 6px rgba(142, 36, 55, .25); }
.btn-primary:hover { background: var(--burgundy-bright); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: #aab3c0; background: #fafbfc; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c43736; }
.btn-subtle { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-subtle:hover { background: #f1f2f6; color: var(--text); }
.btn-link { background: transparent; color: var(--burgundy-bright); border: none; padding: 6px 8px; }
.btn-link:hover { text-decoration: underline; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #188a5c; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #265fc4; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .spinner { width: 15px; height: 15px; }
.btn.is-loading { cursor: progress; }
.btn.is-loading > span:last-child { white-space: nowrap; }

/* ---------- Loading spinner & page loader ---------- */
.spinner {
  display: inline-block; width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.is-loading { cursor: progress; }

.page-loader {
  position: fixed; inset: 0; z-index: 200;
  display: none; align-items: center; justify-content: center;
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.page-loader.is-active { display: flex; animation: fade-in var(--transition); }
.page-loader-box {
  background: var(--surface); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 24px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 13px;
  min-width: 190px; text-align: center;
}
.page-loader-box .spinner { width: 32px; height: 32px; border-width: 3px; color: var(--burgundy); }
.page-loader-text { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-header h2 { margin: 0; font-size: 15px; }
.card-header .card-sub { font-size: 12px; color: var(--text-2); margin: 0; }
.card-body { padding: 20px; }
.card-hover { transition: box-shadow var(--transition), transform var(--transition); }
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: box-shadow var(--transition), transform var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.metric-icon.is-navy { background: var(--navy); color: #b9c3d6; }
.metric-icon.is-green { background: var(--green-bg); color: var(--green); }
.metric-icon.is-amber { background: var(--amber-bg); color: var(--amber); }
.metric-icon.is-red { background: var(--red-bg); color: var(--red); }
.metric-value { font-size: 25px; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.metric-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.metric-delta { font-size: 11.5px; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-neutral { color: var(--text-3); }
.metric-note { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ---------- Grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 18px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead th {
  background: #f8f9fb;
  color: var(--text-2);
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  font-weight: 650;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  min-width: 0;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: #f7f8fb; }
.data-table tbody tr.is-critical { background: #fdf2f2; }
.data-table tbody tr.is-critical:hover { background: #fbeaea; }
.data-table .num { font-variant-numeric: tabular-nums; }
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}
.row-clickable { cursor: pointer; }

.patient-cell { display: flex; align-items: center; gap: 10px; }
.patient-cell .pc-name { font-weight: 600; color: var(--text); }
.patient-cell .pc-id { font-size: 11px; color: var(--text-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; line-height: 1.5;
  white-space: nowrap;
}
.badge-low { background: var(--green-bg); color: #157a51; }
.badge-high { background: var(--amber-bg); color: #b45f14; }
.badge-emergency { background: var(--red-bg); color: #c0322f; }
.badge-red { background: var(--red-bg); color: #c0322f; }
.badge-amber { background: var(--amber-bg); color: #b45f14; }
.badge-blue { background: var(--blue-bg); color: #2459b4; }
.badge-neutral { background: #eef0f4; color: var(--text-2); }

.risk-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 7px;
  font-size: 11.5px; font-weight: 650;
  white-space: nowrap;
}
.risk-badge .risk-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.risk-badge.badge-low { background: var(--green-bg); color: #157a51; }
.risk-badge.badge-low .risk-dot { background: var(--green); }
.risk-badge.badge-high { background: var(--amber-bg); color: #b45f14; }
.risk-badge.badge-high .risk-dot { background: var(--amber); }
.risk-badge.badge-emergency { background: var(--red-bg); color: #c0322f; }
.risk-badge.badge-emergency .risk-dot { background: var(--red); animation: blink 1.4s infinite; }
.risk-badge.badge-neutral { background: #eef0f4; color: var(--text-2); }
.risk-badge.badge-neutral .risk-dot { background: var(--text-3); }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.is-full { grid-column: 1 / -1; }
.form-group.is-third { grid-column: span 1; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--red); }
.form-hint { font-size: 11.5px; color: var(--text-3); }
.form-control, .form-select, textarea.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
  border-color: var(--burgundy-bright);
  box-shadow: 0 0 0 3px rgba(169, 43, 71, .12);
}
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { min-height: 84px; resize: vertical; }
.form-group.has-error .form-control { border-color: var(--red); }
.field-error { color: var(--red); font-size: 11.5px; font-weight: 600; }
.input-group { position: relative; }
.input-group .form-control { padding-right: 42px; }
.input-group .toggle-pw {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-3);
  width: 34px; height: 34px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; transition: color var(--transition), background var(--transition);
}
.input-group .toggle-pw:hover { color: var(--text); background: rgba(0, 0, 0, .04); }
.form-section-title {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700;
  margin: 22px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.checkbox-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; }
.checkbox-row input[type="checkbox"] {
  width: 17px; height: 17px; margin-top: 1px; accent-color: var(--burgundy);
}

/* checkbox pills (danger signs) */
.danger-sign-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.danger-pill { position: relative; }
.danger-pill input { position: absolute; opacity: 0; }
.danger-pill label {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
  cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: all var(--transition); user-select: none;
}
.danger-pill input:checked + label {
  border-color: var(--red);
  background: var(--red-bg);
  color: #b0322f;
  font-weight: 600;
}
.danger-pill label::before {
  content: ''; width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid var(--border-strong); flex-shrink: 0;
  transition: all var(--transition);
}
.danger-pill input:checked + label::before {
  background: var(--red); border-color: var(--red);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  background-size: 11px; background-position: center; background-repeat: no-repeat;
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.filter-bar .form-group { min-width: 150px; flex: 1; max-width: 220px; }
.filter-bar .form-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; }
.search-field { position: relative; flex: 2; min-width: 220px; max-width: 380px; }
.search-field input {
  width: 100%; padding: 10px 14px 10px 38px;
  border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13.5px; outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.search-field input:focus { border-color: var(--burgundy-bright); box-shadow: 0 0 0 3px rgba(169,43,71,.12); }
.search-field svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  padding: 11px 16px; font-size: 13px; font-weight: 600;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none;
  font-family: inherit;
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); background: #f7f8fb; }
.tab.is-active { color: var(--burgundy-bright); border-bottom-color: var(--burgundy-bright); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 24, 40, .55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 60px 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.is-open { display: flex; animation: fade-in var(--transition); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: modal-up var(--transition);
  max-height: 88vh; display: flex; flex-direction: column;
}
.modal.is-lg { max-width: 780px; }
@keyframes modal-up { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* confirm / alert dialog variant */
.modal.modal-confirm { max-width: 430px; }
.modal-confirm .modal-head { gap: 12px; }
.modal-confirm .confirm-icon {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--amber-bg); color: var(--amber);
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-confirm .confirm-title { flex: 1; }
.modal-confirm .confirm-msg { color: var(--text-2); margin: 0; }
.confirm-danger .confirm-icon { background: var(--red-bg); color: var(--red); }
.confirm-alert .confirm-icon { background: var(--blue-bg); color: var(--blue); }

/* ---------- Progress / risk distribution ---------- */
.risk-dist-row { margin-bottom: 16px; }
.risk-dist-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.risk-dist-head .rd-label { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.risk-dist-head .rd-label .risk-dot { width: 9px; height: 9px; border-radius: 50%; }
.risk-dist-head .rd-val { font-weight: 650; color: var(--text-2); }
.risk-bar { height: 9px; background: #eef0f4; border-radius: 6px; overflow: hidden; }
.risk-bar > span { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }
.bar-low { background: var(--green); }
.bar-high { background: var(--amber); }
.bar-emergency { background: var(--red); }
.bar-navy { background: var(--navy); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 4px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -26px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
}
.tl-dot.is-emergency { border-color: var(--red); }
.tl-dot.is-high { border-color: var(--amber); }
.tl-dot.is-low { border-color: var(--green); }
.tl-dot.is-blue { border-color: var(--blue); }
.tl-date { font-size: 11.5px; color: var(--text-3); font-weight: 600; letter-spacing: .02em; }
.tl-title { font-weight: 600; font-size: 13.5px; margin: 1px 0 2px; }
.tl-detail { font-size: 12.5px; color: var(--text-2); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-month-title { font-size: 16px; font-weight: 700; min-width: 190px; text-align: center; }
.cal-view-switch { display: flex; background: #eef0f4; border-radius: 8px; padding: 3px; }
.cal-view-switch button {
  border: none; background: transparent; padding: 6px 13px;
  border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-2);
  font-family: inherit;
}
.cal-view-switch button.is-active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cal-dow { background: #f8f9fb; text-align: center; padding: 8px; font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.cal-day {
  background: #fff; min-height: 92px; padding: 6px;
  cursor: pointer; position: relative;
  transition: background var(--transition);
}
.cal-day:hover { background: #fafbfd; }
.cal-day.is-out { background: #f6f7f9; }
.cal-day.is-today .cal-daynum { background: var(--burgundy); color: #fff; }
.cal-daynum { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 650; }
.cal-appt-count { font-size: 10.5px; font-weight: 700; margin-top: 4px; border-radius: 6px; padding: 2px 6px; display: inline-block; }
.cal-appt-count.c0 { color: var(--text-3); background: #f1f3f6; }
.cal-appt-count.c1 { color: #157a51; background: var(--green-bg); }
.cal-appt-count.c2 { color: #b45f14; background: var(--amber-bg); }
.cal-appt-count.c3 { color: #fff; background: var(--amber); }
.cal-appt-count.c4 { color: #fff; background: var(--red); }

.cal-week-rows td { border: 1px solid var(--border); vertical-align: top; padding: 0; height: 96px; width: 14.28%; }
.cal-week-rows td .cal-daynum { margin: 6px; }
.cal-appt-chip {
  display: block; margin: 2px 5px; padding: 3px 7px;
  border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 3px solid transparent;
}
.cal-appt-chip.low { background: var(--green-bg); color: #157a51; border-left-color: var(--green); }
.cal-appt-chip.high { background: var(--amber-bg); color: #b45f14; border-left-color: var(--amber); }
.cal-appt-chip.emergency { background: var(--red-bg); color: #c0322f; border-left-color: var(--red); }

.cal-day-view { display: flex; flex-direction: column; }
.cal-day-view .slot { display: flex; gap: 10px; padding: 9px 6px; border-bottom: 1px solid #f1f3f6; align-items: flex-start; }
.cal-day-view .slot-time { width: 76px; font-size: 12px; font-weight: 700; color: var(--text-2); flex-shrink: 0; }

/* ---------- Alerts list ---------- */
.alert-card {
  display: flex; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; margin-bottom: 10px;
  transition: box-shadow var(--transition);
}
.alert-card:hover { box-shadow: var(--shadow-md); }
.alert-card.is-emergency { border-left: 4px solid var(--red); background: #fefafa; }
.alert-card.is-high { border-left: 4px solid var(--amber); }
.alert-card.is-reminder { border-left: 4px solid var(--blue); }
.alert-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.alert-card .a-title { font-weight: 650; font-size: 13.5px; }
.alert-card .a-reason { font-size: 12.5px; color: var(--text-2); }
.alert-card .a-meta { font-size: 11.5px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.alert-card .a-action { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Key/value list ---------- */
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px dashed #eef0f3; font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .kv-k { color: var(--text-2); font-weight: 500; }
.kv .kv-v { font-weight: 650; text-align: right; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 26px; }

/* ---------- Vital sign tiles ---------- */
.vital-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.vital-tile {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; text-align: center; background: #fff;
  transition: box-shadow var(--transition);
}
.vital-tile:hover { box-shadow: var(--shadow-sm); }
.vital-label { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.vital-value { font-size: 20px; font-weight: 750; margin: 4px 0 2px; letter-spacing: -.01em; }
.vital-unit { font-size: 11px; color: var(--text-3); }
.vital-status { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 2px 8px; margin-top: 5px; }
.vital-status.normal { background: var(--green-bg); color: #157a51; }
.vital-status.warning { background: var(--amber-bg); color: #b45f14; }
.vital-status.critical { background: var(--red-bg); color: #c0322f; }

/* ---------- Risk classification output ---------- */
.risk-output { border-radius: 12px; border: 1px solid; padding: 18px 20px; margin-top: 16px; }
.risk-output.ro-low { border-color: #bfe6d3; background: var(--green-bg); }
.risk-output.ro-high { border-color: #f3d4ae; background: var(--amber-bg); }
.risk-output.ro-emergency { border-color: #f3c0bf; background: var(--red-bg); }
.ro-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ro-title { font-size: 16px; font-weight: 750; display: flex; align-items: center; gap: 10px; }
.ro-score { font-size: 13px; font-weight: 700; }
.ro-emergency .ro-score { color: #b0322f; }
.ro-high .ro-score { color: #b45f14; }
.ro-low .ro-score { color: #157a51; }
.ro-rules { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.ro-rule { background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 7px; padding: 4px 9px; font-size: 11.5px; font-weight: 600; color: var(--text); }
.ro-action { margin-top: 12px; font-weight: 650; font-size: 13.5px; color: var(--text); }
.ro-emergency .ro-action { color: #a8231f; }
.ro-ref-box {
  margin-top: 12px; background: var(--red); color: #fff;
  border-radius: 8px; padding: 10px 14px;
  font-weight: 750; font-size: 13px; letter-spacing: .02em;
  display: flex; align-items: center; gap: 8px;
  animation: ref-pulse 1.8s infinite;
}
@keyframes ref-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(214,64,63,.45); } 50% { box-shadow: 0 0 0 6px rgba(214,64,63,0); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-lg);
  min-width: 280px; max-width: 380px;
  animation: toast-in var(--transition);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.toast-success { border-left: 4px solid var(--green); }
.toast-error { border-left: 4px solid var(--red); }
.toast-info { border-left: 4px solid var(--blue); }
.toast-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.toast-success .toast-icon { background: var(--green); }
.toast-error .toast-icon { background: var(--red); }
.toast-info .toast-icon { background: var(--blue); }
.toast-msg { font-size: 13px; font-weight: 550; flex: 1; }
.toast-close { background: none; border: none; color: var(--text-3); font-size: 17px; cursor: pointer; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 5px; align-items: center; justify-content: flex-end; }
.pg-btn {
  padding: 6px 12px; border-radius: 7px;
  border: 1px solid var(--border-strong);
  font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer;
  background: #fff; transition: all var(--transition);
}
.pg-btn:hover { border-color: var(--burgundy-bright); color: var(--burgundy-bright); }
.pg-btn.is-active { background: var(--burgundy); border-color: var(--burgundy); color: #fff; }
.pg-btn.is-disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 46px 20px; color: var(--text-3);
}
.empty-state svg { color: #c4ccd6; margin-bottom: 10px; }
.empty-state h3 { color: var(--text-2); font-size: 14px; margin: 6px 0 3px; }
.empty-state p { font-size: 12.5px; margin: 0; }

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-card { height: 140px; border-radius: var(--radius); }

/* ---------- Avatar ---------- */
.avatar {
  border-radius: 50%; color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: .02em;
}

/* ---------- Patient header / profile hero ---------- */
.profile-hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 24px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.profile-hero .ph-avatar { width: 64px; height: 64px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; font-weight: 750; flex-shrink: 0; }
.profile-hero .ph-name { font-size: 19px; font-weight: 750; letter-spacing: -.01em; }
.profile-hero .ph-id { color: var(--text-2); font-size: 13px; font-weight: 550; }
.profile-hero .ph-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.profile-hero .ph-meta b { color: var(--text); }
.profile-hero .ph-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.hero-badge-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Stat mini ---------- */
.mini-stat { display: flex; flex-direction: column; }
.mini-stat .ms-val { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.mini-stat .ms-label { font-size: 11.5px; color: var(--text-2); font-weight: 550; }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat-strip .mini-stat { background: #f8f9fb; border: 1px solid var(--border); border-radius: 9px; padding: 12px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; }
.login-left {
  flex: 1; background: linear-gradient(155deg, var(--navy) 0%, #101a30 100%);
  color: #fff; position: relative; overflow: hidden;
  display: flex; align-items: center; padding: 40px 30px;
}
@media (min-width: 1366px) {
  .login-left { padding: 50px 40px; }
}
.login-left .dec {
  position: absolute; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .09);
}
.login-left .dec.d1 { width: 420px; height: 420px; right: -140px; top: -120px; }
.login-left .dec.d2 { width: 300px; height: 300px; right: -60px; top: 40px; border-color: rgba(169, 43, 71, .25); }
.login-left .dec.d3 { width: 220px; height: 220px; left: -80px; bottom: -70px; }
.login-left .dec.d4 { width: 120px; height: 120px; left: 40px; bottom: 30px; border-color: rgba(169, 43, 71, .3); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 38px; }
.login-brand .brand-logo { width: 46px; height: 46px; font-size: 22px; }
.login-brand .lb-name { font-size: 20px; font-weight: 750; letter-spacing: .02em; }
.login-brand .lb-sub { font-size: 11px; color: #8fa1c0; text-transform: uppercase; letter-spacing: .1em; }
.login-left h1 { color: #fff; font-size: 30px; line-height: 1.22; letter-spacing: -.01em; max-width: 480px; }
.login-left h1 span { color: #ff8fa8; }
.login-capabilities { margin-top: 34px; display: flex; flex-direction: column; gap: 15px; }
.login-cap { display: flex; gap: 13px; align-items: flex-start; }
.login-cap .lc-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: rgba(169, 43, 71, .18); border: 1px solid rgba(255, 143, 168, .3);
  color: #ff8fa8; display: flex; align-items: center; justify-content: center;
}
.login-cap .lc-title { font-weight: 650; font-size: 14px; }
.login-cap .lc-desc { font-size: 12.5px; color: #9db0cf; }
.login-privacy {
  margin-top: 40px; display: flex; gap: 11px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 10px; padding: 12px 14px;
  font-size: 12px; color: #aebdd8; max-width: 480px;
  align-items: flex-start;
}
.login-privacy svg { color: #7fd0aa; flex-shrink: 0; margin-top: 1px; }

.login-right { flex: 1; display: flex; align-items: center; justify-content: center; background: #fafbfc; padding: 30px 20px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 25px; }
@media (min-width: 1366px) {
  .login-right { padding: 40px 30px; }
  .login-card { max-width: 420px; padding: 35px 30px; }
}
.login-card .lc-head { margin-bottom: 26px; }
.login-card .lc-head h2 { font-size: 23px; }
.login-card .lc-head p { color: var(--text-2); font-size: 13.5px; margin: 4px 0 0; }
.login-form .form-group { margin-bottom: 12px; }
.login-secure {
  margin-top: 18px; display: flex; gap: 8px; align-items: center;
  font-size: 12px; color: var(--text-3); justify-content: center;
}
.login-remember { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; font-size: 12px; }
.login-remember label { display: flex; align-items: center; gap: 7px; cursor: pointer; color: var(--text-2); }

/* ---------- Rules panel ---------- */
.rule-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid #f1f3f6; align-items: flex-start; }
.rule-item:last-child { border-bottom: none; }
.rule-class {
  width: 62px; flex-shrink: 0; text-align: center;
  border-radius: 7px; padding: 5px 4px; font-size: 10.5px; font-weight: 750;
}
.rule-class.rc-emergency { background: var(--red-bg); color: #b0322f; }
.rule-class.rc-high { background: var(--amber-bg); color: #b45f14; }
.rule-class.rc-low { background: var(--green-bg); color: #157a51; }
.rule-name { font-weight: 650; font-size: 13px; }
.rule-desc { font-size: 12px; color: var(--text-2); }
.rule-arrow { color: var(--text-3); font-weight: 700; font-size: 12px; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0 0 3px; }
.page-head .page-sub { color: var(--text-2); font-size: 13px; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.chart-box { position: relative; height: 260px; }
.chart-box.is-sm { height: 220px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.chart-legend .lg-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.note-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 9px; font-size: 12.5px; align-items: flex-start; }
.note-box.note-info { background: var(--blue-bg); color: #2459b4; }
.note-box.note-emergency { background: var(--red-bg); color: #a8231f; }
.note-box.note-warn { background: var(--amber-bg); color: #a8621a; }
.note-box svg { flex-shrink: 0; margin-top: 1px; }

code, .mono { font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace; font-size: 12px; }

.table-actions { display: flex; gap: 4px; }
.action-btn {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all var(--transition);
}
.action-btn:hover { border-color: var(--burgundy-bright); color: var(--burgundy-bright); }
.action-btn.is-danger:hover { border-color: var(--red); color: var(--red); }

.section-label {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700; margin: 18px 0 10px;
}

/* tab panel animation */
.tab-panel { animation: fade-in var(--transition); }
.hidden { display: none !important; }

/* settings nav */
.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  min-width: 0;
}
.settings-content,
.settings-content > .card { width: 100%; max-width: 100%; min-width: 0; }
.settings-nav { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px; position: sticky; top: calc(var(--header-h) + 20px); }
.settings-nav .sn-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 550;
  color: var(--text-2); cursor: pointer; transition: all var(--transition);
  border: none; background: none; width: 100%; text-align: left; font-family: inherit;
}
.settings-nav .sn-item:hover { background: #f5f6f9; color: var(--text); }
.settings-nav .sn-item.is-active { background: var(--burgundy); color: #fff; }

/* Fit all essential account controls beside the settings navigation. */
.user-management-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.user-management-table { width: 100%; table-layout: fixed; }
.user-management-table th:nth-child(1) { width: 20%; }
.user-management-table th:nth-child(2) { width: 15%; }
.user-management-table th:nth-child(3) { width: 15%; }
.user-management-table th:nth-child(4) { width: 20%; }
.user-management-table th:nth-child(5) { width: 12%; }
.user-management-table th:nth-child(6) { width: 8%; }
.user-management-table th:nth-child(7) { width: 10%; }
.user-management-table td { overflow-wrap: anywhere; }
.user-management-table td:last-child .btn { width: 100%; justify-content: center; }
.user-management-table td:last-child form { width: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 1500px) {
  .user-management-table th,
  .user-management-table td { padding-left: 9px; padding-right: 9px; }
  .user-management-table th:nth-child(3),
  .user-management-table td:nth-child(3) { display: none; }
  .user-management-table th:nth-child(1) { width: 21%; }
  .user-management-table th:nth-child(2) { width: 16%; }
  .user-management-table th:nth-child(4) { width: 22%; }
  .user-management-table th:nth-child(5) { width: 13%; }
  .user-management-table th:nth-child(6) { width: 10%; }
  .user-management-table th:nth-child(7) { width: 18%; }
}

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .vital-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  .global-search { width: 220px; }
  .main-wrap { margin-left: var(--sidebar-w); }
  body.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-w); }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .brand-name, body.sidebar-collapsed .brand-sub,
  body.sidebar-collapsed .nav-item span.nav-label, body.sidebar-collapsed .nav-group-label,
  body.sidebar-collapsed .rhu-title, body.sidebar-collapsed .rhu-sub { display: inline; }
  body.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 18px; }
  body.sidebar-collapsed .brand-logo { display: flex; }
  body.sidebar-collapsed .collapse-btn { margin-left: auto; transform: none; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 10px 18px; margin: 2px 10px; }
  body.sidebar-collapsed .rhu-box { justify-content: flex-start; }
  body.sidebar-collapsed .sidebar-logout { justify-content: flex-start; padding: 10px 12px; }
  body.sidebar-collapsed .sidebar-logout .nav-label { display: inline; }
}

@media (max-width: 880px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  body.mobile-nav-open .sidebar { transform: translateX(0); }
  .main-wrap { margin-left: 0 !important; }
  .app-main { padding: 18px 14px 32px; }
  .topbar { padding: 0 14px; }
  .menu-toggle { display: flex !important; }
  .global-search { display: none; }
  .user-chip .u-meta { display: none; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .vital-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.is-third { grid-column: span 1; }
  .login-page { flex-direction: column; }
  .login-left { display: none; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; overflow-x: auto; }
  .settings-nav .sn-item { white-space: nowrap; width: auto; }
  .profile-hero .ph-actions { margin-left: 0; width: 100%; }
  .profile-hero .ph-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .vital-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: 1fr; }
  .danger-sign-grid { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .dropdown-panel { position: fixed; left: 10px; right: 10px; top: 70px; width: auto; }
  .modal-overlay { padding: 20px 10px; }
}

.nav-overlay {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: rgba(16, 24, 40, .5);
}
@media (max-width: 880px) {
  body.mobile-nav-open .nav-overlay { display: block; }
}
.menu-toggle { display: none; }

/* Focus visibility for accessibility */
:focus-visible { outline: 2px solid var(--burgundy-bright); outline-offset: 2px; }

/* Scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c8cfd9; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #aab4c2; }
::-webkit-scrollbar-track { background: transparent; }
