:root {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e9ef;
  --border-strong: #cbd8e2;
  --text: #12212e;
  --text-soft: #5b7083;
  --text-mute: #8a9baa;
  --brand: #0d7f8f;
  --brand-strong: #0a6472;
  --brand-soft: #e4f2f4;
  --accent: #1f7a5c;
  --danger: #b4392f;
  --danger-soft: #fbeae8;
  --warn: #a86a10;
  --warn-soft: #fdf3e2;
  --info: #2563a8;
  --info-soft: #e9f1fa;
  --ok: #1f7a5c;
  --ok-soft: #e6f3ed;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 33, 46, .05), 0 8px 24px -12px rgba(18, 33, 46, .18);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
small { font-size: .82rem; }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: #0c2530;
  color: #c7dbe3;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 20px;
  color: #fff; font-weight: 700; font-size: 1.16rem; letter-spacing: -.02em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #14b8a6, #0d7f8f);
  display: grid; place-items: center;
  font-size: 1rem;
}
.brand em { font-style: normal; color: #6fe3d3; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: #a9c2cc; font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(20, 184, 166, .16); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav .sep { margin: 14px 0 6px; padding: 0 11px; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: #5a7885; }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.09); padding-top: 12px; margin-top: 8px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(20,184,166,.22); color: #7fe9da;
  display: grid; place-items: center; font-weight: 650; font-size: .85rem; flex: 0 0 auto;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who b { display: block; color: #eaf4f7; font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who span { font-size: .74rem; color: #7d9aa6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.18rem; margin: 0; }
.topbar .sub { font-size: .82rem; color: var(--text-soft); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.content { padding: 26px 32px 60px; width: 100%; max-width: 1240px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* ---------------------------------------------------------------- stats */
.stat { padding: 18px 20px; }
.stat .label { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-mute); }
.stat .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .hint { font-size: .8rem; color: var(--text-soft); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-family: inherit; font-size: .89rem; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ai { background: linear-gradient(135deg, #0d7f8f, #1f7a5c); border-color: transparent; color: #fff; }
.btn-ai:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: #eccbc7; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms */
label.field { display: block; margin-bottom: 14px; }
label.field > span, .field-label {
  display: block; font-size: .8rem; font-weight: 600; color: var(--text-soft);
  margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: .92rem; color: var(--text);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(13,127,143,.13);
}
input::placeholder, textarea::placeholder { color: #a9b8c4; }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b7083' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.field-row-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }

.check { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; font-size: .9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--brand); flex: 0 0 auto; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 18px; }
fieldset > legend { padding: 0 8px; font-size: .84rem; font-weight: 700; color: var(--brand-strong); letter-spacing: .01em; }
.hint { font-size: .78rem; color: var(--text-mute); margin-top: 4px; }

/* ---------------------------------------------------------------- icons */
.ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; }
.ico svg, .fi svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.feature .fi svg { width: 19px; height: 19px; color: #4fd1c5; }
.brand .logo svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th {
  text-align: left; padding: 10px 16px; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfdfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .74rem; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #cbe6db; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2e0be; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #f0d2ce; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #cfe0f2; }
.badge-brand { background: var(--brand-soft); color: var(--brand-strong); border-color: #c3e3e7; }

/* ---------------------------------------------------------------- flags */
.flag {
  display: flex; gap: 11px; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: .875rem; margin-bottom: 8px;
}
.flag:last-child { margin-bottom: 0; }
.flag .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; background: var(--text-mute); }
.flag b { font-weight: 650; }
.flag .area { font-weight: 700; }
.flag-critical { background: var(--danger-soft); border-color: #f0d2ce; }
.flag-critical .dot { background: var(--danger); }
.flag-critical .area { color: var(--danger); }
.flag-warning { background: var(--warn-soft); border-color: #f2e0be; }
.flag-warning .dot { background: var(--warn); }
.flag-warning .area { color: var(--warn); }
.flag-info { background: var(--info-soft); border-color: #cfe0f2; }
.flag-info .dot { background: var(--info); }
.flag-info .area { color: var(--info); }

/* ---------------------------------------------------------------- misc */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .89rem; margin-bottom: 18px; border: 1px solid; }
.alert-error { background: var(--danger-soft); border-color: #f0d2ce; color: #8c2b23; }
.alert-ok { background: var(--ok-soft); border-color: #cbe6db; color: #14563f; }
.alert-info { background: var(--info-soft); border-color: #cfe0f2; color: #1b4a7d; }

.muted { color: var(--text-soft); }
.mono { font-family: var(--mono); font-size: .85em; }
.center { text-align: center; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

.kv { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 7px 16px; font-size: .9rem; }
.kv dt { color: var(--text-soft); font-weight: 500; }
.kv dd { margin: 0; font-weight: 550; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .8rem; color: var(--text-soft);
}

.proposal-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 15px 17px; background: var(--surface); margin-bottom: 12px;
  border-left: 4px solid var(--brand);
}
.proposal-item:last-child { margin-bottom: 0; }
.proposal-item .drug { font-size: 1.02rem; font-weight: 680; letter-spacing: -.01em; }
.proposal-item .dose { font-weight: 600; color: var(--brand-strong); }
.proposal-item .why { font-size: .88rem; color: var(--text-soft); margin-top: 7px; }
.proposal-item .cls {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-mute); font-weight: 700;
  max-width: 42%; text-align: right; line-height: 1.35;
}

.list-clean { margin: 0; padding-left: 19px; font-size: .9rem; }
.list-clean li { margin-bottom: 6px; }
.list-clean li:last-child { margin-bottom: 0; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-soft); }
.empty .big { font-size: 2rem; margin-bottom: 8px; opacity: .45; }

.split-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.loader-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 37, 48, .62); backdrop-filter: blur(3px);
  display: none; place-items: center; padding: 20px;
}
.loader-overlay.on { display: grid; }
.loader-box {
  background: var(--surface); border-radius: var(--radius); padding: 28px 32px;
  text-align: center; max-width: 400px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.4);
}
.spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-box h3 { margin-bottom: 6px; }
.loader-box p { color: var(--text-soft); font-size: .88rem; margin: 0; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 16px; }

/* ---------------------------------------------------------------- landing */
.landing { background: #081a24; color: #e8f1f4; }
.landing-wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 22px 0; }
.landing .brand { padding: 0; color: #fff; }
.landing .brand .logo { background: linear-gradient(135deg, #14b8a6, #0d7f8f); }
.hero { padding: 60px 0 76px; display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; }
.hero h1 { font-size: 2.9rem; line-height: 1.1; letter-spacing: -.035em; margin-bottom: 18px; color: #fff; }
.hero h1 em { font-style: normal; background: linear-gradient(100deg, #2fd4bd, #5aa9e6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p.lead { font-size: 1.1rem; color: #a7c0cb; max-width: 560px; margin-bottom: 28px; }
.hero-btns { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btn { padding: 12px 22px; font-size: .95rem; }
.hero .btn-ghost { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.2); color: #dceaf0; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.12); }
.hero-panel { background: linear-gradient(160deg, #103440, #0a2430); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; padding: 22px; box-shadow: 0 30px 70px -30px rgba(0,0,0,.7); }
.mock-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: .85rem; color: #b7ced8; }
.mock-line:last-child { border-bottom: none; }
.mock-pill { font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; letter-spacing: .04em; }
.pill-a { background: rgba(20,184,166,.2); color: #5fe0cb; }
.pill-b { background: rgba(90,169,230,.18); color: #8fc4ee; }
.pill-c { background: rgba(245,158,11,.18); color: #f0b85a; }
.panel-title { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: #6f909d; margin-bottom: 10px; }

.features { padding: 0 0 80px; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.09); border-radius: 14px; padding: 22px; }
.feature .fi { width: 38px; height: 38px; border-radius: 10px; background: rgba(20,184,166,.15); display: grid; place-items: center; font-size: 1.1rem; margin-bottom: 14px; }
.feature h3 { color: #fff; font-size: 1rem; margin-bottom: 6px; }
.feature p { color: #9db6c1; font-size: .88rem; margin: 0; }

.landing-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 26px 0 40px; color: #6f909d; font-size: .82rem; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.disclaimer { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.22); border-radius: 10px; padding: 12px 16px; font-size: .8rem; color: #d9b678; margin-bottom: 40px; }

/* ---------------------------------------------------------------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; background: radial-gradient(1200px 600px at 50% -10%, #0f3644, #081a24); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 16px; padding: 32px; box-shadow: 0 30px 70px -25px rgba(0,0,0,.6); }
.auth-card.wide { max-width: 520px; }
.auth-card .brand { color: var(--text); justify-content: center; padding: 0 0 6px; }
.auth-card h1 { font-size: 1.28rem; text-align: center; margin-bottom: 4px; }
.auth-card .lead { text-align: center; color: var(--text-soft); font-size: .88rem; margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: .86rem; color: var(--text-soft); }
.auth-note { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: .76rem; color: var(--text-mute); }

/* ---------------------------------------------------------------- print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; gap: 32px; }
  .features-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { left: 0; }
  .menu-btn { display: inline-flex !important; }
  .content { padding: 20px 18px 50px; }
  .topbar { padding: 14px 18px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-row-3, .field-row-4 { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; font-size: .8rem; }
  .features-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.1rem; }
}
@media (max-width: 560px) {
  .field-row, .field-row-3, .field-row-4 { grid-template-columns: 1fr; }
  .landing-wrap { padding: 0 18px; }
  .hero { padding: 36px 0 52px; }
  .auth-card { padding: 24px; }
  .topbar .sub { display: none; }
}
.menu-btn { display: none; }
