/* Кадровий облік — базові стилі.
   Телефон: нижня панель навігації; планшет і комп'ютер: верхня.
   Друк: лише вміст документа на A4. */
:root {
  --bg: #F5F7F9; --surface: #FFFFFF; --fg: #16202A; --muted: #5A6672; --line: #D3DAE1;
  --accent: #1D5C82; --accent-fg: #FFFFFF; --accent-soft: #E2EDF4;
  --ok: #2C7A4C; --ok-bg: #E1F1E7; --warn: #8E6300; --warn-bg: #FBEFC8; --err: #A83A22; --err-bg: #FBE8E2;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E141A; --surface: #151D25; --fg: #E2E8EE; --muted: #97A4B1; --line: #2A3540;
    --accent: #7CB6DA; --accent-fg: #0E141A; --accent-soft: #19303F;
    --ok: #7FCB9C; --ok-bg: #15301F; --warn: #E6C063; --warn-bg: #32290E; --err: #F09A80; --err-bg: #321A12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .75rem; text-wrap: balance; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* --- Каркас --- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top, 0px) 16px 0; }
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--fg); text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; line-height: 1.1; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; color: var(--fg); text-decoration: none; font-size: .95rem; }
.nav a:hover, .nav a.active { background: var(--accent-soft); }
.nav svg { width: 20px; height: 20px; flex: none; }
.badge { display: inline-block; min-width: 1.4em; padding: 1px 6px; border-radius: 999px; background: var(--err); color: #fff; font-size: .75rem; font-weight: 600; text-align: center; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 96px; }

@media (max-width: 720px) {
  .topbar .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 8px; position: relative; }
  .nav a .badge { position: absolute; top: 0; right: 4px; }
  .nav .nav-wide { display: none; }
}

/* --- Елементи --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .grid > * { min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--err); }
.btn-block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.pill { display: inline-block; font-size: .8rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); }

.messages { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.messages li { padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); }
.messages li.success { background: var(--ok-bg); }
.messages li.error { background: var(--err-bg); }
.messages li.warning { background: var(--warn-bg); }

form p { margin-bottom: 12px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--err); font-size: .9rem; }
.helptext { display: block; color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; background: var(--bg); }
tr:last-child td { border-bottom: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list .unread { font-weight: 700; }

.stage-card { display: grid; gap: 6px; opacity: .85; }
.stage-card .pill { justify-self: start; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); }

/* --- Персонал --- */
.page-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }
.people { list-style: none; margin: 0; padding: 0; }
.people li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); }
.people li:last-child a { border-bottom: none; }
.people li a:hover { background: var(--accent-soft); }
.people .who { font-weight: 600; }
.people .meta { grid-column: 1; color: var(--muted); font-size: .88rem; }
.people .side { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; }

.person-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; margin-bottom: 12px; }
.avatar { width: 64px; height: 64px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 1.4rem; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-head h1 { margin: 0 0 2px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 14px; scrollbar-width: none; }
.tabs a { padding: 10px 14px; white-space: nowrap; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--fg); border-color: var(--accent); }

.dl { display: grid; grid-template-columns: minmax(140px, 34%) minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 0; } .dl dd { margin-bottom: 8px; } }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: none; }
.checklist .mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.checklist .done .mark { background: var(--ok-bg); color: var(--ok); }
.checklist .missing .mark { background: var(--err-bg); color: var(--err); }
.checklist .decide .mark { background: var(--warn-bg); color: var(--warn); }
.checklist .not_required .mark { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.lvl { font: 600 .75rem var(--mono); padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

.form-section { margin-bottom: 14px; }
.form-section h2 { margin: 0 0 10px; font-size: 1.05rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 14px; }
.form-grid p { margin: 0 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
input[type=date], input[type=number], input[type=file], input[type=tel] { width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) { .sticky-actions { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); } }

/* --- Планшет (кіоск) --- */
.kiosk-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kiosk-user { display: flex; align-items: center; min-height: 72px; padding: 14px 16px; font-size: 1.05rem; font-weight: 600;
  text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kiosk-user:hover { background: var(--accent-soft); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 16px auto; }
.pinpad button { min-height: 64px; font: 600 1.5rem var(--font); border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.pinpad button:active { background: var(--accent-soft); }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); }
.pin-dots span.on { background: var(--accent); }
.kiosk-bar { background: var(--warn-bg); color: var(--fg); text-align: center; font-size: .9rem; padding: 6px 16px; }

/* --- Друк: лише документ, формат A4 --- */
.print-only { display: none; }
@page { size: A4; margin: 18mm 15mm 18mm 25mm; }
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --fg: #000; --muted: #333; --line: #999; }
  body { background: #fff; color: #000; font: 12pt/1.4 "Times New Roman", serif; }
  .topbar, .nav, .no-print, .messages, .kiosk-bar { display: none !important; }
  .print-only { display: block; }
  main { max-width: none; padding: 0; }
  .card { border: none; padding: 0; }
  .table-wrap { border: none; overflow: visible; }
  th { background: #eee; color: #000; }
  th, td { border: 1px solid #999; }
  a { color: #000; text-decoration: none; }
}
.print-header { border-bottom: 1px solid #000; padding-bottom: 6pt; margin-bottom: 12pt; font-size: 10pt; }

/* Перемикач юрособи */
.employer-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.employer-switch label { font-size: .85rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.employer-switch select { min-height: 40px; max-width: 100%; flex: 0 1 auto; }
