:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f4f6f9;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
a { color: #164e9a; }
button, input, select, textarea { font: inherit; }

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
    color: white;
    background: #123660;
}

.brand { color: white; font-size: 1.1rem; font-weight: 750; text-decoration: none; }
.main-nav { display: flex; flex: 1; flex-wrap: wrap; justify-content: center; gap: 0.35rem; }
.main-nav a { padding: 0.45rem 0.65rem; border-radius: 7px; color: white; text-decoration: none; font-weight: 650; }
.main-nav a:hover { background: rgb(255 255 255 / 14%); }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.header-actions a { color: white; }
.role { padding: 0.18rem 0.5rem; border-radius: 999px; background: #dceaff; color: #123660; font-size: 0.78rem; }
.inline { display: inline; }

.container { width: min(1180px, calc(100% - 2rem)); margin: 2rem auto; }
.narrow { width: min(460px, calc(100% - 2rem)); }
.card { padding: 1.4rem; border: 1px solid #dbe2ea; border-radius: 12px; background: white; box-shadow: 0 8px 30px rgb(18 54 96 / 7%); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
h1 { margin: 0 0 0.35rem; font-size: clamp(1.55rem, 4vw, 2.1rem); }
.muted { margin: 0; color: #657086; }

.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.field label { font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 0.65rem 0.75rem; border: 1px solid #aeb8c7; border-radius: 7px; background: white; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid #b9d7ff; border-color: #165da7; }
.field small, .choice small { display: block; margin-top: 0.2rem; color: #657086; font-weight: 400; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0.6rem 0.9rem; border: 0; border-radius: 7px; color: white; background: #165da7; cursor: pointer; text-decoration: none; font-weight: 650; }
.button:hover { background: #0f4a87; }
.button-secondary { color: #172033; background: #e9eef5; }
.button-link { padding: 0; min-height: auto; color: white; background: transparent; }
.button-danger { background: #a12626; }
.button-danger:hover { background: #7e1b1b; }
.actions, .form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }

.alert { padding: 0.8rem 1rem; margin-bottom: 1rem; border-radius: 7px; }
.alert-error { color: #781a1a; background: #fde8e8; border: 1px solid #f4b8b8; }
.alert-success { color: #155d34; background: #e4f7eb; border: 1px solid #a8dfbc; }

.table-wrap { overflow-x: auto; border: 1px solid #dbe2ea; border-radius: 10px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; border-bottom: 1px solid #e5eaf0; text-align: left; vertical-align: top; }
th { color: #41506a; background: #f6f8fb; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.center { text-align: center; }
.empty { padding: 2.5rem 1rem; text-align: center; color: #657086; }
.form-container { width: min(900px, calc(100% - 2rem)); }
.visit-form { display: grid; gap: 1.25rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
fieldset { min-width: 0; margin: 0; padding: 1rem; border: 1px solid #dbe2ea; border-radius: 8px; }
legend { padding: 0 0.35rem; font-weight: 750; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.55rem; }
.choice { display: flex; gap: 0.55rem; align-items: flex-start; min-height: 42px; padding: 0.55rem; border-radius: 7px; background: #f6f8fb; cursor: pointer; }
.choice input { margin-top: 0.2rem; }
.choice-prominent { padding: 0.9rem; border: 1px solid #b7c9df; background: #edf5ff; }
.language-list { display: grid; gap: 0.5rem; }
.language-row { display: grid; grid-template-columns: minmax(160px, 1fr) 130px; gap: 0.75rem; align-items: center; }
.quantity { width: 100%; min-height: 40px; padding: 0.5rem; border: 1px solid #aeb8c7; border-radius: 7px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.detail-grid > div { display: grid; gap: 0.2rem; }
.detail-grid small { display: block; color: #657086; }
.detail-label { color: #657086; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.detail-wide { grid-column: 1 / -1; }
.detail-wide p { margin: 0; white-space: normal; }
.danger-zone { margin-top: 1rem; border-color: #e4b4b4; }
.danger-zone h2 { margin-top: 0; }
.timeline { display: grid; gap: 1rem; }
.timeline-heading { display: flex; justify-content: space-between; gap: 1rem; }
.timeline-heading p { margin: 0.3rem 0 0; }
details pre { overflow-x: auto; padding: 0.8rem; border-radius: 7px; background: #111827; color: #e5e7eb; }
.admin-nav { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.admin-nav a { padding: 0.5rem 0.75rem; border-radius: 7px; background: #e9eef5; text-decoration: none; font-weight: 650; }
.admin-section { margin: 0 0 2.5rem; scroll-margin-top: 1rem; }
.admin-section h2 { margin-bottom: 0.75rem; }
.compact-form { margin-bottom: 1rem; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1.5fr 0.8fr 1.5fr; gap: 0.8rem; }
.admin-form-grid.two { grid-template-columns: minmax(150px, 0.6fr) minmax(240px, 1.4fr); }
.form-help { margin: -0.35rem 0 1rem; color: #657086; font-size: 0.9rem; }
.admin-table { margin-top: 1rem; }
.row-actions, .reset-form { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.reset-form input { min-height: 42px; max-width: 190px; padding: 0.5rem 0.6rem; border: 1px solid #aeb8c7; border-radius: 7px; }
.filter-panel { margin-bottom: 1rem; padding-bottom: 1rem; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 0 0.8rem; }
.filter-search { grid-column: span 2; }
.filter-date-range { display: grid; grid-column: span 2; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.filter-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.deleted-row { opacity: 0.68; background: #fff5f5; }
td small { display: block; color: #8b2f2f; }
.year-selector { display: flex; align-items: end; gap: 0.7rem; width: fit-content; margin-bottom: 1rem; }
.year-selector .field { min-width: 140px; margin: 0; }
.stat-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { display: grid; gap: 0.2rem; }
.stat-card span, .stat-card small { color: #657086; }
.stat-card strong { font-size: 1.8rem; color: #123660; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stats-grid h2, .stats-table h2 { margin-top: 0; font-size: 1.15rem; }
.stats-table { margin-bottom: 1rem; }
.bar-list { display: grid; gap: 0.55rem; }
.bar-row { display: grid; grid-template-columns: 7rem minmax(80px, 1fr) 2.5rem; gap: 0.6rem; align-items: center; }
.bar-row strong { text-align: right; }
.bar-track { height: 0.75rem; overflow: hidden; border-radius: 999px; background: #e6ebf1; }
.bar-track span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: #367fc5; }

@media (max-width: 720px) {
    .site-header { align-items: flex-start; }
    .main-nav { order: 3; flex-basis: 100%; justify-content: flex-start; }
    .main-nav a { padding-inline: 0.5rem; }
    .username { display: none; }
    .container { margin-top: 1.2rem; }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .admin-form-grid, .admin-form-grid.two { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-search { grid-column: auto; }
    .filter-date-range { grid-column: auto; grid-template-columns: 1fr; }
    .stat-cards, .stats-grid { grid-template-columns: 1fr; }
    .year-selector { width: 100%; }
    .detail-wide { grid-column: auto; }
    .language-row { grid-template-columns: 1fr 110px; }
    .table-wrap { border: 0; overflow: visible; background: transparent; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    tr { margin-bottom: 0.8rem; padding: 0.8rem; border: 1px solid #dbe2ea; border-radius: 10px; background: white; }
    td { display: grid; grid-template-columns: 7rem 1fr; gap: 0.5rem; padding: 0.4rem 0; border: 0; }
    td::before { content: attr(data-label); color: #657086; font-weight: 650; }
    td.center { text-align: left; }
}
