:root {
  --brand: #4F46E5; --brand-2: #7C3AED; --brand-soft: #EEF2FF;
  --bg: #F5F6FA; --card: #FFFFFF; --text: #1F2433; --muted: #6B7280; --line: #E6E8EF;
  --good: #059669; --good-soft: #D1FAE5; --warn: #B45309; --warn-soft: #FEF3C7; --bad: #DC2626; --bad-soft: #FEE2E2;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 17px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); } .sm { font-size: 12px; } .strong { font-weight: 600; color: var(--text); }
.center { text-align: center; margin: 16px 0; } .grow { flex: 1; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty.err, .err-text { color: var(--bad); }

/* ---------- layout ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: 240px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 14px; font-size: 19px; font-weight: 700; }
.brand b { color: var(--brand); }
.brand.big { font-size: 26px; padding: 0 0 6px; justify-content: center; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand.big .logo { width: 44px; height: 44px; font-size: 22px; border-radius: 12px; }
.side nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #3B4152; font-weight: 500; margin: 1px 0; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side nav svg { width: 19px; height: 19px; fill: currentColor; opacity: .85; flex: none; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #9AA0AE; padding: 16px 12px 6px; font-weight: 600; }
.side-foot { padding: 14px 20px; font-size: 12px; color: #9AA0AE; border-top: 1px solid var(--line); }
.content { margin-left: 240px; min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 10; background: rgba(245,246,250,.92); backdrop-filter: blur(8px); display: flex; align-items: center; gap: 14px; padding: 16px 28px; border-bottom: 1px solid var(--line); }
.top h1 { flex: 1; }
.top .menu { display: none; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
main { padding: 24px 28px 60px; max-width: 1400px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; height: 46px; font-size: 15px; }
.btn.primary { background: var(--brand); color: #fff; } .btn.primary:hover { background: #4338CA; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); } .btn.ghost:hover { border-color: #C9CCD8; }
.btn.good { background: var(--good); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-ghost { background: #fff; border-color: #F5C2C2; color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: #fff; border: 1px solid #D5D8E1; border-radius: 10px; padding: 9px 12px; min-height: 38px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79,70,229,.25); border-color: var(--brand); }
input[readonly] { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; }
.toolbar input[type=search] { min-width: 240px; }
.tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs a { padding: 8px 16px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs a.on { background: var(--brand); color: #fff; text-decoration: none; }
.back { display: inline-block; margin-bottom: 12px; font-weight: 600; }

/* ---------- cards & panels ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none !important; transition: transform .12s; }
.stat:hover { transform: translateY(-1px); border-color: #CBD0F5; }
.stat-l { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat-v small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.stat.good .stat-v { color: var(--good); } .stat.warn .stat-v { color: var(--warn); } .stat.bad .stat-v { color: var(--bad); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.narrow { max-width: 640px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.dot.a, .bar.a { background: var(--brand); } .dot.b, .bar.b { background: #A5B4FC; }
.bars { display: flex; gap: 10px; height: 220px; align-items: stretch; }
.bar-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; gap: 4px; justify-content: center; border-bottom: 1px solid var(--line); }
.bar { width: 40%; max-width: 28px; border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.bar-x { text-align: center; font-size: 12px; color: var(--muted); padding-top: 6px; white-space: nowrap; overflow: hidden; }

/* ---------- tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.panel .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 11px 14px; background: #FAFBFD; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #F0F1F5; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.dim td { opacity: .55; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 6px; }
.att-cell { display: flex; align-items: center; gap: 10px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; cursor: zoom-in; background: var(--bg); flex: none; }
.thumb.sm { width: 34px; height: 34px; border-radius: 8px; vertical-align: middle; }
.copy { background: var(--brand-soft); color: var(--brand); padding: 3px 8px; border-radius: 6px; cursor: copy; }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #EEF0F4; color: #4B5263; white-space: nowrap; }
.s-working, .s-active { background: var(--brand-soft); color: var(--brand); }
.s-done, .s-approved, .s-sent, .s-good { background: var(--good-soft); color: var(--good); }
.s-pending, .s-leave, .s-upcoming, .s-mailOff, .s-zipped, .s-new { background: var(--warn-soft); color: var(--warn); }
.s-absent, .s-rejected, .s-mailFailed, .s-error, .s-noManagers, .s-bad { background: var(--bad-soft); color: var(--bad); }
.s-off, .s-hidden, .s-cancelled, .s-completed { background: #EEF0F4; color: #6B7280; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--muted); }
.pill b { color: var(--text); margin-left: 4px; }

/* ---------- photos ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.grid > .empty { grid-column: 1 / -1; }
.ph { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: zoom-in; box-shadow: var(--shadow); }
.ph img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--bg); }
.ph figcaption { padding: 9px 11px; display: flex; flex-direction: column; gap: 1px; font-size: 12px; }
.ph figcaption b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph figcaption span { color: var(--muted); }
.ph em { font-style: normal; color: var(--brand); font-weight: 600; } .ph em.d { color: var(--good); }

/* ---------- profile ---------- */
.profile { display: flex; gap: 20px; align-items: flex-start; }
.avatar-lg { width: 84px; height: 84px; border-radius: 20px; object-fit: cover; flex: none; }
.avatar-lg.ph { display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 32px; font-weight: 800; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 20px; margin-top: 12px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }

/* ---------- forms / modals ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full, .form-grid .full { grid-column: 1 / -1; }
.field small { color: var(--muted); font-size: 12px; }
.lbl { font-size: 13px; font-weight: 600; color: #3B4152; }
.check { display: flex; align-items: center; gap: 8px; min-height: 38px; font-weight: 500; }
.check input { width: 18px; height: 18px; min-height: 0; }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 9px 12px; border-radius: 10px; margin: 14px 0 0; }
.layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.layer-bg { position: absolute; inset: 0; background: rgba(17,20,35,.45); }
.layer-box { position: relative; background: #fff; border-radius: 18px; width: min(620px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal-form { padding: 22px 24px; }
.modal-form.small { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.danger-zone { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.big-code { font-size: 24px; font-weight: 800; letter-spacing: .04em; color: var(--brand); font-family: ui-monospace, Consolas, monospace; }
.viewer .layer-bg { background: rgba(8,10,20,.92); }
.viewer .layer-box { background: transparent; box-shadow: none; width: auto; max-width: 92vw; display: contents; }
.viewer figure { position: relative; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.viewer img { max-width: 88vw; max-height: 80vh; border-radius: 10px; }
.viewer figcaption { color: #fff; text-align: center; } .viewer figcaption a { color: #C7D2FE; }
.v-close { position: fixed; top: 18px; right: 18px; z-index: 2; }
.v-nav { position: fixed; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 30px; cursor: pointer; }
.v-nav.prev { left: 18px; } .v-nav.next { right: 18px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1F2433; color: #fff; padding: 11px 18px; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: all .25s; font-weight: 500; max-width: 90vw; }
.toast.err { background: var(--bad); } .toast.show { opacity: 1; transform: none; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #E0E7FF, transparent), radial-gradient(900px 500px at 110% 110%, #EDE9FE, transparent), var(--bg); }
.auth-card { background: #fff; width: min(400px, 100%); padding: 32px 28px; border-radius: 22px; box-shadow: 0 20px 50px rgba(30,27,75,.12); display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-card > .muted { text-align: center; margin: 0 0 6px; }
.auth-card h2 { text-align: center; }

@media (max-width: 900px) {
  .side { transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .content { margin-left: 0; }
  .top { padding: 12px 16px; }
  .top .menu { display: block; }
  .who-name { display: none; }
  main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select, .toolbar input[type=search] { min-width: 0; flex: 1 1 150px; }
  .profile { flex-direction: column; }
}
