/* ============================================================
   PARIS VIA — учёт рабочего времени
   Токены совпадают с ассистентом: это один продукт, а не два.
   ============================================================ */

:root {
  --purple:     #7A3E93;
  --purple-600: #6B3382;
  --purple-700: #5A2A6E;
  --purple-200: #D9BFE4;
  --purple-100: #EEE2F3;
  --purple-050: #F7F1FA;

  --ink:    #1E1822;
  --ink-2:  #4A4152;
  --ink-3:  #857C8E;
  --line:   #E7E1EA;
  --line-2: #F0EBF3;

  --bg:      #FBFAFC;
  --surface: #FFFFFF;
  --surface-2: #F6F3F8;

  --danger: #C0392B;
  --danger-bg: #FDF1EF;
  --ok:     #2E7D57;
  --ok-bg:  #EDF7F2;
  --warn:   #B26A00;
  --warn-bg: #FDF5E8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --shadow-1: 0 1px 2px rgba(30,24,34,.05), 0 1px 3px rgba(30,24,34,.04);
  --shadow-2: 0 4px 16px rgba(30,24,34,.07), 0 1px 3px rgba(30,24,34,.05);
  --shadow-3: 0 18px 50px rgba(60,30,75,.14), 0 2px 8px rgba(30,24,34,.06);

  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--purple); }
[hidden] { display: none !important; }

/* ---------- бренд ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 34px; height: 34px; color: var(--purple); flex: none; }
.brand .mark svg { width: 100%; height: 100%; display: block; }
.wordmark { font-family: var(--serif); letter-spacing: .1em; line-height: 1; }
.wordmark .w1 { color: var(--ink); }
.wordmark .w2 { color: var(--purple); margin-left: .35em; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }
.btn-danger { color: var(--danger); border-color: #EFD9D5; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--r-sm); }

.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--purple-200); box-shadow: 0 0 0 3px var(--purple-050); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-3); font-weight: 500; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
}
.pill-in     { background: var(--ok-bg);     color: var(--ok); }
.pill-out    { background: var(--purple-100); color: var(--purple-700); }
.pill-open   { background: var(--danger-bg); color: var(--danger); }
.pill-late   { background: var(--warn-bg);   color: var(--warn); }
.pill-muted  { background: var(--surface-2); color: var(--ink-3); }

/* ============================================================
   КИОСК
   ============================================================ */

#kiosk {
  height: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 20px 32px;
  background:
    radial-gradient(1100px 600px at 50% -10%, var(--purple-050), transparent 70%),
    var(--bg);
  overflow: hidden;
}

.k-top {
  width: 100%; max-width: 900px;
  display: flex; align-items: center; justify-content: space-between;
  flex: none;
}
.k-top .wordmark { font-size: 21px; }
.k-branch { text-align: right; font-size: 13px; color: var(--ink-3); }
.k-branch b { display: block; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.k-clock { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--ink-2); font-weight: 600; }

.k-stage {
  flex: 1 1 auto; width: 100%; max-width: 620px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; min-height: 0; padding: 20px 0;
}

/* Видоискатель. Зеркалим по горизонтали — человек ожидает увидеть себя
   как в зеркале, иначе движения кажутся вывернутыми. */
.k-viewport {
  position: relative;
  width: min(420px, 72vh, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: var(--shadow-3);
  flex: none;
}
.k-viewport video {
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); display: block;
}
.k-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--purple-200);
  transition: border-color .25s, box-shadow .25s;
  pointer-events: none;
}
.k-viewport.busy .k-ring { border-color: var(--purple); box-shadow: 0 0 0 6px var(--purple-050); }
.k-viewport.ok   .k-ring { border-color: var(--ok);     box-shadow: 0 0 0 6px var(--ok-bg); }
.k-viewport.err  .k-ring { border-color: var(--danger); box-shadow: 0 0 0 6px var(--danger-bg); }

/* Бегущая полоса по кольцу, пока сервер думает */
.k-viewport.busy::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--purple);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.k-hint {
  font-size: 20px; color: var(--ink-2); text-align: center;
  min-height: 2.4em; max-width: 460px;
}
.k-hint.err { color: var(--danger); }

.k-actions { display: flex; gap: 10px; align-items: center; flex: none; }

/* Карточка результата — перекрывает видоискатель на несколько секунд */
.k-card {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(251,250,252,.94);
  backdrop-filter: blur(8px);
  animation: fade .2s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.k-card-inner {
  text-align: center; padding: 40px 44px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  max-width: 460px; width: calc(100% - 40px);
  animation: pop .25s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.k-card .k-photo {
  width: 116px; height: 116px; border-radius: 50%;
  object-fit: cover; margin: 0 auto 18px; display: block;
  border: 3px solid var(--purple-100);
}
.k-card .k-name { font-size: 27px; font-weight: 600; line-height: 1.2; }
.k-card .k-pos  { color: var(--ink-3); margin-top: 4px; font-size: 15px; }
.k-card .k-verdict {
  margin-top: 20px; font-size: 30px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.k-card.in  .k-verdict { color: var(--ok); }
.k-card.out .k-verdict { color: var(--purple); }
.k-card .k-sub { margin-top: 8px; color: var(--ink-3); font-size: 16px; }
.k-card.bad .k-name { font-size: 22px; color: var(--danger); }

.k-foot { flex: none; font-size: 12px; color: var(--ink-3); }
.k-foot a { color: var(--ink-3); }

/* ============================================================
   АДМИНКА
   ============================================================ */

#login {
  height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(900px 500px at 50% 0%, var(--purple-050), transparent 70%), var(--bg);
}
.login-card {
  width: 100%; max-width: 360px; padding: 32px;
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; gap: 16px;
}
.login-card .brand { justify-content: center; }
.login-card .wordmark { font-size: 22px; }
.login-sub { text-align: center; color: var(--ink-3); font-size: 14px; margin: -4px 0 4px; }

#app { height: 100%; display: grid; grid-template-columns: 232px 1fr; }

.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px;
  overflow-y: auto;
}
.side .brand { padding: 0 8px 20px; }
.side .wordmark { font-size: 17px; }
.side .side-tag { font-size: 11px; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; padding: 0 8px 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  color: var(--ink-2); text-align: left; font-weight: 500;
}
.nav button:hover { background: var(--surface-2); }
.nav button.on { background: var(--purple-050); color: var(--purple-700); font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.side-user { font-size: 13px; color: var(--ink-3); padding: 0 8px; }

.main { overflow-y: auto; padding: 26px 30px 60px; }
.head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.head h1 { font-size: 23px; margin: 0; font-weight: 600; }
.head .sub { color: var(--ink-3); font-size: 14px; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .input { width: auto; min-width: 170px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
  margin-bottom: 18px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-body { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 15px 17px;
}
.stat .n { font-size: 27px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.stat.alarm .n { color: var(--danger); }

/* Таблицы шире экрана скроллим внутри, а не всей страницей */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surface);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.nowrap, th.nowrap { white-space: nowrap; }
.muted { color: var(--ink-3); }

.thumb {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--line); display: block;
  cursor: zoom-in;
}

.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }

/* ---------- табель ---------- */
.sheet { font-size: 12.5px; }
.sheet th, .sheet td { padding: 6px 7px; text-align: center; }
.sheet th.name, .sheet td.name {
  text-align: left; white-space: nowrap; position: sticky; left: 0;
  background: var(--surface); z-index: 1; min-width: 190px;
  box-shadow: 1px 0 0 var(--line-2);
}
.sheet tbody tr:hover td.name { background: var(--surface-2); }
.sheet td.d { font-variant-numeric: tabular-nums; cursor: default; }
.sheet td.d.has { font-weight: 600; }
.sheet td.d.late { color: var(--warn); }
.sheet td.d.open { color: var(--danger); background: var(--danger-bg); }
.sheet th.we, .sheet td.we { background: var(--surface-2); }
.sheet td.total { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- модалка ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(30,24,34,.35); backdrop-filter: blur(3px);
  animation: fade .15s ease-out;
}
.modal-inner {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3); width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .2s cubic-bezier(.2,.9,.3,1.2);
}
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-head h2 { font-size: 17px; margin: 0; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--line-2);
  display: flex; gap: 10px; justify-content: flex-end;
}
.x { width: 30px; height: 30px; border-radius: 50%; color: var(--ink-3); font-size: 20px; line-height: 1; }
.x:hover { background: var(--surface-2); color: var(--ink); }

.faces { display: flex; flex-wrap: wrap; gap: 10px; }
.face-item { position: relative; }
.face-item img { width: 84px; height: 84px; border-radius: var(--r-md); object-fit: cover; border: 1px solid var(--line); display: block; }
.face-item button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); color: var(--danger); font-size: 14px; line-height: 1;
}

.note {
  padding: 11px 14px; border-radius: var(--r-md);
  font-size: 13.5px; line-height: 1.5;
  background: var(--purple-050); color: var(--purple-700);
}
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.err  { background: var(--danger-bg); color: var(--danger); }
.note.ok   { background: var(--ok-bg); color: var(--ok); }

.tokenbox {
  font-family: var(--mono); font-size: 12px; word-break: break-all;
  background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line);
}

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 100; padding: 11px 20px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 14px;
  box-shadow: var(--shadow-3); animation: pop .2s;
  max-width: calc(100vw - 40px);
}
.toast.err { background: var(--danger); }

.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(30,24,34,.8);
  display: flex; align-items: center; justify-content: center; padding: 30px;
  cursor: zoom-out; animation: fade .15s;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r-lg); }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px;
          border-right: none; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .side .brand, .side .side-tag, .side-user { display: none; }
  .nav { flex-direction: row; }
  .side-foot { margin: 0; padding: 0; }
  .main { padding: 18px 16px 50px; }
}
