/* ============================================
   FMC Concierge — Shared Design System
   Epic-inspired EMR aesthetic: professional,
   data-dense, navy/white with subtle accents.
   ============================================ */

:root {
  /* Brand palette */
  --navy:        #0a3d62;
  --navy-2:      #08365a;
  --navy-3:      #062a48;
  --brand:       #1c5d99;
  --brand-2:     #2e7cb8;
  --accent:      #0ea5b7;
  --accent-2:    #0891a3;

  /* Ink (text) */
  --ink:         #0f172a;
  --ink-2:       #334155;
  --ink-3:       #64748b;
  --ink-4:       #94a3b8;
  --ink-on-dark: #e2e8f0;

  /* Surfaces & lines */
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #f1f5f9;
  --line:        #e2e8f0;
  --line-2:      #cbd5e1;
  --line-3:      #94a3b8;

  /* Status */
  --success:     #0a7a4a;
  --success-bg:  #d6f0e2;
  --warning:     #b45309;
  --warning-bg:  #fef3c7;
  --danger:      #b91c1c;
  --danger-bg:   #fee2e2;
  --info:        #075985;
  --info-bg:     #e0f2fe;
  --pending:     #6b21a8;
  --pending-bg:  #ede9fe;

  /* Geometry */
  --radius:      6px;
  --radius-sm:   4px;
  --radius-lg:   10px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(15,23,42,.06);
  --shadow:      0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg:   0 10px 30px -10px rgba(15,23,42,.20), 0 4px 12px -2px rgba(15,23,42,.08);

  /* Typography */
  --font:        'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:   'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Sidebar */
  --sidebar-w:   240px;
  --topbar-h:    56px;
}

/* ============================================
   RESET / BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }

/* ============================================
   FORMS
   ============================================ */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .02em;
}
.field label .req { color: var(--danger); margin-left: 2px; }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(28,93,153,.15);
}
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--surface-3);
  color: var(--ink-3);
  cursor: not-allowed;
}
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  transition: all .15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--navy-2); }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-3); }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-2); }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: var(--line-2);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-full { width: 100%; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: var(--radius);
}

/* ============================================
   BADGES / PILLS
   ============================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-success  { background: var(--success-bg); color: var(--success); }
.pill-warning  { background: var(--warning-bg); color: var(--warning); }
.pill-danger   { background: var(--danger-bg);  color: var(--danger);  }
.pill-info     { background: var(--info-bg);    color: var(--info);    }
.pill-pending  { background: var(--pending-bg); color: var(--pending); }
.pill-neutral  { background: var(--surface-3);  color: var(--ink-2);   }

/* ============================================
   CARDS / PANELS
   ============================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.card-subtitle {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.card-body { padding: 16px; }
.card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   TABLES
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-3);
  font-size: 13px;
}

/* ============================================
   STAT CARDS
   ============================================ */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.stat-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
  letter-spacing: -.01em;
  font-feature-settings: "tnum";
}
.stat-trend {
  font-size: 12px;
  margin-top: 6px;
  color: var(--ink-3);
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--info);
  display: grid; place-items: center;
}

/* ============================================
   APP SHELL (dashboard layout)
   ============================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: var(--navy);
  color: var(--ink-on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-mark {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  letter-spacing: -.02em;
}
.sidebar-brand-text {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  letter-spacing: .01em;
}
.sidebar-brand-text small {
  display: block;
  font-weight: 400;
  font-size: 10px;
  opacity: .65;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar-section {
  padding: 16px 12px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(226,232,240,.5);
  font-weight: 500;
}
.sidebar-nav { padding: 0 8px; flex: 1; overflow-y: auto; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 1px;
  border-radius: var(--radius-sm);
  color: rgba(226,232,240,.85);
  font-size: 13px;
  font-weight: 400;
  transition: background .12s, color .12s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-link.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-link svg { width: 16px; height: 16px; opacity: .85; flex: none; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}
.sidebar-user {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  color: #fff;
  flex: none;
}
.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: rgba(226,232,240,.6);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Topbar */
.topbar {
  grid-area: topbar;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.topbar-spacer { flex: 1; }
.topbar-search {
  position: relative;
  width: 320px;
}
.topbar-search input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
}
.topbar-search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(28,93,153,.15);
}
.topbar-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  width: 14px; height: 14px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--ink-2);
  position: relative;
  transition: background .12s;
}
.topbar-btn:hover { background: var(--surface-3); }
.topbar-btn svg { width: 16px; height: 16px; }
.topbar-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}

/* Main content */
.main {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  gap: 16px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 4px;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalIn .18s ease-out;
}
.modal-lg { max-width: 720px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.modal-close:hover { background: var(--surface-3); color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}

/* ============================================
   TOAST
   ============================================ */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn .25s ease-out;
  max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.danger  { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================
   UTILS
   ============================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; } .text-xs { font-size: 11px; }
.text-muted { color: var(--ink-3); }
.text-ink { color: var(--ink); }
.font-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Empty states */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty-state-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--ink-3);
  margin: 0 auto 16px;
}
.empty-state-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.empty-state-text {
  font-size: 13px;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--ink-2); }
.tab.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar { display: none; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
