:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f9fafb; --border: #e3e6ea;
  --text: #16191d; --muted: #68717d; --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #d9f2ef;
  --green: #15803d; --green-soft: #dcfce7; --blue: #1d4ed8; --blue-soft: #dbeafe;
  --red: #b91c1c; --red-soft: #fee2e2; --amber: #a16207; --amber-soft: #fef3c7;
  --gray-soft: #e9ebee; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
  --control-h: 38px; --control-h-sm: 32px; --control-border: #cdd3da; --control-w: 200px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1215; --surface: #181c21; --surface-2: #1e232a; --border: #2a3038;
    --text: #e8eaed; --muted: #98a1ad; --accent: #2dd4bf; --accent-ink: #06201d; --accent-soft: #123a36;
    --green: #4ade80; --green-soft: #12351f; --blue: #7aa7ff; --blue-soft: #172a4d;
    --red: #f87171; --red-soft: #431a1a; --amber: #fbbf24; --amber-soft: #3d2f0c;
    --gray-soft: #262c34; --shadow: none; --control-border: #3b434d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 14px 10px 6px; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.who b { display: block; }
.who button { margin-top: 8px; }
.main { padding: 24px 28px 48px; min-width: 0; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .brand { padding: 4px 6px; display: flex; justify-content: space-between; align-items: center; }
  .menu-toggle { display: inline-flex; }
  .side .nav, .side .who { display: none; }
  .side.open .nav, .side.open .who { display: block; }
  .main { padding: 16px 16px 40px; }
}

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > h2 { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: var(--text); display: block; box-shadow: var(--shadow); }
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; }

.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.sticky-col { background: var(--surface-2); z-index: 2; }
.grid-ts td, .grid-ts th { padding: 6px 6px; font-size: 12.5px; text-align: center; min-width: 46px; }
.grid-ts td.sticky-col, .grid-ts th.sticky-col { text-align: left; min-width: 200px; font-size: 14px; padding-left: 12px; }
.grid-ts td a { color: inherit; }
.wk { background: var(--surface-2); }
.lv { background: var(--blue-soft); color: var(--blue); }
.warn-cell { background: var(--red-soft); color: var(--red); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; background: var(--gray-soft); color: var(--muted); }
.b-in_office, .b-in, .b-ok { background: var(--green-soft); color: var(--green); }
.b-remote, .b-link { background: var(--blue-soft); color: var(--blue); }
.b-absent, .b-err { background: var(--red-soft); color: var(--red); }
.b-on_leave, .b-manual, .b-warn { background: var(--amber-soft); color: var(--amber); }
.b-admin, .b-door { background: var(--accent-soft); color: var(--accent); }

/* ── Элементы управления: одна высота, рамка, шрифт, скругление и состояние фокуса для всех ── */
input[type=text], input[type=search], input[type=number], input[type=date], input[type=time],
input[type=datetime-local], input[type=email], input[type=url], input[type=password], select, textarea {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: var(--control-h); margin: 0;
  padding: 0 12px; font: inherit; font-size: 14px; line-height: normal; color: var(--text);
  background-color: var(--surface); border: 1px solid var(--control-border); border-radius: 8px;
  transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 76px; padding: 8px 12px; line-height: 1.45; resize: vertical; }
select { padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%2368717d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
select[multiple] { height: auto; min-height: 112px; padding: 6px; background-image: none; cursor: default; }
select[multiple] option { padding: 5px 8px; border-radius: 5px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button { opacity: .5; }
input[type=search]::-webkit-search-decoration, input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
input::-webkit-datetime-edit { padding: 0; }
input::-webkit-date-and-time-value { text-align: left; }
input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; margin-left: 4px; }
@media (prefers-color-scheme: dark) { input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .85; } }

input[type=checkbox] { -webkit-appearance: none; appearance: none; flex: none; width: 18px; height: 18px; margin: 0;
  background: var(--surface) center / 12px 12px no-repeat; border: 1px solid var(--control-border); border-radius: 5px;
  cursor: pointer; transition: border-color .12s, box-shadow .12s, background-color .12s; }
input[type=checkbox]:checked { background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5'/%3E%3C/svg%3E"); }

input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus, input[type=checkbox]:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 8px; }
input:disabled, select:disabled, textarea:disabled, button:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, label.lbl { font-size: 12px; line-height: 1.2; color: var(--muted); }
.check { display: inline-flex; gap: 8px; align-items: center; min-height: var(--control-h); font-size: 14px; cursor: pointer; }

button, .btn { font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; border: 1px solid var(--control-border);
  background: var(--surface); color: var(--text); padding: 0 14px; height: var(--control-h); white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background-color .12s, filter .12s; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.primary:hover { background: var(--accent); filter: brightness(1.06); }
.danger { color: var(--red); }
.small { padding: 0 10px; height: var(--control-h-sm); font-size: 13px; }

/* В строке фильтров у всех полей одна ширина; в сетке .cols поля тянутся на ячейку. */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { width: var(--control-w); }
.row-form select, .row-form input:not([type=checkbox]) { width: var(--control-w); height: var(--control-h-sm); font-size: 13px; }
.row-form .field { width: var(--control-w); }
.row-form .field input, .row-form .field select { width: 100%; height: var(--control-h); font-size: 14px; }
.row-form .check { min-height: var(--control-h-sm); font-size: 13px; }
.tbl-inputs input:not([type=checkbox]) { width: 120px; }
@media (max-width: 560px) { .filters .field, .row-form .field, .row-form select { width: 100%; } .filters > button, .filters > .btn { flex: 1; } }
form.inline { display: inline; }
.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.error { background: var(--red-soft); color: var(--red); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px; color: var(--muted); font-size: 13px; }
.head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; }
details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 12px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; }

/* мобильная версия: только «Отметка» — шапка без меню */
.mbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.mbar .brand { padding: 0; }
.mbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.mbar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbar + .main { padding: 16px 16px 32px; }

/* отметка — мобильный экран */
.checkin { max-width: 460px; margin: 0 auto; text-align: center; }
.checkin .clock { font-size: 44px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bigbtn { width: 100%; min-height: 96px; font-size: 22px; font-weight: 700; border-radius: 16px; border: 0;
  justify-content: center; margin: 18px 0 8px; color: #fff; }
.bigbtn.in { background: #15803d; } .bigbtn.out { background: #b45309; }
.bigbtn:hover { filter: brightness(1.07); }
.bigbtn:active { transform: translateY(1px); }
.login { max-width: 400px; margin: 12vh auto 0; text-align: center; }
.login .brand { font-size: 28px; padding: 0 0 6px; }
.login .primary { width: 100%; justify-content: center; min-height: 48px; font-size: 16px; }
