:root {
  /* — Emerald & Harvest — премиум-палитра interAGRO — */
  --bg: #f3f6f3; --panel: #ffffff; --ink: #0a1510; --muted: #66756c; --line: #e7ece8;
  --primary: #12a85c; --primary-d: #0e8f4d;
  --primary-grad: linear-gradient(145deg, #2fd47f 0%, #14b365 45%, #0e9b54 100%);
  --gold: #e3b24c; --gold-soft: #f6e6bd;
  --ok: #12a85c; --ok-bg: #d8f5e4; --warn: #c98a1e; --warn-bg: #fbf0d6;
  --err: #e0484d; --err-bg: #fde4e4; --dark: #07120d;
  --dark-grad:
    radial-gradient(115% 75% at 50% -12%, rgba(28,200,120,.20), transparent 58%),
    radial-gradient(95% 55% at 50% 112%, rgba(20,170,95,.12), transparent 60%),
    linear-gradient(162deg, #0d2018 0%, #081109 100%);
  --display: 'Manrope', 'Inter', -apple-system, system-ui, sans-serif;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(10,21,16,.05), 0 14px 34px -18px rgba(10,21,16,.20);
  --shadow-hover: 0 1px 2px rgba(10,21,16,.06), 0 24px 50px -22px rgba(18,168,92,.32);
  --glow: 0 0 0 1px rgba(255,255,255,.05) inset, 0 0 44px -10px rgba(28,200,120,.30);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #f5f8f5, #eaf0eb) fixed; color: var(--ink);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; letter-spacing: -0.1px;
}
h1, h2, .emp-clock, .stat-num, .pin-display, .mark-btn, .brand-badge b, .admin-top .brand { font-family: var(--display); letter-spacing: -0.4px; }
#app { min-height: 100vh; }
.loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; }
#fatal { position: fixed; left: 0; right: 0; bottom: 0; background: var(--err); color: #fff; padding: 14px 18px; font-size: 14px; z-index: 9999; white-space: pre-wrap; }

/* кнопки */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 650; cursor: pointer;
  transition: transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease, filter .15s ease, background .15s ease; }
.btn:hover { box-shadow: 0 8px 20px -10px rgba(10,21,16,.25); transform: translateY(-1px); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary-grad); border-color: transparent; color: #fff; box-shadow: 0 10px 26px -10px rgba(18,168,92,.6), 0 1px 0 rgba(255,255,255,.25) inset; }
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 16px 32px -12px rgba(18,168,92,.7), 0 1px 0 rgba(255,255,255,.25) inset; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(10,21,16,.04); color: var(--ink); box-shadow: none; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.block { width: 100%; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); width: 40px; height: 40px; border-radius: 12px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .12s ease; }
.icon-btn:hover { background: #eef3ef; color: var(--ink); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.danger { color: var(--err); border-color: #f6cccd; }
.icon-btn.danger:hover { background: var(--err-bg); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--primary-d); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.muted { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.err-text { color: var(--err); font-size: 14px; font-weight: 650; }
.ok-text { color: var(--ok); font-weight: 650; }

input, select { font: inherit; padding: 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fcfdfc; width: 100%; transition: border-color .15s ease, box-shadow .15s ease, background .15s ease; }
input:focus, select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(18,168,92,.14); }
label.field { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 12px; }
label.field input, label.field select { margin-top: 5px; }

/* центрированная карточка (вход/настройка) */
.center-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--dark-grad); padding: 20px; }
.card { background: var(--panel); border-radius: 26px; padding: 32px; width: 100%; max-width: 392px;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,.6), 0 2px 0 rgba(255,255,255,.5) inset; animation: rise .5s cubic-bezier(.2,.8,.2,1); }
.card h1 { font-size: 26px; margin: 0 0 4px; }
.card .sub { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.brand-badge { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.brand-badge img { height: 46px; width: auto; }
.brand-badge b { font-size: 18px; }
.logo { height: 38px; width: auto; display: block; }
.brand-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }

/* keypad */
.pin-display { height: 46px; margin: 8px 0; display: flex; align-items: center; justify-content: center;
  font-size: 28px; letter-spacing: 12px; color: var(--ink); border-bottom: 2px solid var(--line); }
.pin-display.err { border-color: var(--err); }
.pin-ph { color: #c2cdc6; letter-spacing: 6px; font-size: 20px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.key { padding: 17px 0; font-size: 22px; font-weight: 700; color: var(--ink); background: #f5f8f5; border: 1px solid var(--line); border-radius: 16px; cursor: pointer; transition: transform .1s ease, background .15s ease; }
.key:hover { background: #eef3ef; }
.key:active { transform: scale(.94); }
.key.ok { background: var(--primary-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 18px -8px rgba(18,168,92,.6); }
.key.sub { background: #fff; color: var(--muted); }

/* ====== экран сотрудника (отметка) ====== */
.emp-screen { min-height: 100vh; display: flex; flex-direction: column; background: var(--dark-grad); background-attachment: fixed; color: #fff; }
.emp-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(8,17,11,.35); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,.06); position: sticky; top: 0; z-index: 10; }
.emp-top .who { font-weight: 750; line-height: 1.2; }
.emp-top .who small { display: block; color: #8fa79a; font-weight: 500; font-size: 12.5px; }
.emp-top .logout { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08); color: #eaf2ed; padding: 8px 13px; border-radius: 11px; cursor: pointer; font-weight: 650; font-size: 14px; transition: background .15s ease; }
.emp-top .logout:hover { background: rgba(255,255,255,.16); }
.emp-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); text-align: center; }
.greeting { font-family: var(--display); font-size: 15px; font-weight: 600; color: #7fd6a6; letter-spacing: .2px; margin-bottom: -8px; }
.emp-clock { font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 2px 30px rgba(28,200,120,.25); }
.emp-date { color: #8fa79a; margin-top: 2px; font-size: 14.5px; }
.status-pill { padding: 9px 20px; border-radius: 999px; font-weight: 700; font-size: 14.5px; border: 1px solid transparent; backdrop-filter: blur(8px); }
.status-pill.in { background: rgba(18,168,92,.18); color: #6ee7a8; border-color: rgba(46,212,127,.35); }
.status-pill.out { background: rgba(255,255,255,.08); color: #c4d2ca; border-color: rgba(255,255,255,.12); }

.mark-btn { position: relative; width: min(74vw, 264px); height: min(74vw, 264px); border-radius: 50%; border: none; cursor: pointer;
  font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: .5px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; isolation: isolate;
  box-shadow: 0 24px 60px -18px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) inset, 0 2px 4px rgba(255,255,255,.25) inset;
  transition: transform .12s cubic-bezier(.2,.8,.2,1); }
.mark-btn::after { content: ''; position: absolute; inset: -14px; border-radius: 50%; z-index: -1;
  border: 2px solid rgba(46,212,127,.5); animation: aura 2.6s ease-in-out infinite; }
.mark-btn.go-out::after { border-color: rgba(96,165,250,.5); }
.mark-btn:active { transform: scale(.95); }
.mark-btn.go-in { background: radial-gradient(120% 120% at 30% 20%, #43e08c 0%, #16b365 45%, #0c9150 100%); }
.mark-btn.go-out { background: radial-gradient(120% 120% at 30% 20%, #5aa6ff 0%, #2f7df0 48%, #1d5fd6 100%); }
.mark-btn:disabled { opacity: .55; }
.mark-btn:disabled::after { animation: none; opacity: .3; }
.mark-btn .sub { font-family: 'Inter', sans-serif; font-size: 14.5px; font-weight: 600; letter-spacing: 0; opacity: .92; max-width: 80%; }

.emp-cam { width: min(66vw, 230px); aspect-ratio: 1; border-radius: 28px; overflow: hidden; background: #000; position: relative;
  box-shadow: 0 24px 60px -22px rgba(0,0,0,.75), var(--glow); border: 1px solid rgba(255,255,255,.07); }
.emp-cam video, .emp-cam .face-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.emp-cam .face-overlay { pointer-events: none; z-index: 2; }
.face-hint { font-size: 14px; font-weight: 650; color: #fb9aa0; min-height: 20px; transition: color .2s ease; }
.face-hint.ok { color: #6ee7a8; }
.proc-status { font-size: 15px; color: #b6c7bd; min-height: 22px; font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 14px 24px; border-radius: 16px; font-weight: 700; color: #fff; z-index: 200; max-width: 90vw; text-align: center;
  box-shadow: 0 20px 50px -16px rgba(0,0,0,.5); animation: pop .35s cubic-bezier(.2,.9,.2,1); }
.toast.ok { background: linear-gradient(135deg, #16b365, #0e9b54); } .toast.err { background: linear-gradient(135deg, #ef5a5f, #d83a40); } .toast.warn { background: linear-gradient(135deg, #d9a441, #c98a1e); }

/* успешная отметка — вспышка-печать */
.flash { position: fixed; inset: 0; z-index: 220; display: flex; align-items: center; justify-content: center; pointer-events: none; background: rgba(7,18,13,.4); backdrop-filter: blur(2px); animation: fade .9s ease forwards; }
.flash .seal { width: 116px; height: 116px; border-radius: 50%; background: radial-gradient(120% 120% at 30% 20%, #43e08c, #0e9b54); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 58px;
  box-shadow: 0 0 0 0 rgba(46,212,127,.5); animation: seal .7s cubic-bezier(.2,.9,.2,1); }

/* ====== кабинет директора ====== */
.admin { min-height: 100vh; display: flex; flex-direction: column; }
.admin-top { display: flex; align-items: center; justify-content: space-between; background: var(--dark-grad); color: #fff; padding: 18px 22px; padding-top: max(18px, env(safe-area-inset-top)); }
.admin-top .brand { font-size: 19px; font-weight: 750; }
.admin-top .logout { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08); color: #eaf2ed; padding: 9px 16px; border-radius: 11px; font-weight: 650; cursor: pointer; transition: background .15s ease; }
.admin-top .logout:hover { background: rgba(255,255,255,.16); }
.tabs { display: flex; gap: 6px; padding: 12px 16px; background: rgba(255,255,255,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 0; z-index: 5; }
.tab { border: none; background: transparent; color: var(--muted); padding: 9px 16px; border-radius: 999px; font-size: 15px; font-weight: 650; white-space: nowrap; cursor: pointer; transition: background .18s ease, color .18s ease, transform .1s ease; }
.tab:hover { background: #eef3ef; color: var(--ink); }
.tab:active { transform: scale(.96); }
.tab.active { background: var(--primary-grad); color: #fff; box-shadow: 0 10px 22px -10px rgba(18,168,92,.6); }
.tab.active:hover { color: #fff; }
.admin-main { padding: 22px; max-width: 980px; width: 100%; margin: 0 auto; }
.admin-main h2 { font-size: 19px; margin: 26px 0 13px; }
.admin-main h2:first-child { margin-top: 6px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.stat-card { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 19px; box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-card.accent { background: var(--primary-grad); border-color: transparent; color: #fff; box-shadow: 0 18px 38px -16px rgba(18,168,92,.6); }
.stat-card.warn { background: var(--warn-bg); border-color: #f0dcaf; }
.stat-num { font-size: 34px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; opacity: .72; margin-top: 7px; font-weight: 500; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar input { flex: 1; min-width: 180px; }
.filter-bar select { width: auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.toolbar h2 { margin: 0 !important; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .2s ease; }
.row-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.avatar { width: 52px; height: 52px; border-radius: 16px; object-fit: cover; background: var(--line); flex-shrink: 0; }
.row-info { flex: 1; min-width: 0; }
.row-name { font-weight: 700; }
.row-sub { color: var(--muted); font-size: 14px; }
.row-badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; }
.row-time { color: var(--muted); font-size: 14px; font-weight: 650; white-space: nowrap; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(7,18,13,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 20px; z-index: 100; overflow-y: auto; animation: fadein .2s ease; }
.modal { background: var(--panel); color: var(--ink); border-radius: 26px; padding: 26px; width: 100%; max-width: 440px; margin: auto;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.6); animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.modal h2 { margin: 0 0 16px !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.report-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-controls label { font-size: 13px; font-weight: 650; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.report-controls input { width: auto; }
.report-summary { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 15px; text-align: left; white-space: nowrap; }
thead th { background: #f3f7f4; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
tbody tr { border-bottom: 1px solid var(--line); transition: background .12s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7faf8; }
td.late { color: var(--err); font-weight: 700; }
td.empty { text-align: center; }

.grid-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .2s ease; }
.photo-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #000; }
.photo-card .cap { padding: 9px 11px; font-size: 12px; color: var(--muted); font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 18px; }
.form-grid label { font-size: 13px; font-weight: 650; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.saved-note { color: var(--ok); font-weight: 650; margin-left: 12px; }

/* регистрация лица */
.enroll { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.enroll-cam { width: min(70vw, 260px); aspect-ratio: 1; border-radius: 26px; overflow: hidden; background: #000; box-shadow: var(--shadow); }
.enroll-cam video, .enroll-cam img { width: 100%; height: 100%; object-fit: cover; }
.enroll-cam video { transform: scaleX(-1); }

/* карта выбора офиса */
.map-pick { height: 300px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); margin: 10px 0; }
.map-search { display: flex; gap: 8px; margin-bottom: 4px; }
.map-search input { flex: 1; }
.leaflet-container { font: inherit; }

/* выходные / праздники */
.dayoff-banner { background: var(--warn-bg); border: 1px solid #f0dcaf; color: #8a6516; padding: 13px 16px; border-radius: var(--radius); margin-bottom: 14px; font-weight: 650; }
.weekday-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.wd { width: 48px; height: 46px; border: 1px solid var(--line); background: #f5f8f5; border-radius: 13px; font-weight: 700; cursor: pointer; color: var(--muted); transition: transform .1s ease; }
.wd:active { transform: scale(.94); }
.wd.off { background: var(--warn-bg); border-color: #ecc97e; color: #8a6516; }
.hol-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hol-add input[type="date"] { width: auto; }
.hol-add input:not([type="date"]) { flex: 1; min-width: 160px; }
.hol-add .mini { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 650; }
.hol-add .mini input { width: auto; }

/* карта слежения */
.map-live { height: 380px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); margin: 10px 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.track-note { font-size: 14px; color: #86efac; max-width: 320px; }

/* — анимации — */
@keyframes aura { 0%, 100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.08); opacity: .15; } }
@keyframes pop { from { transform: translateX(-50%) translateY(12px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade { 0% { opacity: 0; } 18% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes seal { 0% { transform: scale(.4) rotate(-12deg); opacity: 0; } 55% { transform: scale(1.12) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
