/* ============================================================
   Помощник восстановления — Shared Design System
   ============================================================ */

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

:root {
  --bg:         #F3F5F8;
  --surface:    #FFFFFF;
  --surface-2:  #EDF0F5;
  --border:     #DDE2EC;
  --border-2:   #C8CFDC;

  --text-1:     #111827;
  --text-2:     #4B5563;
  --text-3:     #9CA3AF;

  --nav-bg:     #0F1B2D;
  --nav-text:   #8FA3BF;
  --nav-hover:  #1E3050;
  --nav-active: #FFFFFF;
  --nav-accent: #3B82F6;

  --blue:       #2563EB;
  --blue-d:     #1D4ED8;
  --blue-l:     #EFF6FF;
  --blue-m:     #BFDBFE;

  --green:      #15803D;
  --green-l:    #F0FDF4;
  --green-m:    #BBF7D0;

  --amber:      #B45309;
  --amber-l:    #FFFBEB;
  --amber-m:    #FDE68A;

  --red:        #B91C1C;
  --red-l:      #FEF2F2;
  --red-m:      #FECACA;

  --teal:       #0F766E;
  --teal-l:     #F0FDFA;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06), 0 1px 1px rgba(0,0,0,0.04);
  --shadow:     0 1px 4px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg:  0 4px 16px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);

  --font-sans:  'IBM Plex Sans', system-ui, sans-serif;
  --font-serif: 'IBM Plex Serif', Georgia, serif;

  --sidebar-w: 224px;
  --header-h:  64px;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--nav-bg);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* Thin custom scrollbars — no arrows, minimal */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-button { display: none; }
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }

/* Focus-visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Screen-reader only (visually hidden but accessible) */
.sr-only {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
}

/* ── Sidebar Nav ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--nav-accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon .icon { width: 16px; height: 16px; color: #fff; }

.sidebar-logo-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--nav-active);
  line-height: 1.3;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--nav-text);
  font-weight: 400;
  margin-top: 1px;
  letter-spacing: 0.02em;
}

.sidebar-section {
  padding: 20px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--nav-text);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--nav-text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
  white-space: nowrap;
}

.nav-item:hover { background: var(--nav-hover); color: #CBD5E1; }

.nav-item.active {
  background: rgba(59,130,246,0.18);
  color: var(--nav-active);
}

.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .icon { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* ── Patient Header Bar ──────────────────────────────────── */
.patient-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.patient-header-name {
  display: flex;
  flex-direction: column;
}

.patient-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.patient-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

.patient-header-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

.header-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-3);
  text-transform: uppercase;
}

.header-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

/* ── Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-done    { background: var(--green-l);  color: var(--green); }
.badge-done .badge-dot { background: var(--green); }
.badge-missed  { background: var(--red-l);    color: var(--red); }
.badge-missed .badge-dot { background: var(--red); }
.badge-warn    { background: var(--amber-l);  color: var(--amber); }
.badge-warn .badge-dot { background: var(--amber); }
.badge-upcoming{ background: var(--blue-l);   color: var(--blue); }
.badge-upcoming .badge-dot { background: var(--blue); }
.badge-later   { background: var(--surface-2); color: var(--text-2); }
.badge-later .badge-dot { background: var(--text-3); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}


.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
}

.card-body { padding: 16px 20px; }

/* ── KPI tiles ───────────────────────────────────────────── */

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ── Task rows ───────────────────────────────────────────── */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.task-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  width: 40px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.task-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-1);
  flex: 1;
  min-width: 0;
}

.task-name-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
}

.task-owner {
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: background 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-d); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--blue);
  padding: 6px 10px;
}

/* pressed state for JS feedback */
.btn.pressed,
.btn-primary.pressed,
.btn-secondary.pressed {
  transform: translateY(1px);
}

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Alert cards ─────────────────────────────────────────── */
.alert-item {
  border-radius: var(--radius);
  border: 1px solid;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-warn  { background: var(--amber-l); border-color: var(--amber-m); }
.alert-crit  { background: var(--red-l);   border-color: var(--red-m); }

.alert-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.alert-title  { font-size: 13px; font-weight: 600; color: var(--text-1); }
.alert-desc   { font-size: 12px; color: var(--text-2); }
.alert-meta   { font-size: 11px; color: var(--text-3); }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Section time headers ────────────────────────────────── */
.time-block { margin-bottom: 20px; }
.time-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 0 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ── App shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-area {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  overflow-y: scroll;
}

.right-panel {
  width: 340px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 18px;
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.right-panel-section {}
.right-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── App Layout Shell ────────────────────────────────────── */
.app-shell-layout {
  display: flex;
  min-height: 100vh;
}
.app-shell-layout.pinned {
  height: 100vh;
  overflow: hidden;
}
.app-shell-layout.pinned .main-area {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-shell-layout.pinned .content-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.app-shell-layout.pinned .main-content {
  height: 100%;
  overflow-y: scroll;
}
.app-shell-layout.pinned .right-panel {
  height: 100%;
  overflow-y: scroll;
}

/* ── Utilities ───────────────────────────────────────────── */
.icon { fill: currentColor; }
.flex   { display: flex; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }


/* tag */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* note entry */
.note-entry {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.note-entry:last-child { border-bottom: none; }
.note-author { font-size: 12px; font-weight: 600; color: var(--text-1); margin-bottom: 3px; }
.note-text { font-size: 12.5px; color: var(--text-2); font-style: italic; }
.note-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }

/* deviation status steps */
.workflow-steps {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.ws-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.ws-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.ws-step.done::after { background: var(--blue); }
.ws-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  font-size: 10px;
  color: var(--text-3);
  flex-shrink: 0;
}
.ws-step.done .ws-dot { background: var(--blue); border-color: var(--blue); color: #fff; }
.ws-step.active .ws-dot { background: var(--surface); border-color: var(--blue); color: var(--blue); box-shadow: 0 0 0 3px var(--blue-l); }
.ws-label { font-size: 10px; color: var(--text-3); margin-top: 5px; text-align: center; }
.ws-step.done .ws-label { color: var(--blue); font-weight: 600; }
.ws-step.active .ws-label { color: var(--text-1); font-weight: 600; }

/* ============================================================
   Cross-screen shared components
   ============================================================ */

/* Sidebar user card */
.sidebar-user-card {
  padding: 10px; border-radius: 6px;
  background: rgba(255,255,255,0.05);
}
.sidebar-user-name { font-size: 11px; font-weight: 600; color: #CBD5E1; }
.sidebar-user-role { font-size: 10px; color: #64748B; margin-top: 2px; }

/* Nav badges */
.nav-badge {
  margin-left: auto;
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 100px;
}
.nav-badge--amber {
  background: var(--amber);
}

/* Header actions */
/* Section layout */
.section-mb { margin-bottom: 24px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* Tags */
.tag-amber { background: var(--amber-l); border-color: var(--amber-m); color: var(--amber); }
.tag-sm { font-size: 10px; }

/* Notes */
.note-list { list-style: none; padding: 0; margin: 0; }
.note-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.note-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

/* Right panel */
.rp-divider { height: 1px; background: var(--border); }

/* Card header note */
.card-header-note { font-size: 12px; color: var(--text-3); }

/* Team */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-member { display: flex; align-items: center; gap: 8px; }
.team-name { font-size: 12px; font-weight: 600; color: var(--text-1); }

/* Visit card */
.visit-card {
  background: var(--blue-l); border: 1px solid var(--blue-m);
  border-radius: var(--radius); padding: 12px 14px;
}
.visit-title { font-size: 13px; font-weight: 700; color: var(--text-1); margin-bottom: 3px; }
.visit-time  { font-size: 12px; color: var(--text-2); }

/* Risk summary */
.risk-metrics { display: flex; flex-direction: column; gap: 6px; }
.risk-row { display: flex; justify-content: space-between; align-items: center; }
.risk-label { font-size: 12px; color: var(--text-2); }
.risk-value { font-size: 13px; font-weight: 700; color: var(--text-1); }
.risk-value.amber { color: var(--amber); }
.risk-value.blue  { color: var(--blue); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-3);
}
.empty-state-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.empty-state-icon .icon { color: var(--text-3); }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.empty-state-desc  { font-size: 13px; color: var(--text-3); line-height: 1.4; }

/* Right panel action buttons */
.rp-action {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  color: var(--text-1);
  width: 100%;
  font-family: var(--font-sans);
  transition: background 0.1s, box-shadow 0.1s;
  text-align: left;
  margin-bottom: 6px;
}
.rp-action:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }
.rp-action-icon {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rp-action-icon.blue    { background: var(--blue-l); }
.rp-action-icon.amber   { background: var(--amber-l); }
.rp-action-icon.green   { background: var(--green-l); }
.rp-action-icon.teal    { background: var(--teal-l); }
.rp-action-icon.surface { background: var(--surface-2); }
.rp-action-icon.blue    .icon { color: var(--blue); }
.rp-action-icon.amber   .icon { color: var(--amber); }
.rp-action-icon.green   .icon { color: var(--green); }
.rp-action-icon.teal    .icon { color: var(--teal); }
.rp-action-icon.surface .icon { color: var(--text-2); }

/* ============================================================
   Responsive breakpoints
   ============================================================ */


/* Portfolio navigation */
.portfolio-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--font-sans);
}
.portfolio-nav a {
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}
.portfolio-nav a:hover {
  color: var(--text-1);
}