:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --primary-50: #f0fdfa;
  --accent: #f59e0b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f6f8fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.04);
  --shadow: 0 1px 3px 0 rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(13,148,136,.08), 0 4px 6px -4px rgba(13,148,136,.05);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ========== LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-light);
}
.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(13,148,136,.25);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.nav-section {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
}

.nav { padding: 4px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
  transition: all .15s;
}
.nav-item:hover { background: var(--primary-50); color: var(--primary-dark); }
.nav-item.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 10px -3px rgba(13,148,136,.45);
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.nav-item.active .badge { background: rgba(255,255,255,.25); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 13px;
  flex: 0 0 36px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.avatar.blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.avatar.pink { background: linear-gradient(135deg, #f472b6, #db2777); }
.avatar.green { background: linear-gradient(135deg, #34d399, #059669); }
.avatar.teal { background: linear-gradient(135deg, #2dd4bf, var(--primary)); }

.user-meta { line-height: 1.25; }
.user-meta .name { font-weight: 600; font-size: 13px; }
.user-meta .role { font-size: 11px; color: var(--text-muted); }

/* ========== MAIN ========== */
.main { min-width: 0; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title { font-size: 18px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text-muted); }

.search {
  flex: 1;
  max-width: 380px;
  margin-left: auto;
  position: relative;
}
.search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: all .15s;
}
.search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(13,148,136,.1); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-light); }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-muted);
  position: relative;
  transition: all .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}

.content { padding: 24px 28px 60px; }

/* ========== KPI CARDS ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border-light);
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex: 0 0 44px;
}
.kpi-icon.teal { background: var(--primary-light); color: var(--primary-dark); }
.kpi-icon.amber { background: #fef3c7; color: #d97706; }
.kpi-icon.violet { background: #ede9fe; color: #7c3aed; }
.kpi-icon.rose { background: #fce7f3; color: #db2777; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; }
.kpi-delta { font-size: 11px; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ========== CARDS / SECTIONS ========== */
.row { display: grid; gap: 18px; margin-bottom: 18px; }
.row.split-2 { grid-template-columns: 2fr 1fr; }
.row.split-3 { grid-template-columns: 1fr 1fr 1fr; }
.row.split-1-1 { grid-template-columns: 1fr 1fr; }

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.card-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
}
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .meta { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 18px 20px; }
.card-body.flush { padding: 0; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border: 1px solid transparent;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-outline { border-color: var(--border); background: #fff; color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ========== TABLES ========== */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 11px 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--primary-50); }
.tbl .who { display: flex; align-items: center; gap: 10px; }
.tbl .who .name { font-weight: 500; }
.tbl .who .sub { font-size: 11px; color: var(--text-muted); }

/* ========== PILLS / BADGES ========== */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.success { color: #047857; background: #d1fae5; }
.pill.warning { color: #b45309; background: #fef3c7; }
.pill.danger  { color: #b91c1c; background: #fee2e2; }
.pill.info    { color: #1d4ed8; background: #dbeafe; }
.pill.neutral { color: #475569; background: #e2e8f0; }
.pill.violet  { color: #6d28d9; background: #ede9fe; }
.pill.teal    { color: var(--primary-dark); background: var(--primary-light); }

/* ========== APPOINTMENTS / TIMELINE ========== */
.appt-list { display: flex; flex-direction: column; }
.appt {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  padding: 14px 20px;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
}
.appt:last-child { border-bottom: 0; }
.appt-time {
  text-align: center;
  padding: 6px 0;
  border-radius: 8px;
  background: var(--primary-50);
  border: 1px solid var(--primary-light);
}
.appt-time .h { font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.appt-time .m { font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.appt-main { min-width: 0; }
.appt-main .who { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.appt-main .who .name { font-weight: 600; }
.appt-main .detail { font-size: 12px; color: var(--text-muted); }

/* ========== CALENDAR ========== */
.cal-grid {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  gap: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.cal-head {
  padding: 12px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
.cal-head .day { font-size: 18px; color: var(--text); }
.cal-head.today .day { color: var(--primary); }
.cal-head .label { color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.cal-time {
  padding: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  border-bottom: 1px solid var(--border-light);
}
.cal-cell {
  padding: 6px;
  min-height: 64px;
  border-bottom: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  position: relative;
}
.cal-event {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 4px;
}
.cal-event .ev-name { font-weight: 600; color: var(--primary-dark); }
.cal-event .ev-dr { color: var(--text-muted); }
.cal-event.amber { background: #fef3c7; border-color: var(--accent); }
.cal-event.amber .ev-name { color: #b45309; }
.cal-event.violet { background: #ede9fe; border-color: #7c3aed; }
.cal-event.violet .ev-name { color: #6d28d9; }
.cal-event.rose { background: #fce7f3; border-color: #db2777; }
.cal-event.rose .ev-name { color: #be185d; }

/* ========== CHART (CSS-based) ========== */
.bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  height: 180px;
  align-items: end;
  padding: 8px 0 24px;
  position: relative;
}
.bar {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: all .25s;
}
.bar:hover { filter: brightness(1.1); }
.bar .bar-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
}

.donut {
  width: 160px; height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0 55%, var(--accent) 55% 78%, #a78bfa 78% 92%, #cbd5e1 92% 100%);
  position: relative;
  margin: 0 auto;
}
.donut::after {
  content: '';
  position: absolute;
  inset: 22px;
  background: #fff;
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 1;
}
.donut-center .big { font-size: 22px; font-weight: 700; }
.donut-center .small { font-size: 11px; color: var(--text-muted); }
.legend { margin-top: 16px; display: grid; gap: 8px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-item .sw { width: 10px; height: 10px; border-radius: 3px; }

/* ========== PROFILE LAYOUT ========== */
.profile-head {
  display: flex;
  gap: 22px;
  align-items: center;
  padding: 22px;
  background: linear-gradient(135deg, var(--primary-50), #fff);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin-bottom: 18px;
}
.profile-head h2 { font-size: 20px; }
.profile-head .meta-row { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-muted); }
.profile-head .meta-row span { display: inline-flex; gap: 6px; align-items: center; }

.tab-strip {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--primary-dark); border-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { color: var(--text); font-weight: 500; }

/* ========== ALERT BANNER ========== */
.banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .row.split-2, .row.split-3, .row.split-1-1 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
}
