/* Implantcare — тёмная чёрно-белая тема. Шрифт IBM Plex (лицензия OFL, файлы в fonts/). */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-mono-cyrillic-400-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-mono-cyrillic-500-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+FEFF, U+FFFD; }

:root {
  --bg: #0a0a0a;
  --panel: #101010;
  --raised: #161616;
  --hover: #1c1c1c;
  --line: #242424;
  --line-strong: #383838;
  --text: #f1f1f1;
  --muted: #9b9b9b;
  --faint: #666;
  --invert-bg: #f1f1f1;
  --invert-text: #0a0a0a;
  --danger: #ff5d5d;
  --danger-bg: #2a1212;
  --ok-bg: #141f16;
  --ok-line: #2c4a31;
  --radius: 8px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "tnum";
}
a { color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 13px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.mono { font-family: var(--mono); font-size: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ── Каркас: меню слева, на телефоне — сверху ───────────────────────── */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--panel); padding: 22px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border: 1.5px solid var(--text); border-radius: 6px;
  display: grid; place-items: center; font: 600 13px/1 var(--mono);
}
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 var(--text); }
.nav svg { width: 17px; height: 17px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.sidebar-foot .who { font-weight: 500; margin-bottom: 8px; overflow-wrap: anywhere; }
.sidebar-foot form { margin: 0; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }
.version { margin-top: 10px; color: var(--faint); font: 12px var(--mono); }

.main { padding: 36px 40px 64px; max-width: 1180px; width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; }
  .nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; gap: 4px; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--text); }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 12px; }
  .sidebar-foot .who, .version { display: none; }
  .main { padding: 22px 16px 48px; }
  h1 { font-size: 22px; }
}

/* ── Заголовок страницы ─────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.crumb { display: inline-block; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 10px; }
.crumb:hover { color: var(--text); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Кнопки и поля ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); font: 500 14px var(--sans); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.btn-primary:hover { background: #fff; }
.btn-danger { border-color: #5a2323; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn svg { width: 16px; height: 16px; }

label, .label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.req::after { content: " *"; color: var(--faint); }
input[type="text"], input[type="search"], input[type="tel"], input[type="date"], input[type="password"], select {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font: 400 15px var(--sans);
}
input:focus, select:focus { outline: none; border-color: var(--text); }
input[aria-invalid="true"] { border-color: var(--danger); }
input::placeholder { color: var(--faint); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint { color: var(--faint); font-size: 13px; margin-top: 6px; }

.radio-row { display: flex; gap: 8px; }
.radio-row label {
  margin: 0; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 42px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--text); cursor: pointer; font-size: 14px;
}
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.radio-row input:checked + span { font-weight: 600; }
.radio-row label:has(input:checked) { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.radio-row label:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }

.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 14px; font-weight: 400; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: #f1f1f1; flex: none; }

/* ── Поиск и фильтры ────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--faint); }
.search input { padding-left: 38px; }
.chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
}
.chip:hover { color: var(--text); }
.chip[aria-current="true"] { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.chip .count { font-family: var(--mono); font-size: 12px; }

/* ── Таблица пациентов (на телефоне — карточки) ─────────────────────── */
.table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--panel); }
.table a.row-link { text-decoration: none; font-weight: 500; }
.table a.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.name-cell { display: flex; align-items: center; gap: 10px; }

@media (max-width: 860px) {
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table { border: 0; }
  .table tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 12px 14px; }
  .table td { border: 0; padding: 2px 0; }
  .table td[data-label]::before { content: attr(data-label); display: inline-block; width: 92px; color: var(--faint); font: 400 13px var(--sans); }
  .table td.name-td { padding-bottom: 6px; }
}

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  background: var(--invert-bg); color: var(--invert-text); font: 600 11px var(--sans); letter-spacing: 0.04em; text-transform: uppercase;
}
.badge-outline { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); }

.empty { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 40px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 6px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 14px; }

/* ── Карточка пациента ──────────────────────────────────────────────── */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.card + .card { margin-top: 16px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.details div { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.details div:nth-child(odd) { border-right: 1px solid var(--line); }
.details div:nth-last-child(-n + 2) { border-bottom: 0; }
.details dt { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.details dd { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .details { grid-template-columns: minmax(0, 1fr); }
  .details div:nth-child(odd) { border-right: 0; }
  .details div:nth-last-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .details div:last-child { border-bottom: 0; }
}

/* ── Форма пациента ─────────────────────────────────────────────────── */
.form-card { padding: 22px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: minmax(0, 1fr); } .form-card { padding: 16px; } }
.form-actions { display: flex; gap: 8px; margin-top: 24px; flex-wrap: wrap; }

/* ── Сообщения ──────────────────────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid var(--ok-line); background: var(--ok-bg); font-size: 14px; }
.flash-error { border-color: #5a2323; background: var(--danger-bg); }
.alert { padding: 14px 16px; border-radius: var(--radius); border: 1px solid #5a2323; background: var(--danger-bg); margin-bottom: 18px; }

/* ── Вход ───────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 380px; }
.login .brand { padding: 0 0 28px; justify-content: center; }
.login .brand-name { font-size: 20px; }
.login .card { padding: 26px 24px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.login .btn { width: 100%; margin-top: 4px; }
.login-foot { text-align: center; color: var(--faint); font-size: 12px; margin-top: 18px; }

/* ── Журнал ─────────────────────────────────────────────────────────── */
.log td { font-size: 14px; }
.log tbody tr { cursor: default; }

/* ── Модуль «Имплантаты» ────────────────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip svg { width: 15px; height: 15px; }
.warn { color: var(--danger); }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--sans); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--text); }
.computed {
  min-height: 42px; display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius);
  border: 1px dashed var(--line-strong); font-size: 15px;
}
.status-filter { flex-wrap: wrap; margin: -4px 0 16px; }

.tooth {
  display: inline-grid; place-items: center; min-width: 30px; height: 24px; padding: 0 6px; border-radius: 5px;
  border: 1px solid var(--line-strong); font: 500 13px var(--mono); flex: none;
}
.status {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
}
.status-integrated { color: var(--text); border-color: #6b6b6b; }
.status-loaded { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.status-periimplantitis, .status-rejected { color: var(--danger); border-color: #5a2323; background: var(--danger-bg); }

.board-hint { margin: -6px 0 14px; }
.board {
  display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 10px; align-items: start;
  overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity;
}
.board-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); scroll-snap-align: start; min-width: 0; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.board-col-head h2 { color: var(--text); }
.board-col-head .count { font: 500 13px var(--mono); color: var(--muted); }
.board-col-problem .board-col-head h2 { color: var(--danger); }
.board-col.drop-target { border-color: var(--text); background: var(--raised); }
.board-drop { display: flex; flex-direction: column; gap: 8px; padding: 10px; min-height: 120px; }
.board-empty { display: none; color: var(--faint); font-size: 13px; text-align: center; padding: 28px 0; }
.board-drop:not(:has(.kcard)) .board-empty { display: block; }
.board-more { color: var(--muted); font-size: 13px; text-align: center; padding: 6px; }

.kcard { background: var(--raised); border: 1px solid var(--line-strong); border-radius: 7px; cursor: grab; }
.kcard:hover { border-color: #555; }
.kcard.dragging { opacity: .45; }
.kcard-problem { border-color: #5a2323; }
.kcard-link { display: block; padding: 10px 12px; text-decoration: none; }
.kcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.kcard-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.kcard-implant { font-size: 13px; color: var(--text); }
.kcard-meta, .kcard-due { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kcard-due .warn { font-weight: 500; }

@media (max-width: 860px) {
  .board { grid-template-columns: repeat(5, 78vw); }
  .board-hint { display: none; }
}

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  padding: 10px 16px; border-radius: var(--radius); background: var(--invert-bg); color: var(--invert-text);
  font-size: 14px; font-weight: 500; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast-error { background: var(--danger); color: #fff; }

.status-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-form select { width: auto; min-height: 34px; font-size: 14px; }
.notes { padding: 14px 18px; border-top: 1px solid var(--line); }
.notes-label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.notes p { margin: 4px 0 0; white-space: pre-wrap; }

.implant-rows { list-style: none; margin: 0; padding: 0; }
.implant-rows li + li { border-top: 1px solid var(--line); }
.implant-rows a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; text-decoration: none; }
.implant-rows a:hover { background: var(--hover); }
.implant-rows-main { flex: 1; min-width: 0; font-size: 14px; }
.panel-empty { margin: 0; padding: 14px 18px; color: var(--muted); font-size: 14px; }
