/* ============================================================
   HealthCRM — Swiss Minimalist Design System
   Typography: Host Grotesk (Google Fonts)
   Version: 1.0
   ============================================================ */

/* ── 1. Design Tokens ────────────────────────────────────── */
:root {
  /* Colors */
  --c-bg:          #F6F5F2;
  --c-surface:     #FFFFFF;
  --c-surface-2:   #F0EEE9;
  --c-border:      #1A1A1A;
  --c-border-soft: #D6D3CC;
  --c-text:        #0D0D0D;
  --c-text-muted:  #6B6862;
  --c-text-inv:    #FFFFFF;
  --c-accent:      #0A0A0A;
  --c-sidebar:     #111110;
  --c-sidebar-nav: rgba(255,255,255,0.06);
  --c-sidebar-act: rgba(255,255,255,0.14);
  --c-danger:      #C0392B;
  --c-danger-bg:   #FDF0EF;
  --c-success:     #1E8449;
  --c-success-bg:  #EAF7EF;
  --c-warning:     #B7770D;
  --c-warning-bg:  #FEF9EC;
  --c-info:        #1A5276;
  --c-info-bg:     #EBF5FB;
  --c-blue:        #1A6EBD;

  /* Typography */
  --font:          'Host Grotesk', system-ui, -apple-system, sans-serif;

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-w:   256px;
  --topbar-h:    60px;
  --radius:      2px;
  --radius-md:   4px;
  --radius-lg:   8px;

  /* Transitions */
  --t-fast:   120ms ease;
  --t-base:   200ms ease;
  --t-slow:   350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 2. Reset & Base ─────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: var(--font);
}

img { display: block; max-width: 100%; }

/* ── 3. Layout — App Shell ───────────────────────────────── */
body:not(.login-body) {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── 4. Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--c-sidebar);
  color: var(--c-text-inv);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  z-index: 100;
  transition: transform var(--t-slow);
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark--sm {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-text-inv);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.brand-mark--sm .brand-cross {
  color: var(--c-sidebar);
  font-size: 16px;
  line-height: 1;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--c-text-inv);
}

.sidebar-role {
  padding: var(--sp-3) var(--sp-5);
}

.role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px var(--sp-2);
  border-radius: var(--radius);
  border: 1px solid;
}

.role-badge--admin {
  color: #F0C040;
  border-color: rgba(240,192,64,0.4);
  background: rgba(240,192,64,0.08);
}

.role-badge--worker {
  color: rgba(255,255,255,0.6);
  border-color: rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
}

/* Navigation */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3) var(--sp-3);
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.58);
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--c-sidebar-nav);
  color: rgba(255,255,255,0.9);
}

.nav-item--active {
  background: var(--c-sidebar-act);
  color: #FFFFFF;
  font-weight: 600;
}

.nav-icon {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
  opacity: 0.8;
}

.nav-indicator {
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: #FFFFFF;
  border-radius: 2px 0 0 2px;
}

.sidebar-spacer { flex: 1; }

/* Sidebar User */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,0.9);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  transition: color var(--t-fast);
}

.user-logout:hover {
  color: var(--c-danger);
}

/* ── 5. Main Content ─────────────────────────────────────── */
.main-content {
  grid-column: 2;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── 6. Topbar ───────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-soft);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-8);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 24px;
  padding: 0;
}

.topbar-toggle span {
  display: block;
  height: 1.5px;
  background: var(--c-text);
  border-radius: 1px;
  transition: transform var(--t-base);
}

.topbar-title { flex: 1; }

.page-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.topbar-time {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ── 7. Page Content ─────────────────────────────────────── */
.page-content {
  padding: var(--sp-8);
  flex: 1;
}

/* ── 8. Cards ────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--c-border-soft);
}

.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-muted);
}

.card-body {
  padding: var(--sp-6);
}

.card-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--c-border-soft);
  background: var(--c-surface-2);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}

.kpi-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-md);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-base), transform var(--t-base);
}

.kpi-card:hover {
  border-color: var(--c-border);
  transform: translateY(-1px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--c-accent);
  opacity: 0;
  transition: opacity var(--t-base);
}

.kpi-card:hover::before { opacity: 1; }

.kpi-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-3);
}

.kpi-value {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--c-text);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-top: var(--sp-2);
}

.kpi-icon {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  font-size: 1.4rem;
  opacity: 0.08;
  line-height: 1;
}

/* ── 9. Form Elements ────────────────────────────────────── */
.form-group {
  margin-bottom: var(--sp-5);
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-2);
}

.form-label .required {
  color: var(--c-danger);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--c-border);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.07);
}

.form-input::placeholder { color: var(--c-text-muted); opacity: 0.6; }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.form-hint {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin-top: var(--sp-1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

.form-row--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .form-input {
  padding-right: 44px;
}

.input-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-muted);
  font-size: 0.9rem;
  padding: 0;
  transition: color var(--t-fast);
}

.input-toggle:hover { color: var(--c-text); }

/* Character counter */
.char-counter {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  text-align: right;
  margin-top: var(--sp-1);
  font-variant-numeric: tabular-nums;
}

.char-counter.over-limit { color: var(--c-danger); }

/* ── 10. Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn--primary {
  background: var(--c-accent);
  color: var(--c-text-inv);
  border-color: var(--c-accent);
}

.btn--primary:hover {
  background: #2D2D2D;
  border-color: #2D2D2D;
}

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

.btn--outline:hover {
  background: var(--c-surface-2);
}

.btn--ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

.btn--danger {
  background: var(--c-danger);
  color: #fff;
  border-color: var(--c-danger);
}

.btn--danger:hover { background: #A93226; }

.btn--success {
  background: var(--c-success);
  color: #fff;
  border-color: var(--c-success);
}

.btn--sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.78rem;
}

.btn--lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: 0.95rem;
}

.btn--full { width: 100%; }

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
}

/* ── 11. Tables ──────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: var(--c-surface-2);
  text-align: left;
  padding: var(--sp-3) var(--sp-5);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border-soft);
  white-space: nowrap;
}

.data-table td {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: middle;
  color: var(--c-text);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr {
  transition: background var(--t-fast);
}

.data-table tbody tr:hover {
  background: var(--c-surface-2);
}

/* ── 12. Alerts ──────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--sp-5);
  border: 1px solid;
  animation: alertSlideIn 0.2s ease;
}

@keyframes alertSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert--error   { background: var(--c-danger-bg);  color: var(--c-danger);  border-color: rgba(192,57,43,0.2); }
.alert--success { background: var(--c-success-bg); color: var(--c-success); border-color: rgba(30,132,73,0.2); }
.alert--warning { background: var(--c-warning-bg); color: var(--c-warning); border-color: rgba(183,119,13,0.2); }
.alert--info    { background: var(--c-info-bg);    color: var(--c-info);    border-color: rgba(26,82,118,0.2); }

.alert-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ── 13. Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius);
  border: 1px solid;
}

.badge--success { color: var(--c-success); border-color: rgba(30,132,73,0.3); background: var(--c-success-bg); }
.badge--danger  { color: var(--c-danger);  border-color: rgba(192,57,43,0.3); background: var(--c-danger-bg); }
.badge--warning { color: var(--c-warning); border-color: rgba(183,119,13,0.3); background: var(--c-warning-bg); }
.badge--neutral { color: var(--c-text-muted); border-color: var(--c-border-soft); background: var(--c-surface-2); }

/* ── 14. Search Bar ──────────────────────────────────────── */
.search-bar {
  position: relative;
  max-width: 400px;
}

.search-bar-input {
  width: 100%;
  padding: var(--sp-3) var(--sp-4) var(--sp-3) 40px;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.88rem;
  background: var(--c-surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.search-bar-input:focus {
  border-color: var(--c-border);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.07);
}

.search-bar-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--c-border-soft);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.search-spinner.visible { display: block; }

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ── 15. Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border-soft);
}

.pagination-info {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  flex: 1;
}

.page-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text-muted);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  cursor: pointer;
  background: var(--c-surface);
  font-family: var(--font);
}

.page-btn:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border);
}

.page-btn.active {
  background: var(--c-accent);
  color: var(--c-text-inv);
  border-color: var(--c-accent);
}

/* ── 16. Analytics Bar Charts ────────────────────────────── */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 50px;
  align-items: center;
  gap: var(--sp-3);
}

.bar-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  background: var(--c-surface-2);
  border-radius: 1px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--c-accent);
  border-radius: 1px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.bar-fill--alt { background: var(--c-blue); }
.bar-fill--success { background: var(--c-success); }
.bar-fill--danger { background: var(--c-danger); }

.bar-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}

/* ── 17. Toggle (SMS/WhatsApp) ───────────────────────────── */
.channel-toggle {
  display: flex;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.channel-btn {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text-muted);
  background: var(--c-surface);
  border: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}

.channel-btn + .channel-btn {
  border-left: 1px solid var(--c-border-soft);
}

.channel-btn.active {
  background: var(--c-accent);
  color: var(--c-text-inv);
}

/* ── 18. Progress Bar ────────────────────────────────────── */
.progress-bar {
  background: var(--c-surface-2);
  border-radius: 1px;
  height: 4px;
  overflow: hidden;
  margin: var(--sp-3) 0;
}

.progress-fill {
  height: 100%;
  background: var(--c-accent);
  border-radius: 1px;
  transition: width var(--t-slow);
  width: 0%;
}

/* ── 19. Upload Zone ─────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--c-border-soft);
  border-radius: var(--radius-md);
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-base), background var(--t-base);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--c-border);
  background: var(--c-surface-2);
}

.upload-zone input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.upload-icon {
  font-size: 2rem;
  margin-bottom: var(--sp-3);
  opacity: 0.3;
}

.upload-text {
  font-size: 0.88rem;
  color: var(--c-text-muted);
  line-height: 1.6;
}

.upload-text strong { color: var(--c-text); }

/* ── 20. Settings Key Fields ─────────────────────────────── */
.setting-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: start;
  gap: var(--sp-5);
  padding: var(--sp-5) 0;
  border-bottom: 1px solid var(--c-border-soft);
}

.setting-row:last-child { border-bottom: none; }

.setting-label-group { padding-top: var(--sp-1); }

.setting-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-top: 2px;
  line-height: 1.5;
}

/* ── 21. Activity Feed ───────────────────────────────────── */
.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border-soft);
  transition: background var(--t-fast);
}

.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--c-surface-2); }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.activity-dot--patient  { background: var(--c-success); }
.activity-dot--message  { background: var(--c-blue); }
.activity-dot--admin    { background: var(--c-warning); }

.activity-text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--c-text);
  line-height: 1.5;
}

.activity-text strong { font-weight: 600; }

.activity-time {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── 22. Modal (Glassmorphism) ───────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--t-slow);
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--c-border-soft);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--c-text-muted);
  transition: background var(--t-fast), color var(--t-fast);
  font-size: 1.1rem;
}

.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }

.modal-body { padding: var(--sp-6); }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--c-border-soft);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

/* ── 23. Section Headers ─────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  margin-top: 2px;
}

/* ── 24. Empty State ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-8);
  color: var(--c-text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  opacity: 0.2;
  margin-bottom: var(--sp-4);
}

.empty-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: var(--sp-2);
}

.empty-desc {
  font-size: 0.82rem;
  max-width: 300px;
  margin: 0 auto var(--sp-5);
}

/* ── 25. Login Page ──────────────────────────────────────── */
.login-body {
  display: flex;
  min-height: 100vh;
  background: var(--c-bg);
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-5);
  position: relative;
  z-index: 10;
}

.login-brand {
  text-align: center;
  margin-bottom: var(--sp-10);
}

.brand-mark {
  width: 56px;
  height: 56px;
  background: var(--c-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-4);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.brand-cross {
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 300;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--c-text);
  margin-bottom: var(--sp-1);
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

.login-form {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-note {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  text-align: center;
  margin-top: var(--sp-5);
  line-height: 1.6;
}

/* Decorative elements on login */
.login-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.decor-line {
  position: absolute;
  background: var(--c-border-soft);
}

.decor-line--1 {
  width: 1px;
  height: 100vh;
  left: 22%;
  top: 0;
  opacity: 0.4;
}

.decor-line--2 {
  width: 100vw;
  height: 1px;
  top: 35%;
  left: 0;
  opacity: 0.3;
}

.decor-grid {
  position: absolute;
  right: -10%;
  top: -10%;
  width: 60%;
  height: 60%;
  background-image:
    linear-gradient(var(--c-border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-border-soft) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.3;
  transform: rotate(-8deg);
}

/* ── 26. Divider ─────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--c-border-soft);
  margin: var(--sp-6) 0;
}

/* ── 27. Loading Skeleton ────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-border-soft) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 28. Utility Classes ─────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.text-muted { color: var(--c-text-muted); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ── 29. Grid Layouts ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-6); }

/* ── 30. Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  body:not(.login-body) {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .topbar-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base);
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: all;
  }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row--3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 44px; }
}

@media (max-width: 600px) {
  .page-content { padding: var(--sp-5); }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 2.2rem; }
}
