/* ============================================================
   Assistant Médical — Design tokens & shared components
   Light clinical theme. UI font: IBM Plex Sans. Meta: IBM Plex Mono.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #F2F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;
  --surface-3: #EEF2F5;

  /* Ink */
  --ink: #1C2B3A;
  --ink-2: #4E6172;
  --ink-3: #84939F;

  /* Lines */
  --line: #E2E8ED;
  --line-2: #CFD9E0;

  /* Brand */
  --accent: #1B3A5C;          /* primary CTA / nav — tweakable */
  --accent-ink: #FFFFFF;
  --accent-soft: #EAF1F7;
  --accent-line: #C8D8E6;
  --blue: #2E6DA4;            /* links, info */
  --blue-bg: #EDF4FA;

  /* Semantic */
  --amber: #9A5B12;
  --amber-strong: #C77A1C;
  --amber-bg: #FDF4E5;
  --amber-line: #EFD9B4;
  --green: #1E7F4F;
  --green-bg: #E9F5EE;
  --green-line: #BFE2CD;
  --red: #B3372B;
  --red-bg: #FBEEEC;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --shadow-1: 0 1px 2px rgba(28, 43, 58, .06);
  --shadow-2: 0 4px 16px rgba(28, 43, 58, .10);
  --shadow-3: 0 16px 48px rgba(28, 43, 58, .18);

  --font: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --pad-row: 12px;            /* list row vertical padding (density) */
}
[data-density="compact"] { --pad-row: 7px; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--blue); text-decoration: none; }

/* ---------- App layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.app--center { align-items: center; justify-content: center; }
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 36px 64px; }
.page--narrow { max-width: 880px; }
.page--wide { max-width: 1380px; }

.login-page { background: var(--bg); padding: 24px; }
.login-card {
  width: 390px; max-width: 100%;
  padding: 26px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-3);
}
.login-card h1 { font-size: 22px; font-weight: 600; }
.login-foot { font-size: 12px; color: var(--ink-3); line-height: 1.5; margin-top: 4px; }
.pilot-notice {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 8px 22px;
  background: var(--blue-bg); color: #1F4E75;
  border-bottom: 1px solid #CCE0F0;
  font-size: 12.5px;
}
.pilot-notice span { flex: 1; min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 16px;
}
.sidebar__logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.sidebar__title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.sidebar__sub { font-size: 11.5px; color: var(--ink-3); margin-top: -2px; }

.navitem {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  border: none; background: none; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  text-align: left;
}
.navitem:hover { background: var(--surface-3); color: var(--ink); }
.navitem.is-active { background: var(--accent-soft); color: var(--accent); }
.navitem .navitem__count {
  margin-left: auto; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2);
  border-radius: 99px; padding: 1px 8px;
}
.navitem.is-active .navitem__count { background: #fff; }
.navitem .navitem__count--alert { background: var(--amber-bg); color: var(--amber); }

.sidebar__section {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); padding: 16px 10px 6px;
}
.sidebar__footer { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.sidebar__user b { display: block; font-size: 13.5px; font-weight: 600; }
.sidebar__user span { font-size: 12px; color: var(--ink-3); }

/* ---------- Avatars ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 600; font-size: 13px; color: #fff;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.avatar--ghost { background: var(--surface-3) !important; color: var(--ink-3); border: 1.5px dashed var(--line-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; padding: 9px 16px;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.12); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn--secondary:hover { border-color: var(--ink-3); }
.btn--ghost { background: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn--soft { background: var(--accent-soft); color: var(--accent); }
.btn--soft:hover { background: #DDE9F3; }
.btn--green { background: var(--green); color: #fff; }
.btn--green:hover { filter: brightness(1.1); }
.btn--lg { padding: 13px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn--sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--teaser { position: relative; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; border-radius: 99px;
  padding: 2px 10px; border: 1px solid transparent; white-space: nowrap;
}
.chip--amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.chip--green { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }
.chip--blue { background: var(--blue-bg); color: var(--blue); border-color: #CCE0F0; }
.chip--gray { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }
.chip--ai { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.conf { font-size: 11.5px; font-weight: 600; border-radius: 5px; padding: 1px 7px; }
.conf--high { background: var(--green-bg); color: var(--green); }
.conf--mid { background: var(--amber-bg); color: var(--amber); }
.conf--low { background: var(--red-bg); color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card__title { font-size: 14px; font-weight: 600; }
.card__body { padding: 16px 18px; }

/* ---------- Pilot checklist ---------- */
.pilot-checklist {
  margin-top: 22px;
  overflow: hidden;
}
.pilot-checklist__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.pilot-step {
  display: grid;
  grid-template-columns: 24px 36px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.pilot-step:nth-child(2n) { border-right: none; }
.pilot-step:nth-last-child(-n+2) { border-bottom: none; }
.pilot-step__num {
  width: 22px; height: 22px; border-radius: 99px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 11.5px; font-weight: 700;
}
.pilot-step__icon {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.pilot-step h2 {
  font-size: 13.5px; font-weight: 600;
  margin-bottom: 2px;
}
.pilot-step p {
  font-size: 12.5px; line-height: 1.45;
  margin-bottom: 8px;
}
.pilot-checklist__foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
}

/* ---------- Inputs ---------- */
.input {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 14px; background: var(--surface); color: var(--ink);
  outline: none;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.input::placeholder { color: var(--ink-3); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }

.searchbox { position: relative; }
.searchbox .input { padding-left: 34px; }
.searchbox svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }

/* ---------- Drop zones ---------- */
.dropzone {
  border: 2px dashed var(--line-2); border-radius: var(--r-lg);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 28px 20px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--blue); background: var(--blue-bg); }
.dropzone__icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: 6px;
}
.dropzone__title { font-weight: 600; font-size: 15px; }
.dropzone__hint { font-size: 12.5px; color: var(--ink-3); }

/* Global drag overlay */
.dropveil {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(27, 58, 92, .55); backdrop-filter: blur(2px);
  display: grid; place-items: center;
}
.dropveil__box {
  background: var(--surface); border-radius: 18px; padding: 44px 64px;
  border: 2.5px dashed var(--blue); text-align: center; box-shadow: var(--shadow-3);
}

/* ---------- File rows & doc tiles ---------- */
.filerow {
  display: flex; align-items: center; gap: 12px;
  padding: var(--pad-row) 14px;
  border-bottom: 1px solid var(--line);
}
.filerow:last-child { border-bottom: none; }
.filerow__name { font-weight: 500; font-size: 13.5px; }
.filerow__meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.filerow:hover { background: var(--surface-2); }

.doctype {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .03em;
}
.doctype--pdf { background: var(--red-bg); color: var(--red); }
.doctype--img { background: var(--blue-bg); color: var(--blue); }
.doctype--bio { background: var(--green-bg); color: var(--green); }
.doctype--note { background: var(--amber-bg); color: var(--amber); }
.doctype--doc { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tables / list rows ---------- */
.listrow {
  display: flex; align-items: center; gap: 14px;
  padding: var(--pad-row) 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer; background: var(--surface);
}
.listrow:hover { background: var(--surface-2); }
.listrow:last-child { border-bottom: none; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.listhead {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* ---------- Tabs / segmented ---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg__btn {
  border: none; background: none; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 5px 14px;
}
.seg__btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.langtabs { display: inline-flex; gap: 2px; border-bottom: none; }
.langtab {
  border: none; background: none; padding: 3px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
}
.langtab.is-active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Callouts ---------- */
.callout {
  border-radius: var(--r-md); padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13.5px;
}
.callout--amber { background: var(--amber-bg); border: 1px solid var(--amber-line); color: #6B4310; }
.callout--blue { background: var(--blue-bg); border: 1px solid #CCE0F0; color: #1F4E75; }
.callout--green { background: var(--green-bg); border: 1px solid var(--green-line); color: #14573A; }

/* ---------- Timeline ---------- */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.tl__item { position: relative; padding: 8px 0; }
.tl__dot {
  position: absolute; left: -22px; top: 14px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--line-2);
}
.tl__item--accent .tl__dot { border-color: var(--blue); }

/* ---------- Misc ---------- */
.kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px;
  padding: 0 5px; background: var(--surface);
}
.divider { height: 1px; background: var(--line); border: none; margin: 8px 0; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 500;
  border-radius: 10px; padding: 11px 18px; box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: 10px; z-index: 400;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { transform: translate(-50%, 10px); } to { transform: translate(-50%, 0); } }

@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.pulsing { animation: pulse-soft 1.4s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid var(--accent-line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes rise-in { from { transform: translateY(8px); } to { transform: translateY(0); } }
.rise { animation: rise-in .3s ease both; }

/* Skeleton shimmer for AI extraction */
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel {
  border-radius: 6px; height: 14px;
  background: linear-gradient(90deg, var(--surface-3) 25%, #E7EDF1 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* ---------- Layout columns (responsive) ---------- */
.cols-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.cols-side-main { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.cols-side-main--narrow { grid-template-columns: 260px minmax(0, 1fr); }
.cols-fields { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; }
.sidecol { position: sticky; top: 76px; }
@media (max-width: 1100px) {
  .cols-main-side, .cols-side-main, .cols-side-main--narrow { grid-template-columns: 1fr; }
  .sidecol { position: static; }
}
@media (max-width: 900px) {
  .cols-fields { grid-template-columns: 1fr; }
  .cols-bilingual { grid-template-columns: 1fr !important; }
  .cols-bilingual > div + div { border-left: none !important; padding-left: 0 !important; border-top: 1px solid var(--line); padding-top: 14px; }
  .pilot-checklist__grid { grid-template-columns: 1fr; }
  .pilot-step { border-right: none; }
  .pilot-step:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .pilot-step:last-child { border-bottom: none; }
}

/* Scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
