@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f8fafc;
  --bg-white: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-hover: #1d4ed8;
  --fg: #0f172a;
  --fg-secondary: #475569;
  --fg-muted: #94a3b8;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --success-border: #bbf7d0;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

body { -webkit-font-smoothing: antialiased; }

/* ===== SHELL ===== */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 24px 16px 16px;
  overflow-y: auto;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: #fff;
  background: var(--accent);
}

.logo-title {
  font-size: 15px; font-weight: 700; color: var(--fg);
  display: block;
}

.logo-subtitle {
  font-size: 12px; color: var(--fg-muted); display: block;
}

.sidebar__nav { flex: 1; }

.sidebar__section-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 20px 0 6px 12px;
}

.sidebar__item {
  width: 100%; border: none; outline: none;
  background: transparent;
  color: var(--fg-secondary);
  font-size: 13px; font-weight: 500;
  padding: 9px 12px;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 150ms, color 150ms;
}

.sidebar__item::before { display: none; }

.sidebar__item:hover {
  background: var(--bg-subtle);
  color: var(--fg);
}

.sidebar__item--active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.sidebar__footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.sidebar__version {
  font-size: 12px; color: var(--fg-muted);
}

/* ===== MAIN ===== */
.main {
  background: var(--bg);
  overflow-y: auto;
  padding: 28px 32px;
}

/* ===== SCREEN ===== */
.screen {
  display: none;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 200ms ease;
}

.screen--active { display: block; }

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

.screen__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.screen__title {
  margin: 0 0 4px;
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.screen__subtitle {
  margin: 0;
  font-size: 14px; color: var(--fg-secondary);
}

.screen__actions {
  display: flex; gap: 8px; align-items: center;
  flex-shrink: 0;
  padding-top: 4px;
}

/* ===== CONTENT AREA ===== */
.screen__content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.screen__content--split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
}

.screen__content--mobile {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

/* ===== PANEL / CARD ===== */
.panel {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.panel--primary,
.panel--secondary {
  border-color: var(--border);
}

.panel--nested {
  margin-top: 16px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  padding: 16px;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel__title {
  font-size: 15px; font-weight: 600; color: var(--fg);
}

.panel__description {
  font-size: 13px; color: var(--fg-muted);
}

.panel__filters {
  display: flex; gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
  border-radius: 8px;
  padding: 8px 16px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 150ms;
  font-family: inherit;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: var(--bg-white);
  color: var(--fg-secondary);
  border-color: var(--border-strong);
}

.btn--ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--fg-muted);
}

.btn--full {
  width: 100%;
  text-align: center;
}

/* ===== INPUTS ===== */
.input {
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-white);
  color: var(--fg);
  outline: none;
  font-family: inherit;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input--search { width: 260px; }
.input--select { padding-right: 28px; }

/* ===== TABLE ===== */
.table-wrapper {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.table-wrapper--compact {
  border-color: var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--bg-subtle);
}

.table th {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--fg-secondary);
}

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

.table tbody tr:hover {
  background: var(--bg-subtle);
}

.table--dense th, .table--dense td {
  padding: 8px 10px;
}

.table__row--active {
  background: var(--accent-light) !important;
}

.table__row--alert {
  background: var(--danger-light) !important;
}

.cell-title {
  font-weight: 600; color: var(--fg);
}

.cell-subtitle {
  font-size: 12px; color: var(--fg-muted);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}

.badge--score {
  background: var(--accent-light);
  color: var(--accent);
}

.badge--score-high {
  background: var(--success-light);
  color: var(--success);
}

.badge--risk-high {
  background: var(--danger-light);
  color: var(--danger);
}

.badge--risk-medium {
  background: var(--warning-light);
  color: var(--warning);
}

.badge--risk-low {
  background: var(--success-light);
  color: var(--success);
}

.badge--status-new {
  background: var(--accent-light);
  color: var(--accent);
}

.badge--status-secondary {
  background: var(--warning-light);
  color: var(--warning);
}

.badge--status-approved {
  background: var(--success-light);
  color: var(--success);
}

.badge--status-scheduled {
  background: var(--purple-light);
  color: var(--purple);
}

.badge--status-active {
  background: var(--success-light);
  color: var(--success);
}

.badge--status-completed {
  background: var(--bg-subtle);
  color: var(--fg-muted);
}

.badge--allergy {
  background: var(--danger-light);
  color: var(--danger);
}

.badge--diet {
  background: #ecfdf5;
  color: #047857;
}

/* ===== DETAIL GRID (Admission side panel) ===== */
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-grid__col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-card {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 16px;
}

.detail-card__title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.detail-card__main {
  font-size: 16px; font-weight: 700; color: var(--fg);
  margin-bottom: 4px;
}

.detail-card__meta {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

.detail-card__note {
  margin-top: 10px;
  font-size: 13px; color: var(--fg-secondary);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.detail-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.detail-metric__label {
  font-size: 13px; color: var(--fg-secondary);
}

.detail-metric__value {
  font-size: 18px; font-weight: 700;
}

.detail-metric__value--high {
  color: var(--success);
}

.detail-actions {
  display: flex; flex-direction: column; gap: 8px;
}

/* ===== TIMELINE ===== */
.timeline {
  list-style: none; padding: 0; margin: 0;
}

.timeline__item {
  position: relative;
  padding-left: 20px;
  padding-bottom: 16px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
}

.timeline__item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: -5px; top: 4px;
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid var(--bg-white);
}

.timeline__meta {
  font-size: 12px; color: var(--fg-muted);
}

.timeline__title {
  font-size: 14px; font-weight: 600; color: var(--fg);
  margin-top: 2px;
}

.timeline__body {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 4px;
  line-height: 1.6;
}

.timeline__tag {
  margin-top: 4px;
  font-size: 12px; color: var(--fg-muted);
}

/* ===== PATIENT HEADER (360 page) ===== */
.patient-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.patient-header__identity {
  display: flex; align-items: center; gap: 14px;
}

.avatar {
  width: 48px; height: 48px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  color: #fff;
  background: var(--accent);
}

.patient-header__name {
  font-size: 18px; font-weight: 700; color: var(--fg);
}

.patient-header__meta {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

.patient-header__status { text-align: right; }

.status-line {
  display: flex; align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.status-line__text {
  font-size: 13px; color: var(--fg-secondary);
}

/* ===== COLUMNS ===== */
.columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 20px;
}

.columns--balanced {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.column {
  display: flex; flex-direction: column; gap: 20px;
}

/* ===== PILL LIST ===== */
.pill-list {
  margin: 0; padding: 0;
  list-style: none;
  font-size: 13px; color: var(--fg-secondary);
}

.pill-list li {
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border-left: 3px solid var(--accent);
}

/* ===== SESSION LIST ===== */
.session-list {
  list-style: none; padding: 0; margin: 0;
}

.session-list__item {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-white);
  margin-bottom: 8px;
  transition: box-shadow 150ms;
}

.session-list__item:hover {
  box-shadow: var(--shadow);
}

.session-list__meta {
  font-size: 12px; color: var(--fg-muted);
  margin-bottom: 4px;
}

.session-list__title {
  font-size: 14px; font-weight: 600; color: var(--fg);
}

.session-list__body {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

/* ===== CONTACT GRID ===== */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.contact-card {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 12px;
}

.contact-card__role {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.contact-card__name {
  font-size: 14px; font-weight: 600; color: var(--fg);
}

.contact-card__meta {
  font-size: 13px; color: var(--fg-secondary);
}

/* ===== SESSION GRID (Calendar view) ===== */
.session-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: box-shadow 150ms;
}

.session-card:hover {
  box-shadow: var(--shadow);
}

.session-card--highlight {
  border-color: var(--accent);
  border-left: 4px solid var(--accent);
  background: #f8faff;
}

.session-card__time {
  font-size: 14px; font-weight: 700;
  color: var(--fg);
  min-width: 50px;
  padding-top: 1px;
}

.session-card__body { flex: 1; }

.session-card__title {
  font-size: 14px; font-weight: 600; color: var(--fg);
}

.session-card__meta {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

.session-card__pill {
  display: inline-flex;
  margin-top: 6px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px; font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
}

/* ===== FILTERS ROW ===== */
.filters-row {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 16px 20px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.filters-row__group {
  display: flex; flex-direction: column; gap: 4px;
}

.filters-row__label {
  font-size: 11px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}

.filters-row__group .input { min-width: 160px; }

/* ===== ALERT LIST ===== */
.alert-list {
  list-style: none; padding: 0; margin: 0;
}

.alert-list__item {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.alert-list__item--danger {
  background: var(--danger-light);
  border: 1px solid var(--danger-border);
}

.alert-list__item--warning {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
}

.alert-list__title {
  font-size: 14px; font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.alert-list__body {
  font-size: 13px; color: var(--fg-secondary);
  line-height: 1.6;
}

/* ===== MOBILE APP VIEWS ===== */
.mobile-view {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.mobile-view__header {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 12px;
}

.mobile-screen {
  background: var(--bg);
  border-radius: 20px;
  padding: 16px 14px 12px;
  border: 1px solid var(--border-strong);
}

.mobile-topbar {
  margin-bottom: 14px;
}

.mobile-title {
  display: block;
  font-size: 16px; font-weight: 700; color: var(--fg);
}

.mobile-subtitle {
  display: block;
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

.mobile-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.mobile-card--alert {
  border-color: var(--danger-border);
  background: var(--danger-light);
}

.mobile-card__label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.mobile-card__title {
  font-size: 14px; font-weight: 600; color: var(--fg);
}

.mobile-card__meta {
  font-size: 13px; color: var(--fg-secondary);
  margin-top: 2px;
}

.mobile-list {
  list-style: none; padding: 0; margin: 0;
}

.mobile-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mobile-list li:last-child { border-bottom: none; }

.mobile-list__time {
  min-width: 48px;
  font-size: 13px; font-weight: 600;
  color: var(--fg-muted);
}

.mobile-list__text {
  font-size: 13px; color: var(--fg);
}

.mobile-bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.mobile-bottom-nav__item {
  font-size: 12px; font-weight: 500;
  color: var(--fg-muted);
  padding: 4px 8px;
  border-radius: 6px;
}

.mobile-bottom-nav__item--active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.mobile-week {
  display: flex; flex-direction: column; gap: 8px;
}

.mobile-week__day {
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border);
}

.mobile-week__label {
  font-size: 12px; font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-divider {
  margin: 14px 0 8px;
  font-size: 12px; font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.mobile-list--patients li {
  padding: 8px 0;
  gap: 10px;
}

.mobile-list__avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
}

.mobile-list__patient {
  display: flex; flex-direction: column;
}

.mobile-list__patient-name {
  font-size: 14px; font-weight: 600; color: var(--fg);
}

.mobile-list__patient-meta {
  font-size: 12px; color: var(--fg-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .screen__content--split,
  .screen__content--mobile { grid-template-columns: minmax(0, 1fr); }
  .columns, .columns--balanced { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .screen__header { flex-direction: column; align-items: flex-start; }
  .contact-grid { grid-template-columns: minmax(0, 1fr); }
}
