:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #6b7385;
    --accent: #1f7a5c;
    --accent-hover: #186148;
    --error: #b3261e;
    --border: #e2e5eb;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--accent); }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header nav { display: flex; gap: 16px; align-items: center; }
.logo { font-weight: 700; font-size: 20px; text-decoration: none; color: var(--text); }

.container { max-width: 960px; margin: 40px auto; padding: 0 24px; }
.container.narrow { max-width: 420px; }

.hero h1 { font-size: 36px; margin-bottom: 12px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 640px; }

.button {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--accent-hover); }
.button.danger { background: #c62828; }
.button.danger:hover { background: #a31f1f; }
.button:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

button.link {
    background: none; border: none; padding: 0;
    color: var(--accent); font: inherit; cursor: pointer;
}

form.inline { display: inline; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.form input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
}

.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--error); font-size: 14px; margin: 0; }
.notice { color: var(--accent); }

.cards { list-style: none; padding: 0; display: grid; gap: 12px; }
.card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.button.secondary:hover { background: var(--bg); }

.steps { padding: 0; list-style: none; counter-reset: step; display: grid; gap: 12px; }
.step {
    counter-increment: step;
    position: relative;
    padding: 18px 20px 18px 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.step::before {
    content: counter(step);
    position: absolute; left: 20px; top: 18px;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.step-title { font-weight: 600; margin-bottom: 4px; }
.step p { margin: 0 0 12px; }
.bookmarklet { cursor: grab; }
kbd {
    padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px;
    border-radius: 4px; font: 12px ui-monospace, monospace; background: var(--bg);
}

.key-note { margin-top: 28px; }

/* ---------- Мед-карта ---------- */
:root { --ok: #1f7a5c; --ok-bg: #e6f4ee; --bad: #b3261e; --bad-bg: #fbe9e7; --tag-bg: #eef0f4; }

h2 { font-size: 20px; margin: 32px 0 12px; }

.empty {
    padding: 28px 24px; text-align: center;
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty p { margin: 6px 0 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 20px; }
.tab {
    padding: 10px 16px; color: var(--muted); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.count {
    display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px;
    background: var(--tag-bg); color: var(--muted); border-radius: 11px; font-size: 12px; text-align: center;
}
.tab.active .count { background: var(--ok-bg); color: var(--accent); }

.rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.row {
    display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center;
    padding: 14px 18px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: inherit; text-decoration: none;
}
.row:hover { border-color: var(--accent); }
.row-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main strong { overflow-wrap: anywhere; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
    background: var(--tag-bg); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-head h1 { margin: 8px 0; }

.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin: 16px 0 8px; }
.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 2px 0 0; overflow-wrap: anywhere; }

.conclusion {
    overflow-wrap: anywhere; padding: 16px 18px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.conclusion > :first-child { margin-top: 0; }
.conclusion > :last-child { margin-bottom: 0; }
.conclusion p { margin: 0 0 10px; }
.conclusion table { border-collapse: collapse; }
.conclusion th, .conclusion td { border: 1px solid var(--border); padding: 4px 8px; }

.documents { display: grid; gap: 20px; margin-top: 24px; }
.document-head { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; }
.document-links { display: flex; gap: 16px; }
.pdf { width: 100%; height: 80vh; min-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* Меню «Импорт» в шапке */

@media (max-width: 640px) {
    .header { padding: 12px 16px; }
    .row { grid-template-columns: 1fr; gap: 6px; }
    .row-tags { justify-content: flex-start; }
}

/* Панель фильтров мед-карты */
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin: 8px 0 4px; }
.filter-label { color: var(--muted); font-size: 14px; }
.filters-reset { font-size: 14px; }

/* Выпадающий список с мультивыбором */
.dropdown { position: relative; }
.dropdown summary { list-style: none; cursor: pointer; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-trigger {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px;
}
.dropdown-trigger::after { content: "▾"; color: var(--muted); }
.dropdown-trigger:hover, .dropdown[open] .dropdown-trigger { border-color: var(--accent); }
.dropdown-value { font-weight: 500; }
.dropdown-panel {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 10; min-width: 260px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12); display: flex; flex-direction: column;
}
.option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.option:hover { background: var(--bg); }
.option input { accent-color: var(--accent); margin: 0; width: 16px; height: 16px; }
.dropdown-actions { margin-top: 6px; padding: 8px 4px 2px; border-top: 1px solid var(--border); }
.dropdown-actions .button { width: 100%; padding: 8px 14px; font-size: 14px; }

.clinic-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; }
.clinic-list li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 6px 10px; margin: 0 -10px; border-radius: var(--radius); transition: background .15s;
}
.clinic-list li:hover { background: rgba(0, 0, 0, .06); }
.clinic-name { display: flex; align-items: center; gap: 12px; }
.clinic-logo { height: 56px; width: auto; border-radius: 6px; flex: none; }
