/* Реестр ЛМК — формальный интерфейс медсферы */
:root {
    --bg: oklch(0.975 0.012 245);
    --surface: oklch(0.955 0.018 245);
    --panel: oklch(1 0 0);
    --ink: oklch(0.25 0.02 250);
    --muted: oklch(0.40 0.028 250);
    --border: oklch(0.84 0.025 245);
    --border-strong: oklch(0.70 0.045 245);

    --primary: oklch(0.52 0.16 250);
    --primary-hover: oklch(0.44 0.16 250);
    --primary-soft: oklch(0.93 0.045 245);
    --primary-ink: oklch(1 0 0);

    --header: oklch(0.34 0.10 250);
    --header-fg: oklch(0.98 0.005 250);
    --header-muted: oklch(0.78 0.02 250);
    --header-border: oklch(0.35 0.04 250);

    --green: oklch(0.42 0.10 145);
    --green-bg: oklch(0.96 0.02 145);
    --yellow: oklch(0.50 0.10 85);
    --yellow-bg: oklch(0.97 0.03 95);
    --red: oklch(0.48 0.14 25);
    --red-bg: oklch(0.96 0.02 25);
    --gray: oklch(0.48 0.01 250);
    --gray-bg: oklch(0.96 0.005 250);

    --radius: 6px;
    --radius-sm: 4px;
    --shadow: 0 1px 2px oklch(0.25 0.02 250 / 0.06);
    --shadow-md: 0 4px 12px oklch(0.25 0.02 250 / 0.08);
    --focus: 0 0 0 3px oklch(0.45 0.10 250 / 0.25);
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --z-sticky: 10;
    --z-header: 20;
}

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

html { color-scheme: light; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a:focus-visible,
.table-wrap:focus-visible,
.vaccination-table-wrap:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link:focus,
.skip-link:focus-visible {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    width: auto;
    height: auto;
    margin: 0;
    padding: 8px 14px;
    overflow: visible;
    clip: auto;
    background: var(--primary);
    color: var(--primary-ink);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

/* Header */
.site-header {
    background: var(--header);
    color: var(--header-fg);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    border-bottom: 1px solid var(--header-border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--primary-ink);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.main-nav a {
    color: var(--header-muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 160ms var(--ease), background 160ms var(--ease);
}

.main-nav a:hover {
    color: var(--header-fg);
    background: oklch(1 0 0 / 0.08);
}

.main-nav a.active {
    color: var(--header-fg);
    background: oklch(1 0 0 / 0.14);
}

.main-nav a:focus-visible,
.logo:focus-visible {
    outline: 2px solid oklch(0.78 0.08 250);
    outline-offset: 2px;
}

main.container {
    flex: 1;
    padding: 28px 0 56px;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 14px 0;
    font-size: 0.85rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.site-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.site-footer a:hover { text-decoration: underline; }

.messages { margin-bottom: 14px; }

.alert {
    background: var(--primary-soft);
    border: 1px solid oklch(0.82 0.04 250);
    color: oklch(0.35 0.06 250);
    padding: 12px 14px;
    border-radius: var(--radius);
}

.alert-error,
.alert.error {
    background: var(--red-bg);
    border-color: oklch(0.82 0.06 25);
    color: var(--red);
}

/* Typography */
h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-wrap: balance;
    line-height: 1.25;
}

h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

h3 {
    margin: 16px 0 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.subtitle, .muted, .meta { color: var(--muted); }
.small { font-size: 0.85rem; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Panels */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin: 16px 0;
    box-shadow: var(--shadow);
}

.panel-flush { padding-top: 10px; }

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-panel .registry-table th:first-child,
.table-panel .registry-table td:first-child { padding-left: 18px; }

.table-panel .registry-table th:last-child,
.table-panel .registry-table td:last-child { padding-right: 18px; }

.panel-compact {
    padding: 12px 16px;
    margin: 12px 0;
}

.panel.success {
    border-color: oklch(0.78 0.06 145);
    background: var(--green-bg);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 12px;
}

.panel-header a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.panel-header a:hover { text-decoration: underline; }

.text-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.text-link:hover { text-decoration: underline; }

.panel-desc {
    color: var(--muted);
    margin: 4px 0 0;
    font-size: 0.9rem;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr minmax(220px, 260px);
    gap: 16px;
    align-items: start;
}

/* Stats — one strip, not five identical cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    margin-bottom: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.stat-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 16px 18px;
    box-shadow: none;
    border-right: 1px solid var(--border);
    position: relative;
}

.stat-card:last-child { border-right: none; }

.stat-link {
    text-decoration: none;
    color: inherit;
    transition: background 160ms var(--ease);
}

.stat-link:hover { background: var(--surface); }

.stat-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    z-index: 1;
}

.stat-card.green { background: var(--green-bg); }
.stat-card.yellow { background: var(--yellow-bg); }
.stat-card.red { background: var(--red-bg); }
.stat-card.muted { background: var(--gray-bg); }

.stat-card.green .stat-value { color: var(--green); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.muted .stat-value { color: var(--gray); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 6px;
    font-weight: 500;
}

.stat-share {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.import-stats {
    margin: 16px 0;
}

.import-stats .stat-card {
    background: var(--panel);
}

.import-stats .stat-card.green { background: var(--green-bg); }
.import-stats .stat-card.yellow { background: var(--yellow-bg); }
.import-stats .stat-card.muted { background: var(--gray-bg); }

/* Filter bar */
.filter-bar {
    display: grid;
    gap: 12px;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.active-filters-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.filter-tag {
    display: inline-block;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.search-field { flex: 1; min-width: 220px; }

.block { display: block; }

/* Quick filters */
.quick-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: border-color 160ms var(--ease), background 160ms var(--ease), color 160ms var(--ease);
}

.chip:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.chip:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

.chip-active {
    background: var(--header);
    color: var(--header-fg);
    border-color: var(--header);
}

.chip-red.chip-active { background: var(--red); border-color: var(--red); color: #fff; }
.chip-yellow.chip-active { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.chip-green.chip-active { background: var(--green); border-color: var(--green); color: #fff; }

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-search { min-width: 220px; flex: 1; }

.filters input,
.filters select,
.employee-form input,
.employee-form select,
.employee-form textarea,
.import-form input[type="text"] {
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--panel);
    color: var(--ink);
    transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}

.filters input::placeholder,
.employee-form input::placeholder,
.employee-form textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

.filters input:focus,
.filters select:focus,
.employee-form input:focus,
.employee-form select:focus,
.employee-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus);
}

.employee-form input,
.employee-form select,
.employee-form textarea {
    width: 100%;
}

.employee-form textarea {
    min-height: 88px;
    resize: vertical;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

.registry-table thead th {
    position: static;
    background: var(--surface);
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.col-date { min-width: 110px; }

.date-cell { white-space: nowrap; }

.date-value {
    display: inline-block;
    min-width: 72px;
    margin-right: 6px;
    font-variant-numeric: tabular-nums;
}

.employee-link {
    color: var(--ink);
    font-weight: 600;
}

tr.row-clickable {
    cursor: pointer;
    transition: background 120ms var(--ease);
}

tr.row-clickable:hover { filter: brightness(0.985); }

tr.row-clickable:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

tr.row-red { background: var(--red-bg); }
tr.row-yellow { background: var(--yellow-bg); }
tr.row-no_data { background: var(--gray-bg); }

/* Status indicators */
.status-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    vertical-align: middle;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.12);
}

.status-dot.green { background: oklch(0.62 0.16 145); color: white; }
.status-dot.yellow { background: oklch(0.78 0.14 90); color: var(--ink); }
.status-dot.red { background: oklch(0.60 0.18 25); color: white; }
.status-dot.no_data { background: oklch(0.72 0.01 250); color: var(--ink); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge.green { background: var(--green-bg); color: var(--green); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.no_data { background: var(--gray-bg); color: var(--gray); }

/* Legend */
.legend {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.legend-summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    font-size: 0.9rem;
}

.legend-summary::-webkit-details-marker { display: none; }

.legend-summary::before {
    content: "›";
    display: inline-block;
    margin-right: 7px;
    transform: rotate(0deg);
    transition: transform 160ms var(--ease);
}

.legend[open] .legend-summary::before {
    transform: rotate(90deg);
}

.legend-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.legend-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 0.88rem;
}

.legend-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 8px 0 0;
    line-height: 1.45;
}

/* Detail page */
.breadcrumb {
    margin-bottom: 14px;
    font-size: 0.88rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb a:hover { text-decoration: underline; }

.status-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.employee-hero { margin-top: 0; }

.employee-hero-main {
    display: flex;
    align-items: center;
    gap: 18px;
}

.employee-hero h1 { margin: 0 0 4px; }

.meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    align-items: center;
}

.meta-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--muted);
}

.status-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.status-card.green { background: var(--green-bg); border-color: oklch(0.86 0.04 145); }
.status-card.yellow { background: var(--yellow-bg); border-color: oklch(0.88 0.05 95); }
.status-card.red { background: var(--red-bg); border-color: oklch(0.86 0.04 25); }
.status-card.no_data { background: var(--gray-bg); }

.status-card-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.status-card-date {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 6px 0;
    font-variant-numeric: tabular-nums;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr minmax(240px, 300px);
    gap: 16px;
    align-items: start;
}

/* Forms */
.employee-form fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 0 0 14px;
    background: var(--surface);
}

.employee-form legend {
    float: left;
    width: 100%;
    font-weight: 600;
    padding: 0 0 12px;
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.employee-form legend + * {
    clear: both;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 18px;
}

.form-field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--muted);
}

.form-field-wide { grid-column: 1 / -1; }

.date-input {
    font-variant-numeric: tabular-nums;
}

.form-field.has-error input,
.form-field.has-error select {
    border-color: var(--red);
}

.field-hint {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.error-list {
    margin: 8px 0 0;
    padding-left: 1.2em;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 22px;
}

.form-check label { margin: 0; color: var(--ink); }

.field-status { margin-top: 6px; }

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.form-actions-sticky {
    position: sticky;
    bottom: 0;
    margin: 0 -20px -8px;
    padding: 12px 20px;
    background: oklch(1 0 0 / 0.94);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(8px);
    z-index: 2;
}

.info-list { margin: 12px 0 18px; }

.info-list dt {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 10px;
    font-weight: 500;
}

.info-list dd {
    margin: 2px 0 0;
    font-weight: 600;
}

/* Buttons */
button,
.button,
.button-secondary,
.button-small {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary);
    color: var(--primary-ink);
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 160ms var(--ease);
}

button:hover,
.button:hover {
    background: var(--primary-hover);
}

button:focus-visible,
.button:focus-visible,
.button-secondary:focus-visible,
.button-small:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

button:active,
.button:active {
    transform: translateY(1px);
}

.button-secondary {
    background: var(--panel);
    color: var(--ink);
    border-color: var(--border);
}

.button-secondary:hover {
    background: var(--surface);
    border-color: var(--border-strong);
}

.button-small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.button-block {
    display: block;
    text-align: center;
    width: 100%;
}

.empty-state {
    color: var(--muted);
    padding: 24px 0;
    text-align: center;
}

.empty-state-box {
    padding: 32px 16px;
    text-align: center;
}

.empty-state-title {
    margin: 0 0 6px;
    font-weight: 600;
    color: var(--ink);
}

.table-compact th,
.table-compact td {
    padding: 9px 8px;
}

.hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 14px;
}

.import-form .meta { margin-bottom: 12px; }

.import-form .dropzone {
    display: block;
    margin: 16px 0;
    padding: 36px 24px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
    cursor: pointer;
    transition: border-color 160ms var(--ease), background 160ms var(--ease), box-shadow 160ms var(--ease);
}

.import-form .dropzone:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.import-form .dropzone:focus-within {
    box-shadow: var(--focus);
    border-color: var(--primary);
}

.import-form .dropzone-active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--focus);
}

.import-form .dropzone-filled {
    border-style: solid;
    border-color: oklch(0.72 0.08 145);
    background: var(--green-bg);
}

.import-form .dropzone-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
    border-radius: var(--radius-sm);
    background: var(--panel);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--primary);
}

.import-form .dropzone-icon svg {
    width: 20px;
    height: 20px;
}

.import-form .dropzone-title {
    margin: 0 0 4px;
    font-weight: 600;
}

.import-form .dropzone-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.import-form .dropzone-file {
    margin: 12px 0 0;
    font-weight: 600;
    color: var(--green);
    word-break: break-all;
}

.import-form .dropzone-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.import-form .import-submit { margin-top: 4px; }

.columns-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.column-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.column-list li { margin: 4px 0; }

@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .stat-card:nth-child(3) { border-right: none; }
    .stat-card:nth-child(n + 4) { border-top: 1px solid var(--border); }
    .status-summary { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { border-right: 1px solid var(--border); }
    .stat-card:nth-child(2n) { border-right: none; }
    .stat-card:nth-child(n + 3) { border-top: 1px solid var(--border); }
    .status-summary { grid-template-columns: 1fr; }
    .employee-hero-main { flex-direction: column; align-items: flex-start; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .header-inner { flex-direction: column; align-items: flex-start; }
    .columns-grid { grid-template-columns: 1fr; }
    .filters { width: 100%; }
    .search-field { min-width: 100%; }
    main.container { padding: 20px 0 40px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background: var(--bg);
}

.login-shell {
    width: min(420px, 100%);
}

.login-card {
    margin: 0;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.login-brand h1 {
    margin: 0 0 4px;
    font-size: 1.35rem;
}

.login-brand .muted {
    margin: 0;
    font-size: 0.88rem;
}

.login-form {
    margin-top: 16px;
}

.login-form .form-field {
    margin-bottom: 14px;
}

.login-form input[type="password"] {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
}

.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus);
}

.login-note {
    margin: 16px 0 0;
    font-size: 0.82rem;
    line-height: 1.45;
}

.nav-logout-form {
    display: inline;
    margin: 0;
}

.nav-logout {
    color: var(--header-muted);
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.nav-logout:hover {
    color: var(--header-fg);
    background: oklch(1 0 0 / 0.08);
}

.nav-logout:focus-visible {
    outline: 2px solid oklch(0.78 0.08 250);
    outline-offset: 2px;
}

.org-filters {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.org-filters .chip {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.org-stats {
    margin-bottom: 16px;
}

.org-stats h2 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.org-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.org-stat-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    background: var(--surface);
}

.org-stat-link:hover {
    border-color: var(--primary);
    background: oklch(0.97 0.01 250);
}

.org-stat-name {
    font-size: 0.88rem;
    line-height: 1.3;
}

.org-stat-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
}

.vaccination-fieldset .panel-desc {
    margin: 0 0 12px;
}

.vaccination-table-wrap {
    overflow-x: auto;
}

.vaccination-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.vaccination-table th,
.vaccination-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.vaccination-table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--muted);
}

.vaccination-table input,
.vaccination-table select {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
}

.vaccination-table .col-status {
    white-space: nowrap;
    width: 1%;
}

.vaccination-table .col-delete {
    position: relative;
    width: 44px;
    text-align: center;
}

.vaccination-table .col-delete input[name$="-DELETE"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.vaccination-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--ink);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.vaccination-remove:hover,
.vaccination-remove:focus-visible {
    color: var(--red);
    border-color: var(--red);
    outline: none;
}

.vaccination-row.is-deleted td:not(.col-delete) {
    opacity: 0.45;
    text-decoration: line-through;
}

.vaccination-row.is-deleted .vaccination-remove {
    color: var(--primary);
    border-color: var(--primary);
}

.field-error {
    color: var(--red);
    font-size: 0.78rem;
    margin-top: 4px;
}

/* Refined task UI */
.filters {
    align-items: flex-end;
}

.filter-control {
    display: grid;
    gap: 5px;
    min-width: 180px;
}

.filter-control-search {
    flex: 1 1 320px;
}

.filter-control label,
.employee-form label {
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
}

.filters input,
.filters select,
.employee-form input,
.employee-form select,
.employee-form textarea {
    min-height: 44px;
    font-size: 1rem;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

button,
.button,
.button-secondary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.registry-table thead th {
    font-size: 0.82rem;
}

.registry-table td {
    font-size: 0.95rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 18px 0;
    color: var(--muted);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.section-heading h2 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.zup-readonly {
    margin: -10px -20px 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--primary-soft);
}

.zup-readonly .section-heading {
    align-items: center;
    margin-bottom: 10px;
}

.zup-readonly .panel-desc {
    margin-top: 2px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 9px 18px;
    margin: 0;
}

.info-grid div {
    min-width: 0;
}

.info-grid dt {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.info-grid dd {
    margin: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.add-vaccination {
    margin-top: 12px;
}

.delete-control {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    font-weight: 500;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sync-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 14px;
}

.sync-hero h2 {
    margin: 10px 0 4px;
    font-size: 1.2rem;
}

.sync-warning {
    border-color: var(--yellow);
}

.sync-state {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 9px;
    border-radius: var(--radius-sm);
    background: var(--gray-bg);
    color: var(--gray);
    font-size: 0.82rem;
    font-weight: 700;
}

.sync-state.success,
.sync-state.running {
    background: var(--green-bg);
    color: var(--green);
}

.sync-state.warning,
.sync-state.failed,
.sync-state.rejected {
    background: var(--red-bg);
    color: var(--red);
}

.sync-metrics {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
}

.sync-metrics div {
    flex: 1 1 150px;
    padding: 16px 18px;
    border-right: 1px solid var(--border);
}

.sync-metrics div:last-child {
    border-right: 0;
}

.sync-metrics strong,
.sync-metrics span {
    display: block;
}

.sync-metrics strong {
    color: var(--primary);
    font-size: 1.55rem;
    line-height: 1.1;
}

.sync-metrics span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.84rem;
}

@media (max-width: 768px) {
    .container {
        width: min(100% - 20px, 1180px);
    }

    .header-inner {
        align-items: stretch;
    }

    .main-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .main-nav a,
    .nav-logout {
        min-height: 44px;
        white-space: nowrap;
    }

    .filter-control,
    .filter-control-search {
        flex: 1 1 100%;
        width: 100%;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions > * {
        flex: 1;
    }

    .registry-table th:first-child,
    .registry-table td:first-child {
        position: static;
        background: var(--panel);
        box-shadow: none;
    }

    .registry-table thead th:first-child {
        position: static;
        background: var(--surface);
    }

    .sync-hero,
    .section-heading {
        display: grid;
    }

    .vaccination-table {
        min-width: 720px;
    }
}

/* Overflow safety for real ZUP values */
.container,
.page-header,
.page-header > *,
.page-actions,
.panel,
.panel-header,
.panel-header > *,
.two-col,
.two-col > *,
.detail-grid,
.detail-grid > *,
.employee-hero-main,
.employee-hero-main > *,
.status-summary > *,
.stats-grid > *,
.sync-hero > *,
.sync-metrics > *,
.filters > *,
.employee-form,
.employee-form fieldset,
.form-grid > *,
.vaccination-fieldset,
.registry-panel {
    min-width: 0;
    max-width: 100%;
}

.employee-form fieldset {
    min-inline-size: 0;
}

.table-wrap,
.vaccination-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
}

.table-panel .registry-table {
    min-width: 1020px;
}

.sync-hero + .sync-metrics + .panel .registry-table,
.panel .table-compact {
    min-width: 0;
}

.table-panel .registry-table th:first-child,
.table-panel .registry-table td:first-child {
    min-width: 230px;
    max-width: 320px;
}

.table-panel .registry-table th:nth-child(2),
.table-panel .registry-table td:nth-child(2) {
    min-width: 190px;
    max-width: 240px;
}

.table-panel .registry-table th:nth-child(3),
.table-panel .registry-table td:nth-child(3) {
    min-width: 220px;
    max-width: 310px;
}

.registry-table th,
.registry-table td,
.employee-link,
.employee-hero h1,
.employee-hero .subtitle,
.breadcrumb span,
.org-stat-name,
.meta-chip,
.panel-desc,
.sync-state,
.info-list dd {
    overflow-wrap: anywhere;
    word-break: normal;
}

.employee-link {
    display: block;
    line-height: 1.35;
}

.registry-table td {
    line-height: 1.4;
}

.registry-table th {
    white-space: nowrap;
}

.registry-table .col-health {
    min-width: 104px;
}

.dashboard-bottom {
    display: grid;
    gap: 16px;
}

.urgent-table {
    width: 100%;
    min-width: 0 !important;
    table-layout: auto;
}

.urgent-table th,
.urgent-table td {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: manual;
}

.urgent-table .col-health {
    width: 4.5rem;
    min-width: 4.5rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
}

.urgent-table td:nth-child(4),
.urgent-table td:nth-child(5),
.urgent-table td:nth-child(6),
.urgent-table td:nth-child(7) {
    text-align: center;
}

.urgent-table .col-overall,
.urgent-table td:last-child {
    width: 1%;
    min-width: 10.5rem;
    padding-right: 16px;
    text-align: center;
    white-space: nowrap;
}

.cadre-hint {
    margin: 10px 0 0;
}

.cadre-hint a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.cadre-hint a:hover {
    text-decoration: underline;
}

.page-actions > *,
.filter-actions > *,
.form-actions > * {
    max-width: 100%;
    text-align: center;
    white-space: normal;
}

.panel-header {
    flex-wrap: wrap;
}

.panel-header a {
    white-space: normal;
}

.meta-chip {
    max-width: 100%;
}

.sync-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
}

.sync-metrics div {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.org-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
}

.info-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
}

@media (max-width: 960px) {
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 768px) {
    .page-actions,
    .page-actions > *,
    .form-actions {
        width: 100%;
    }

    .form-actions > * {
        flex: 1 1 140px;
    }

    .sync-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .sync-metrics {
        grid-template-columns: minmax(0, 1fr);
    }

    .pagination {
        flex-wrap: wrap;
    }
}
