/* ===== Tvlmedia HRMS – design tokens ===== */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --line: #e6e9f0;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef0ff;
  --brand-ink: #ffffff;
  --side: #0f172a;
  --side-2: #1e293b;
  --side-text: #cbd5e1;
  --ok: #059669;  --ok-soft: #e7f8f1;
  --warn: #b45309; --warn-soft: #fef4e2;
  --bad: #dc2626; --bad-soft: #fdecec;
  --info: #0284c7; --info-soft: #e6f4fb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --text: #e5e7eb; --text-2: #a3aec2;
    --muted: #64748b; --line: #1f2937; --brand: #818cf8; --brand-2: #6366f1; --brand-soft: #1e1b4b;
    --brand-ink: #0b1120; --side: #060b16; --side-2: #111827;
    --ok: #34d399; --ok-soft: #052e22; --warn: #fbbf24; --warn-soft: #3a2a06;
    --bad: #f87171; --bad-soft: #3b1111; --info: #38bdf8; --info-soft: #082f49;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.icon { flex: none; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 22px; color: #fff; text-decoration: none !important; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; color: #fff; }
.brand-text small { font-size: 12px; color: #94a3b8; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 6px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--side-text); font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--side-2); color: #fff; }
.nav-item.active { background: rgba(99, 102, 241, .18); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.nav-item.active .icon { color: #a5b4fc; }
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px;
  border-top: 1px solid rgba(148, 163, 184, .15);
}
.sidebar-foot .who { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.sidebar-foot .who strong { color: #fff; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who small { color: #94a3b8; font-size: 12px; }
.logout { color: #94a3b8; padding: 6px; border-radius: 8px; display: grid; }
.logout:hover { color: #fff; background: var(--side-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { font-size: 21px; font-weight: 700; }
.topbar p { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }
.today { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; }
.content { padding: 26px 32px 56px; max-width: 1320px; width: 100%; }
.scrim { display: none; }

/* ===== Cards & layout ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 18px 20px 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid2 > .card { margin-bottom: 0; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.subcard { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface-2); }
.subcard p { margin: 0 0 10px; font-size: 13px; }

/* ===== KPI tiles ===== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; display: flex; gap: 14px; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-icon.i-brand { background: var(--brand-soft); color: var(--brand); }
.kpi-icon.i-ok { background: var(--ok-soft); color: var(--ok); }
.kpi-icon.i-info { background: var(--info-soft); color: var(--info); }
.kpi-icon.i-warn { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.i-bad { background: var(--bad-soft); color: var(--bad); }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }

/* ===== Forms ===== */
label { display: block; margin-bottom: 12px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
label input, label select { display: block; margin-top: 6px; width: 100%; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-weight: 400; font-size: 13.5px; }
label.check input { width: auto; margin: 0; accent-color: var(--brand); }
input, select {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=file] { padding: 8px; background: var(--surface-2); width: 100%; }
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--brand); color: #fff; text-decoration: none !important; transition: filter .15s, background .15s;
  white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); filter: none; }
button.danger { background: var(--bad); }
button.small, .btn.small { padding: 6px 11px; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters label { margin: 0; min-width: 150px; }
.filters .grow { flex: 1; }
.filters label input, .filters label select { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-weight: 500; text-decoration: none !important; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.inline-form .card-head { width: 100%; margin: 0; }
.inline-form label { margin: 0; min-width: 220px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600; background: var(--surface-2); }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.muted td { color: var(--muted); }
td.num, th.num { text-align: right; }
.person { display: flex; align-items: center; gap: 10px; }
.person .nm { font-weight: 600; color: var(--text); }
.person .id { font-size: 12px; color: var(--muted); }
.time { font-weight: 600; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); }
.empty .icon { color: var(--muted); margin-bottom: 8px; }

/* ===== Avatars, badges ===== */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12.5px;
  font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar.a0 { background: #e0e7ff; color: #4338ca; } .avatar.a1 { background: #dcfce7; color: #15803d; }
.avatar.a2 { background: #fef3c7; color: #b45309; } .avatar.a3 { background: #fce7f3; color: #be185d; }
.avatar.a4 { background: #e0f2fe; color: #0369a1; } .avatar.a5 { background: #ede9fe; color: #6d28d9; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.plain { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.pill.plain::before { display: none; }

/* ===== Notices ===== */
.notice, .error { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin: 0 0 18px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid transparent; font-weight: 500; }
.notice.bad, .error { background: var(--bad-soft); color: var(--bad); }
.notice ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }

/* ===== Devices ===== */
.device-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.device-title { display: flex; align-items: center; gap: 14px; }
.device-title .kpi-icon { width: 48px; height: 48px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.facts > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.facts dt { font-size: 11.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.facts dd { margin: 4px 0 0; font-weight: 600; }
.row-forms { display: flex; flex-wrap: wrap; gap: 10px; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
details[open] summary::before { transform: rotate(45deg); }
details[open] summary { margin-bottom: 14px; }
.subcard input { width: 100%; margin-bottom: 10px; }

/* ===== Login / install ===== */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #ddd6fe 0, transparent 60%), var(--bg); }
@media (prefers-color-scheme: dark) {
  body.login { background: radial-gradient(1200px 600px at 10% -10%, #1e1b4b 0, transparent 60%), var(--bg); }
}
.login-card { width: 100%; max-width: 410px; padding: 32px; border-radius: 18px; box-shadow: 0 20px 50px rgba(15, 23, 42, .12); }
.login-card.wide { max-width: 560px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 44px; height: 44px; font-size: 20px; }
.login-card h1 { font-size: 22px; font-weight: 700; }
.login-card .lead { color: var(--text-2); margin: 4px 0 22px; }
.login-card h2 { margin: 22px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.login-card button, .login-card .btn { width: 100%; margin-top: 8px; padding: 11px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--muted); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 20; }
  .menu-btn { display: grid; }
  .topbar { padding: 14px 16px; }
  .today span { display: none; }
  .content { padding: 18px 16px 48px; }
  th, td { padding: 10px 12px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; flex-direction: column; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; }
  .kpi-value { font-size: 22px; }
  .filters label { min-width: calc(50% - 7px); flex: 1; }
  .filters button { width: 100%; }
  .topbar h1 { font-size: 18px; }
  .card-head input[type=search] { width: 100% !important; }
}

/* ===== Two-column page (list + side forms) ===== */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
