/* Ө and Ү are in the cyrillic-ext file. */
@font-face { font-family: Montserrat; font-weight: 100 900; font-display: block; src: url(fonts/montserrat-cyrillic-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: Montserrat; font-weight: 100 900; font-display: block; src: url(fonts/montserrat-cyrillic-wght-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: Montserrat; font-weight: 100 900; font-display: block; src: url(fonts/montserrat-latin-ext-wght-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0; }
@font-face { font-family: Montserrat; font-weight: 100 900; font-display: block; src: url(fonts/montserrat-latin-wght-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+2212, U+FEFF, U+FFFD; }
/* Only three colors are used: red, blue and white. */
:root {
  --red: #EC1F2E;
  --blue: #1053A1;
  --white: #FFFFFF;
  color-scheme: light;
  accent-color: var(--blue);
  scrollbar-color: var(--blue) var(--white);
  font: 16px/1.5 Montserrat, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
::selection { background: var(--blue); color: var(--white); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, select, input, summary, label { touch-action: manipulation; }
body { margin: 0; color: var(--blue); background: var(--white); }
h1, h2, h3, p, ul { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 1rem; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

/* Header */
.top { background: var(--blue); color: var(--white); }
.top :focus-visible { outline-color: var(--white); outline-offset: -3px; }
.bar { max-width: 1200px; margin: auto; padding: 0 20px; display: flex; justify-content: space-between; gap: 16px; }
.bar nav { display: flex; gap: 24px; }
.bar nav a { display: flex; align-items: center; min-height: 56px; color: var(--white); text-decoration: none; font-weight: 600; border-bottom: 4px solid transparent; border-top: 4px solid transparent; }
.bar nav a[aria-current] { border-bottom-color: var(--red); }
.account { position: relative; align-self: center; min-width: 0; }
.account summary { cursor: pointer; padding: 10px 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account > div { position: absolute; right: 0; z-index: 5; min-width: 190px; padding: 6px; background: var(--white); border: 2px solid var(--blue); border-radius: 8px; }
.account a, .account button { display: block; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 6px; background: none; color: var(--blue); font: inherit; text-align: left; text-decoration: none; }
.account div :focus-visible { outline-color: var(--red); }

/* Layout */
main { max-width: 1200px; margin: auto; padding: 24px 20px 64px; }
.narrow { max-width: 400px; padding-top: 12vh; }
.narrow h1 { margin-bottom: 20px; }
.title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.count { margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.empty { padding: 48px 20px; text-align: center; border: 1px solid var(--blue); border-radius: 10px; }

/* Buttons */
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px; border: 1px solid var(--blue); border-radius: 8px; background: var(--white); color: var(--blue); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.primary { background: var(--blue); color: var(--white); }
button:disabled, .disabled { border-style: dashed; background: var(--white); color: var(--blue); cursor: default; }
.link { border: 0; padding: 0; background: none; text-decoration: underline; }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.button:focus-within { outline: 3px solid var(--red); outline-offset: 2px; }
@media (hover: hover) {
  button:not(:disabled, .link, .primary):hover, .button:not(.primary, .disabled):hover, .account a:hover { background: var(--blue); color: var(--white); }
  .primary:not(:disabled, .disabled):hover { background: var(--white); color: var(--blue); }
  .bar nav a:hover { text-decoration: underline; text-underline-offset: 4px; }
  .cards a:hover { border-color: var(--red); }
}

/* Forms */
.field { min-width: 0; }
label { font-weight: 600; }
.field label { display: block; margin-bottom: 5px; }
.optional { font-weight: 400; white-space: nowrap; }
input, select { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid var(--blue); border-radius: 8px; background: var(--white); color: var(--blue); font: inherit; }
input::placeholder { color: var(--blue); opacity: 1; }
input:autofill { box-shadow: inset 0 0 0 100px var(--white); -webkit-text-fill-color: var(--blue); }
input[type=date], input[type=search] { -webkit-appearance: none; appearance: none; min-width: 0; }
input[type=search]::-webkit-search-cancel-button { display: none; }
input[type=date]::-webkit-calendar-picker-indicator { background: var(--blue); -webkit-mask: url(calendar.svg) center / 18px no-repeat; mask: url(calendar.svg) center / 18px no-repeat; cursor: pointer; }
select:disabled { border-style: dashed; color: var(--blue); opacity: 1; }
.no-date:not(:focus)::-webkit-datetime-edit { color: transparent; }
[aria-invalid], [aria-invalid]:disabled { border: 2px solid var(--red); }
.error { margin-top: 5px; color: var(--red); font-weight: 600; }
.alert { padding: 11px 14px; border: 2px solid var(--red); border-radius: 8px; color: var(--red); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; font-weight: 400; }
.check input { appearance: none; display: grid; place-items: center; width: 22px; min-height: 22px; margin: 0; padding: 0; border-radius: 5px; }
.check input:checked { background: var(--blue); }
.check input:checked::after { content: ""; width: 6px; height: 11px; margin-top: -3px; border: solid var(--white); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
form.stack, .narrow form { display: grid; gap: 16px; max-width: 400px; }
.narrow form + form { margin-top: 12px; justify-items: start; }
.person { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; align-items: start; max-width: 720px; }
.locations { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 16px; align-items: start; }
.person > .alert { grid-column: 1 / -1; }
.person > button { grid-column: 1 / -1; min-height: 50px; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; margin-bottom: 24px; }

.find { max-width: 400px; margin-bottom: 16px; }
[data-toggle-filters] { display: none; }

/* Dashboard */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.cards a { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; padding: 18px; border: 2px solid var(--blue); border-radius: 10px; text-decoration: none; }
.cards span { font-weight: 600; }
.cards strong { font-size: 2.25rem; line-height: 1; font-variant-numeric: tabular-nums; }
.cards small { font-size: 1.25rem; font-weight: 500; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--blue); border-radius: 10px; overflow: hidden; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { background: var(--blue); color: var(--white); font-size: .875rem; white-space: nowrap; }
td { border-top: 1px solid var(--blue); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.number { text-align: right; }
.unit { white-space: nowrap; }
.clip { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions button { min-height: 36px; padding: 4px 12px; font-size: .9375rem; }
.same a { color: var(--red); font-weight: 700; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-top: 18px; }
.pager > :first-child { justify-self: end; }
.pager > :last-child { justify-self: start; }

/* Import result and duplicate groups */
.panel { display: grid; gap: 12px; margin-bottom: 20px; padding: 18px; border: 2px solid var(--blue); border-radius: 10px; }
#import-error { margin-bottom: 20px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.problems { max-height: 260px; overflow: auto; padding: 0; list-style: none; }
.problems li { padding: 7px 0; border-top: 1px solid var(--blue); overflow-wrap: anywhere; }
.problems b { color: var(--red); }
.problems span { margin: 0 6px; }
.group { margin-bottom: 28px; }
.group h2 { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 8px; font-weight: 500; overflow-wrap: anywhere; }
.match b { color: var(--red); }

/* Dialogs and notifications */
dialog { width: min(420px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: 12px; background: var(--white); color: var(--blue); }
dialog::backdrop { background: var(--blue); }
dialog form { display: grid; gap: 16px; }
dialog .actions { justify-content: flex-end; }
.secret { font-size: 1.25rem; letter-spacing: .05em; user-select: all; }
#toast { position: fixed; left: 50%; top: 72px; z-index: 10; padding: 13px 22px; border: 2px solid var(--white); border-radius: 8px; background: var(--blue); color: var(--white); font-weight: 600; transform: translateX(-50%); visibility: hidden; white-space: nowrap; }
#toast.show { visibility: visible; }

/* Phones and tablets */
@media (max-width: 900px) {
  :root { --menu: calc(60px + env(safe-area-inset-bottom)); scroll-padding-bottom: calc(var(--menu) + 16px); }
  main { padding: 18px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }
  .top ~ main { padding-bottom: calc(var(--menu) + 32px); }
  .top { padding-top: env(safe-area-inset-top); }
  .bar { justify-content: flex-end; padding: 0 max(16px, env(safe-area-inset-right)); }
  .account summary { display: flex; align-items: center; min-height: 48px; max-width: 70vw; padding: 0; }
  .account summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: -4px 2px 0 10px; border: solid var(--white); border-width: 0 2px 2px 0; transform: rotate(45deg); }
  .account a, .account button { min-height: 50px; }
  .account > div { min-width: 220px; }

  /* The menu sits at the bottom, within reach of the thumb. */
  .bar nav { position: fixed; inset: auto 0 0; z-index: 6; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; height: var(--menu); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--blue); border-top: 1px solid var(--white); }
  .bar nav a { justify-content: center; min-height: 0; padding: 0 4px; border-bottom: 0; text-align: center; line-height: 1.2; }
  .bar nav a[aria-current] { border-top-color: var(--red); }
  .bar nav.admin a { font-size: .8125rem; }

  input, select, button, .button { min-height: 50px; }
  .check { min-height: 48px; }
  .check input { width: 26px; min-height: 26px; }
  .person > button { min-height: 56px; font-size: 1.0625rem; }
  .title { margin-bottom: 14px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .wide, .filters .actions { grid-column: 1 / -1; }
  .filters .actions > * { flex: 1; }
  .filters.closed .field:not(.wide) { display: none; }
  [data-toggle-filters] { display: inline-flex; }
  [data-toggle-filters][aria-expanded=true] { border-width: 2px; }
  .find { max-width: none; }
  .pager .button { min-width: 110px; }
  .problems { max-height: none; }

  /* Rows become labelled blocks so nothing scrolls sideways. */
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: block; padding: 12px 14px; }
  tr + tr { border-top: 1px solid var(--blue); }
  td { display: grid; grid-template-columns: 40% minmax(0, 1fr); gap: 10px; padding: 5px 0; border: 0; text-align: left; }
  td::before { content: attr(data-label); font-size: .8125rem; line-height: 1.8; overflow-wrap: normal; }
  td:empty { display: none; }
  td > div { min-width: 0; }
  td a { display: inline-block; padding: 6px 0; margin: -6px 0; }
  .number { text-align: left; }
  .row-actions { display: grid; grid-template-columns: 1fr 1fr; padding-top: 10px; }
  .row-actions::before { content: none; }
  .row-actions button { min-height: 48px; padding: 4px 8px; white-space: normal; line-height: 1.2; }
  .clip { max-width: 100%; }

  /* Near the top so the phone keyboard does not cover it. */
  dialog { margin-top: max(24px, 8vh); }
  dialog .actions > * { flex: 1; }
  #toast { top: calc(env(safe-area-inset-top) + 12px); width: calc(100vw - 32px); max-width: 420px; text-align: center; white-space: normal; font-size: 1.0625rem; }
}
@media (max-width: 560px) {
  .narrow { padding-top: 7vh; }
  .person, .locations { grid-template-columns: 1fr; }
  .cards a { padding: 14px; }
  .cards strong { font-size: 1.875rem; }
  .title .actions { flex: 1 1 auto; }
  .title .actions > * { flex: 1; padding: 8px 12px; white-space: nowrap; }
}
@media (max-width: 350px) {
  .bar nav.admin a { font-size: .6875rem; padding: 0 1px; }
  .cards span, .filters label { font-size: .875rem; }
}
