/* =====================================================================
   Astro HR design system
   One stylesheet for every page: app shell, components, role themes,
   light/dark mode (Bootstrap 5.3 data-bs-theme) and print.
   ===================================================================== */

:root {
  --brand: #0f766e;            /* teal 700 */
  --brand-600: #0d9488;
  --brand-50: #e6f6f4;
  --navy: #0f1d33;
  --accent: #0f766e;           /* changed per role, see body.role-* */
  --accent-rgb: 15, 118, 110;
  --accent-soft: rgba(var(--accent-rgb), .10);
  --accent-ink: #0b5e58;

  --ok: #15803d;      --ok-bg: #e8f6ee;
  --warn: #b45309;    --warn-bg: #fff4e0;
  --bad: #be123c;     --bad-bg: #fdecef;
  --info: #0369a1;    --info-bg: #e5f3fb;
  --muted-bg: #eef1f5;

  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --page: #f2f5f9;
  --line: #e3e8ef;
  --ink: #12213a;
  --ink-2: #4a5872;
  --ink-3: #7b879c;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px -12px rgba(16, 24, 40, .25);

  --sidebar-w: 264px;
  --sidebar-w-mini: 76px;
  --topbar-h: 64px;
  --font: "Inter", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bs-body-font-family: var(--font);
  --bs-border-radius: 10px;
  --bs-link-color-rgb: var(--accent-rgb);
  --bs-link-hover-color-rgb: var(--accent-rgb);
}

/* Role accents: admin violet, HR staff teal, manager/moderator sky, employee blue */
body.role-admin      { --accent: #6d28d9; --accent-rgb: 109, 40, 217; --accent-ink: #5b21b6; }
body.role-supervisor { --accent: #0f766e; --accent-rgb: 15, 118, 110; --accent-ink: #0b5e58; }
body.role-manager,
body.role-moderator  { --accent: #0369a1; --accent-rgb: 3, 105, 161;  --accent-ink: #075985; }
body.role-user       { --accent: #2563eb; --accent-rgb: 37, 99, 235;  --accent-ink: #1d4ed8; }

[data-bs-theme="dark"] {
  --surface: #131c2b;
  --surface-2: #182233;
  --page: #0c1320;
  --line: #243149;
  --ink: #e6ecf5;
  --ink-2: #a9b5c8;
  --ink-3: #7d8aa1;
  --muted-bg: #1d2839;
  --ok-bg: rgba(34, 197, 94, .14);   --ok: #4ade80;
  --warn-bg: rgba(245, 158, 11, .15); --warn: #fbbf24;
  --bad-bg: rgba(244, 63, 94, .15);  --bad: #fb7185;
  --info-bg: rgba(56, 189, 248, .14); --info: #7dd3fc;
  --brand-50: rgba(20, 184, 166, .12);
  --accent-soft: rgba(var(--accent-rgb), .22);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --bs-body-bg: var(--page);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-tertiary-bg: var(--surface-2);
}
[data-bs-theme="dark"] body.role-admin      { --accent: #a78bfa; --accent-rgb: 167, 139, 250; --accent-ink: #c4b5fd; }
[data-bs-theme="dark"] body.role-supervisor { --accent: #2dd4bf; --accent-rgb: 45, 212, 191;  --accent-ink: #5eead4; }
[data-bs-theme="dark"] body.role-manager,
[data-bs-theme="dark"] body.role-moderator  { --accent: #38bdf8; --accent-rgb: 56, 189, 248;  --accent-ink: #7dd3fc; }
[data-bs-theme="dark"] body.role-user       { --accent: #60a5fa; --accent-rgb: 96, 165, 250;  --accent-ink: #93c5fd; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  font-size: .9rem;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
.text-muted, .text-body-secondary { color: var(--ink-3) !important; }
.text-accent { color: var(--accent) !important; }
.fw-semi { font-weight: 600; }
.small-caps { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
::selection { background: rgba(var(--accent-rgb), .25); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------------------------------------------------------- buttons */
.btn { font-weight: 600; border-radius: 10px; font-size: .86rem; }
.btn-sm { border-radius: 8px; font-size: .8rem; }
.btn-primary {
  --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-ink); --bs-btn-hover-border-color: var(--accent-ink);
  --bs-btn-active-bg: var(--accent-ink); --bs-btn-active-border-color: var(--accent-ink);
  --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-primary {
  --bs-btn-color: var(--accent); --bs-btn-border-color: rgba(var(--accent-rgb), .45);
  --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-bg: var(--accent); --bs-btn-active-border-color: var(--accent);
}
.btn-soft {
  background: var(--accent-soft); color: var(--accent-ink); border: 0;
}
.btn-soft:hover { background: rgba(var(--accent-rgb), .18); color: var(--accent-ink); }
[data-bs-theme="dark"] .btn-soft { color: var(--accent); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border-radius: 9px; }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-danger-soft { background: var(--bad-bg); color: var(--bad); border: 0; }
.btn-danger-soft:hover { background: var(--bad); color: #fff; }

.form-control, .form-select {
  border-radius: 10px; border-color: var(--line); background-color: var(--surface);
  font-size: .88rem; padding: .5rem .75rem; color: var(--ink);
}
.form-control:focus, .form-select:focus {
  border-color: rgba(var(--accent-rgb), .6);
  box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb), .15);
}
.form-label { font-weight: 600; font-size: .8rem; color: var(--ink-2); margin-bottom: .3rem; }
.form-label .req { color: var(--bad); margin-left: 2px; }
.form-text { color: var(--ink-3); font-size: .76rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb), .15); border-color: rgba(var(--accent-rgb), .6); }
.input-group-text { background: var(--surface-2); border-color: var(--line); color: var(--ink-3); border-radius: 10px; }
.invalid-feedback, .field-error { color: var(--bad); font-size: .76rem; margin-top: .25rem; display: block; }

/* ---------------------------------------------------------------- shell */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: width .2s ease, transform .25s ease;
}
.sidebar::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand-600), var(--accent));
}
.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: .7rem;
  padding: 0 1.1rem; border-bottom: 1px solid var(--line); flex-shrink: 0; text-decoration: none;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1rem;
  background: linear-gradient(135deg, var(--brand-600), var(--accent));
  box-shadow: 0 6px 14px -6px rgba(var(--accent-rgb), .7);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.brand-text { line-height: 1.1; min-width: 0; }
.brand-text strong { display: block; color: var(--ink); font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--ink-3); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .65rem 1rem; scrollbar-width: thin; }
.nav-section {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); padding: .9rem .7rem .35rem; white-space: nowrap;
}
.nav-item-x {
  display: flex; align-items: center; gap: .75rem; padding: .52rem .7rem; margin: 1px 0;
  border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .86rem;
  white-space: nowrap; position: relative;
}
.nav-item-x i { font-size: 1.08rem; width: 22px; text-align: center; color: var(--ink-3); flex-shrink: 0; }
.nav-item-x:hover { background: var(--surface-2); color: var(--ink); }
.nav-item-x.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
[data-bs-theme="dark"] .nav-item-x.active { color: var(--accent); }
.nav-item-x.active i { color: var(--accent); }
.nav-item-x .nav-badge {
  margin-left: auto; font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px;
  background: var(--bad); color: #fff;
}
button.nav-item-x { width: 100%; border: 0; background: transparent; text-align: left; font-family: inherit; cursor: pointer; }
.nav-group > .nav-item-x .chev { margin-left: auto; font-size: .75rem; transition: transform .2s; width: auto; }
.nav-group > .nav-item-x .nav-badge + .chev { margin-left: .4rem; }
.nav-group.has-active > .nav-item-x { color: var(--ink); font-weight: 600; }
.nav-group.has-active > .nav-item-x > i:first-child { color: var(--accent); }
.nav-group.open > .nav-item-x .nav-badge { display: none; }
.nav-group.open > .nav-item-x .chev { transform: rotate(90deg); }
.nav-sub { display: none; padding: .1rem 0 .35rem 1.6rem; margin-left: 1.05rem; border-left: 1px dashed var(--line); }
.nav-group.open > .nav-sub { display: block; }
.nav-sub .nav-item-x { font-size: .82rem; padding: .42rem .7rem; }
.nav-sub .nav-item-x::before {
  content: ""; position: absolute; left: calc(-1.6rem - 4px); top: 50%; width: 6px; height: 6px; border-radius: 50%;
  background: var(--line); transform: translateY(-50%);
}
.nav-sub .nav-item-x.active::before { background: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--line); padding: .75rem 1rem; font-size: .72rem; color: var(--ink-3);
  display: flex; align-items: center; gap: .5rem; flex-shrink: 0;
}

.main {
  flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .2s ease;
  display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.4rem;
  background: rgba(255, 255, 255, .86); backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
[data-bs-theme="dark"] .topbar { background: rgba(19, 28, 43, .86); }
.topbar-title { min-width: 0; }
.topbar-title .crumb { font-size: .72rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.topbar-title .now { font-weight: 700; color: var(--ink); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .btn-icon { color: var(--ink-2); background: transparent; border: 1px solid transparent; position: relative; }
.topbar .btn-icon:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.topbar .dot-count {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--bad); color: #fff; font-size: .6rem; font-weight: 700; display: grid; place-items: center;
}
.user-chip {
  display: flex; align-items: center; gap: .55rem; padding: .25rem .35rem .25rem .25rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink);
}
.user-chip:hover { border-color: rgba(var(--accent-rgb), .4); color: var(--ink); }
.user-chip .meta { line-height: 1.1; padding-right: .35rem; }
.user-chip .meta b { font-size: .8rem; display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta small { font-size: .66rem; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; }

.content { padding: 1.4rem 1.4rem 2.5rem; flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; }
.app-foot { padding: 1rem 1.4rem; font-size: .75rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; }

/* collapsed desktop sidebar */
@media (min-width: 992px) {
  body.sidebar-mini .sidebar { width: var(--sidebar-w-mini); }
  body.sidebar-mini .main { margin-left: var(--sidebar-w-mini); }
  body.sidebar-mini .brand-text, body.sidebar-mini .nav-section, body.sidebar-mini .nav-item-x span,
  body.sidebar-mini .nav-item-x .chev, body.sidebar-mini .nav-badge, body.sidebar-mini .sidebar-foot span,
  body.sidebar-mini .nav-sub { display: none !important; }
  body.sidebar-mini .nav-item-x { justify-content: center; padding: .6rem; }
  body.sidebar-mini .sidebar-brand { justify-content: center; padding: 0; }
  body.sidebar-mini .sidebar:hover { width: var(--sidebar-w); box-shadow: var(--shadow-lg); }
  body.sidebar-mini .sidebar:hover .brand-text, body.sidebar-mini .sidebar:hover .nav-section,
  body.sidebar-mini .sidebar:hover .nav-item-x span, body.sidebar-mini .sidebar:hover .nav-item-x .chev,
  body.sidebar-mini .sidebar:hover .sidebar-foot span { display: initial !important; }
  body.sidebar-mini .sidebar:hover .nav-section { display: block !important; }
  body.sidebar-mini .sidebar:hover .nav-group.open > .nav-sub { display: block !important; }
  body.sidebar-mini .sidebar:hover .nav-item-x { justify-content: flex-start; padding: .52rem .7rem; }
  body.sidebar-mini .sidebar:hover .sidebar-brand { justify-content: flex-start; padding: 0 1.1rem; }
}

/* mobile drawer */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1035; background: rgba(8, 15, 28, .45);
  }
  .main { margin-left: 0; }
  .topbar { padding: 0 .9rem; }
  .content { padding: 1rem 1rem 2rem; }
  .user-chip .meta { display: none; }
}

/* employee bottom tab bar */
.tabbar { display: none; }
@media (max-width: 767.98px) {
  body.has-tabbar .content { padding-bottom: 90px; }
  body.has-tabbar .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 18px -12px rgba(0, 0, 0, .25);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none;
    color: var(--ink-3); font-size: .66rem; font-weight: 600; padding: .3rem 0; border-radius: 10px;
  }
  .tabbar a i { font-size: 1.25rem; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a.active i { transform: translateY(-1px); }
}

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; margin: 0; display: flex; align-items: center; gap: .6rem; }
.page-head h1 .ph-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem;
  background: var(--accent-soft); color: var(--accent);
}
.page-head p { margin: .3rem 0 0; color: var(--ink-3); font-size: .86rem; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 575.98px) {
  .page-head h1 { font-size: 1.2rem; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
}

/* ---------------------------------------------------------------- cards */
.card-x {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.card-x + .card-x { margin-top: 1rem; }
.card-x-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .95rem 1.15rem; border-bottom: 1px solid var(--line);
}
.card-x-head h2, .card-x-head h3, .card-x-head h5 { font-size: .98rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.card-x-head h2 i, .card-x-head h3 i, .card-x-head h5 i { color: var(--accent); }
.card-x-head .sub { font-size: .76rem; color: var(--ink-3); font-weight: 500; }
.card-x-body { padding: 1.15rem; }
.card-x-foot { padding: .8rem 1.15rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-x.flush .card-x-body { padding: 0; }

/* ---------------------------------------------------------------- KPI tiles */
.kpi-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin-bottom: 1.25rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .95rem 1rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: flex; gap: .75rem; align-items: center; text-decoration: none; color: inherit; min-width: 0;
}
a.kpi:hover { border-color: rgba(var(--accent-rgb), .35); color: inherit; transform: translateY(-1px); }
.kpi .kpi-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
}
.kpi .kpi-val { font-size: 1.55rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi .kpi-label { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
.kpi .kpi-note { font-size: .72rem; color: var(--ink-3); margin-top: .15rem; }
.kpi.ok .kpi-icon { background: var(--ok-bg); color: var(--ok); }
.kpi.warn .kpi-icon { background: var(--warn-bg); color: var(--warn); }
.kpi.bad .kpi-icon { background: var(--bad-bg); color: var(--bad); }
.kpi.info .kpi-icon { background: var(--info-bg); color: var(--info); }
.kpi.muted .kpi-icon { background: var(--muted-bg); color: var(--ink-2); }

/* compact stat chips (filters / summaries) */
.stat-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.stat-chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); font-size: .8rem; font-weight: 600; color: var(--ink-2);
  text-decoration: none;
}
.stat-chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-chip.active, .stat-chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* ---------------------------------------------------------------- hero / welcome */
.hero-x {
  border-radius: calc(var(--radius) + 4px); padding: 1.4rem 1.5rem; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--navy) 0%, #12345a 45%, var(--accent) 140%);
  margin-bottom: 1.25rem; box-shadow: var(--shadow-lg);
}
.hero-x::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 65%);
}
.hero-x h1, .hero-x h2 { color: #fff; margin: 0; font-size: 1.4rem; }
.hero-x p { color: rgba(255, 255, 255, .78); margin: .35rem 0 0; }
.hero-x .hero-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; position: relative; z-index: 1; }
.hero-x .pill {
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); color: #fff;
  border-radius: 99px; padding: .3rem .75rem; font-size: .78rem; font-weight: 600; display: inline-flex; gap: .4rem; align-items: center;
}
.hero-x .btn-light { color: var(--navy); }

/* ---------------------------------------------------------------- tables */
.table-x { width: 100%; margin: 0; --bs-table-bg: transparent; color: var(--ink); font-size: .85rem; }
.table-x > thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--ink-3);
  background: var(--surface-2); border-bottom: 1px solid var(--line); padding: .7rem .85rem; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table-x > tbody td { padding: .7rem .85rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-x > tbody tr:last-child td { border-bottom: 0; }
.table-x > tbody tr:hover td { background: var(--surface-2); }
.table-x th.sortable { cursor: pointer; user-select: none; }
.table-x th.sortable::after { content: " \2195"; opacity: .35; font-size: .8em; }
.table-x th.sort-asc::after { content: " \2191"; opacity: .9; }
.table-x th.sort-desc::after { content: " \2193"; opacity: .9; }
.table-x tfoot td { padding: .7rem .85rem; font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 70vh; }
.cell-main { font-weight: 600; color: var(--ink); line-height: 1.2; }
.cell-sub { font-size: .75rem; color: var(--ink-3); }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: nowrap; }
.row-actions form { display: inline; margin: 0; }

.table-tools {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between;
  padding: .8rem 1.15rem; border-bottom: 1px solid var(--line);
}
.table-tools .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.table-tools .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.table-tools .search input { padding-left: 2.1rem; }
.table-pager {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between;
  padding: .7rem 1.15rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-3);
}
.table-pager .pg { display: flex; gap: .25rem; }
.table-pager .pg button {
  min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-weight: 600; font-size: .78rem; padding: 0 .5rem;
}
.table-pager .pg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.table-pager .pg button:disabled { opacity: .45; }

/* mobile: turn data tables into cards */
@media (max-width: 767.98px) {
  table.table-x.stack thead { display: none; }
  table.table-x.stack, table.table-x.stack tbody, table.table-x.stack tr, table.table-x.stack td { display: block; width: 100%; }
  table.table-x.stack tr { border-bottom: 1px solid var(--line); padding: .6rem .9rem; }
  table.table-x.stack td { border: 0; padding: .22rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.table-x.stack td::before {
    content: attr(data-label); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
    font-weight: 700; text-align: left; flex-shrink: 0;
  }
  table.table-x.stack td[data-label=""]::before, table.table-x.stack td:not([data-label])::before { content: none; }
  table.table-x.stack td.td-main { display: block; text-align: left; }
  table.table-x.stack td.td-main::before { content: none; }
  table.table-x.stack .row-actions { justify-content: flex-start; }
}

/* ---------------------------------------------------------------- badges & chips */
.badge-x {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 99px;
  font-size: .72rem; font-weight: 700; white-space: nowrap; background: var(--muted-bg); color: var(--ink-2);
  line-height: 1.3;
}
.badge-x.ok { background: var(--ok-bg); color: var(--ok); }
.badge-x.warn { background: var(--warn-bg); color: var(--warn); }
.badge-x.bad { background: var(--bad-bg); color: var(--bad); }
.badge-x.info { background: var(--info-bg); color: var(--info); }
.badge-x.accent { background: var(--accent-soft); color: var(--accent-ink); }
[data-bs-theme="dark"] .badge-x.accent { color: var(--accent); }
.badge-x .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-3); flex-shrink: 0; }
.status-dot.on { background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulse 2s infinite; }
.status-dot.off { background: #94a3b8; }
.status-dot.warn { background: #f59e0b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); } 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }

/* attendance status codes (daily list, monthly sheet, calendar) */
.att { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 .3rem; border-radius: 6px; font-size: .7rem; font-weight: 800; background: var(--muted-bg); color: var(--ink-2); }
.att-PRESENT, .att-P { background: var(--ok-bg); color: var(--ok); }
.att-LATE, .att-L { background: var(--warn-bg); color: var(--warn); }
.att-HALF_DAY, .att-HD { background: #fdf0e1; color: #c2410c; }
.att-MISSING_OUT, .att-MO { background: #f3e8ff; color: #7e22ce; }
.att-ABSENT, .att-A { background: var(--bad-bg); color: var(--bad); }
.att-ON_LEAVE, .att-LV { background: var(--info-bg); color: var(--info); }
.att-HOLIDAY, .att-H { background: #fef9c3; color: #a16207; }
.att-WEEKEND, .att-W { background: var(--muted-bg); color: var(--ink-3); }
[data-bs-theme="dark"] .att-HALF_DAY, [data-bs-theme="dark"] .att-HD { background: rgba(249, 115, 22, .16); color: #fdba74; }
[data-bs-theme="dark"] .att-MISSING_OUT, [data-bs-theme="dark"] .att-MO { background: rgba(168, 85, 247, .18); color: #d8b4fe; }
[data-bs-theme="dark"] .att-HOLIDAY, [data-bs-theme="dark"] .att-H { background: rgba(234, 179, 8, .16); color: #fde047; }

/* monthly sheet grid */
.sheet { border-collapse: separate; border-spacing: 0; font-size: .74rem; width: 100%; }
.sheet th, .sheet td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: .3rem .25rem; text-align: center; white-space: nowrap; }
.sheet thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; font-weight: 700; color: var(--ink-3); font-size: .68rem; }
.sheet thead th.we { color: var(--bad); }
.sheet .emp { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; min-width: 190px; padding: .35rem .6rem; }
.sheet thead .emp { z-index: 3; background: var(--surface-2); }
.sheet .tot { font-weight: 800; background: var(--surface-2); }
.sheet tr:hover td { background: var(--surface-2); }
.sheet tr:hover .emp { background: var(--surface-2); }

/* calendar (employee self-service) */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; }
.cal .dow { font-size: .68rem; text-transform: uppercase; color: var(--ink-3); font-weight: 700; text-align: center; padding-bottom: .2rem; }
.cal .day {
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: .45rem; min-height: 74px;
  display: flex; flex-direction: column; gap: .2rem; font-size: .72rem;
}
.cal .day .n { font-weight: 800; font-size: .85rem; color: var(--ink); }
.cal .day.blank { border: 0; background: transparent; }
.cal .day.today { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .2); }
.cal .day .t { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal .day.st-ABSENT { background: var(--bad-bg); border-color: transparent; }
.cal .day.st-PRESENT { background: var(--ok-bg); border-color: transparent; }
.cal .day.st-LATE { background: var(--warn-bg); border-color: transparent; }
.cal .day.st-ON_LEAVE { background: var(--info-bg); border-color: transparent; }
.cal .day.st-HOLIDAY { background: #fef9c3; border-color: transparent; }
.cal .day.st-WEEKEND { background: var(--muted-bg); border-color: transparent; }
[data-bs-theme="dark"] .cal .day.st-HOLIDAY { background: rgba(234, 179, 8, .14); }
@media (max-width: 575.98px) {
  .cal { gap: .25rem; }
  .cal .day { min-height: 54px; padding: .3rem; border-radius: 9px; }
  .cal .day .t { display: none; }
}

/* ---------------------------------------------------------------- avatars */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  font-weight: 700; font-size: .8rem; color: var(--accent-ink); background: var(--accent-soft); overflow: hidden;
}
[data-bs-theme="dark"] .avatar { color: var(--accent); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.8rem; }
.person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.person .who { min-width: 0; }

/* ---------------------------------------------------------------- filters */
.filter-bar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.filter-bar .row { --bs-gutter-y: .75rem; }
.filter-bar .form-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

/* form sections */
.form-section { padding: 1.15rem; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin-bottom: .9rem; display: flex; gap: .45rem; align-items: center; }
.form-section h6 i { color: var(--accent); font-size: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; padding: 1rem 1.15rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; }

.photo-drop {
  width: 140px; height: 160px; border-radius: 14px; border: 2px dashed var(--line); background: var(--surface-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--ink-3); cursor: pointer; text-align: center; font-size: .75rem;
}
.photo-drop:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- lists & feeds */
.list-x { list-style: none; margin: 0; padding: 0; }
.list-x > li { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.15rem; border-bottom: 1px solid var(--line); }
.list-x > li:last-child { border-bottom: 0; }
.list-x .grow { flex: 1; min-width: 0; }
.feed-item.new { animation: flashIn 1.6s ease; }
@keyframes flashIn { from { background: var(--accent-soft); } to { background: transparent; } }
.time-tag { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .8rem; color: var(--ink); }

.date-tile {
  width: 46px; border-radius: 10px; overflow: hidden; text-align: center; flex-shrink: 0; border: 1px solid var(--line);
}
.date-tile .m { background: var(--accent); color: #fff; font-size: .62rem; font-weight: 700; text-transform: uppercase; padding: 1px 0; }
.date-tile .d { font-weight: 800; font-size: 1.05rem; padding: 2px 0; color: var(--ink); background: var(--surface); }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .6rem; color: var(--line); }
.empty-state h6 { color: var(--ink-2); margin-bottom: .25rem; }

.progress-x { height: 8px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; }
.progress-x > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: .45rem 1rem; font-size: .86rem; margin: 0; }
.kv dt { color: var(--ink-3); font-weight: 600; font-size: .78rem; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; word-break: break-word; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.chart-box.lg { height: 320px; }

/* ---------------------------------------------------------------- searchable selects (Tom Select) */
.ts-wrapper.form-select, .ts-wrapper.single { padding: 0; border: 0; background: none; box-shadow: none; }
.ts-wrapper .ts-control {
  border-radius: 10px; border: 1px solid var(--line); background-color: var(--surface); color: var(--ink);
  min-height: calc(1.5em + 1rem + 2px); padding: .5rem 2.25rem .5rem .75rem; font-size: .88rem; box-shadow: none;
}
.ts-wrapper.single .ts-control { background-image: none; }
.ts-wrapper.single .ts-control::after {
  content: ""; position: absolute; right: .85rem; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); transition: transform .15s;
}
.ts-wrapper.single.dropdown-active .ts-control::after { transform: rotate(225deg); margin-top: -1px; }
.ts-wrapper.focus .ts-control { border-color: rgba(var(--accent-rgb), .6); box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb), .15); }
.ts-wrapper.disabled .ts-control { opacity: .65; background-color: var(--surface-2); }
.ts-wrapper.form-select-sm .ts-control, .ts-wrapper.ts-sm .ts-control { min-height: 31px; padding: .25rem 2rem .25rem .6rem; font-size: .8rem; border-radius: 8px; }
.ts-wrapper .ts-control > input { color: var(--ink); }
.ts-wrapper .ts-control .item { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ts-dropdown {
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); margin-top: 4px; z-index: 1095; font-size: .86rem; overflow: hidden;
}
.ts-dropdown .dropdown-input-wrap { padding: .5rem; border-bottom: 1px solid var(--line); background: var(--surface-2); position: relative; }
.ts-dropdown .dropdown-input {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface) no-repeat .6rem center; color: var(--ink);
  padding: .4rem .6rem .4rem 2rem; font-size: .85rem; width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%237b879c' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
}
.ts-dropdown .dropdown-input:focus { outline: none; border-color: rgba(var(--accent-rgb), .6); box-shadow: 0 0 0 .15rem rgba(var(--accent-rgb), .15); }
.ts-dropdown .ts-dropdown-content { max-height: 280px; padding: .3rem; }
.ts-dropdown .option { border-radius: 8px; padding: .45rem .65rem; color: var(--ink); }
.ts-dropdown .option.active { background: var(--accent-soft); color: var(--accent-ink); }
[data-bs-theme="dark"] .ts-dropdown .option.active { color: var(--accent); }
.ts-dropdown .option.selected { font-weight: 600; }
.ts-dropdown .option[data-value=""] { color: var(--ink-3); }
.ts-dropdown .no-results { padding: .6rem .75rem; color: var(--ink-3); }
.ts-dropdown .highlight { background: rgba(var(--accent-rgb), .18); border-radius: 3px; color: inherit; }
.is-invalid + .ts-wrapper .ts-control, .ts-wrapper.is-invalid .ts-control { border-color: var(--bad); }

/* ---------------------------------------------------------------- toasts / alerts */
.toast-stack { position: fixed; top: calc(var(--topbar-h) + .75rem); right: 1rem; z-index: 1090; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); }
.toast-x {
  display: flex; gap: .65rem; align-items: flex-start; padding: .8rem .95rem; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: .85rem; animation: toastIn .25s ease;
  border-left: 4px solid var(--info);
}
.toast-x.ok { border-left-color: var(--ok); } .toast-x.ok i { color: var(--ok); }
.toast-x.bad { border-left-color: var(--bad); } .toast-x.bad i { color: var(--bad); }
.toast-x.warn { border-left-color: var(--warn); } .toast-x.warn i { color: var(--warn); }
.toast-x.info i { color: var(--info); }
.toast-x i { font-size: 1.1rem; margin-top: 1px; }
.toast-x .msg { flex: 1; color: var(--ink); }
.toast-x button { background: none; border: 0; color: var(--ink-3); padding: 0; line-height: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.alert-x { border-radius: 12px; padding: .8rem 1rem; font-size: .85rem; display: flex; gap: .6rem; align-items: flex-start; border: 1px solid transparent; }
.alert-x.ok { background: var(--ok-bg); color: var(--ok); }
.alert-x.bad { background: var(--bad-bg); color: var(--bad); }
.alert-x.warn { background: var(--warn-bg); color: var(--warn); }
.alert-x.info { background: var(--info-bg); color: var(--info); }

/* ---------------------------------------------------------------- misc */
.divider-text { display: flex; align-items: center; gap: .75rem; color: var(--ink-3); font-size: .75rem; margin: 1rem 0; }
.divider-text::before, .divider-text::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.tab-pills { display: inline-flex; gap: .25rem; background: var(--surface-2); padding: .25rem; border-radius: 12px; border: 1px solid var(--line); flex-wrap: wrap; }
.tab-pills a, .tab-pills button { border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: .8rem; padding: .38rem .8rem; border-radius: 9px; text-decoration: none; }
.tab-pills .on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }
[data-bs-theme="dark"] .tab-pills .on { color: var(--accent); }
.dropdown-menu { border-radius: 12px; border-color: var(--line); box-shadow: var(--shadow-lg); font-size: .86rem; padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .7rem; }
.dropdown-item i { width: 20px; color: var(--ink-3); }
.modal-content { border-radius: 16px; border-color: var(--line); background: var(--surface); }
.modal-header, .modal-footer { border-color: var(--line); }
.cmd-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .74rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .1rem .35rem; word-break: break-all; }
.live-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .72rem; font-weight: 700; color: var(--ok); text-transform: uppercase; letter-spacing: .06em; }
.hide-empty:empty { display: none; }
.min-w-0 { min-width: 0; }

/* ---------------------------------------------------------------- public pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--page); }
.auth-side {
  position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(140deg, #0b1628 0%, #0f2f4d 50%, #0f766e 120%);
}
.auth-side::before {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .25) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: linear-gradient(160deg, #000 10%, transparent 70%);
}
.auth-side > * { position: relative; }
.auth-side h1 { color: #fff; font-size: 2.1rem; line-height: 1.15; }
.auth-side p { color: rgba(255, 255, 255, .75); }
.auth-feature { display: flex; gap: .8rem; align-items: flex-start; margin-top: 1rem; }
.auth-feature i { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); font-size: 1.1rem; flex-shrink: 0; }
.auth-feature b { display: block; }
.auth-feature span { color: rgba(255, 255, 255, .7); font-size: .85rem; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .card-x { padding: 2rem; }
.auth-card h2 { font-size: 1.5rem; }
.auth-card .form-control { padding: .7rem .85rem; }
.auth-card .btn-primary { padding: .7rem; }
@media (max-width: 991.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

/* landing */
.lp-nav { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, .85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
[data-bs-theme="dark"] .lp-nav { background: rgba(12, 19, 32, .85); }
.lp-nav .inner { max-width: 1180px; margin: 0 auto; padding: .8rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.lp-wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.lp-hero { padding: 4.5rem 0 3.5rem; }
.lp-hero h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); line-height: 1.08; letter-spacing: -.03em; }
.lp-hero h1 .grad { background: linear-gradient(90deg, var(--brand-600), #2563eb); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-hero .lede { font-size: 1.08rem; color: var(--ink-2); max-width: 560px; }
.lp-eyebrow { display: inline-flex; gap: .45rem; align-items: center; font-size: .78rem; font-weight: 700; color: var(--brand); background: var(--brand-50); border-radius: 99px; padding: .3rem .8rem; }
.lp-section { padding: 3.5rem 0; }
.lp-section h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); letter-spacing: -.02em; }
.lp-feature { height: 100%; padding: 1.4rem; }
.lp-feature .ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem; background: var(--brand-50); color: var(--brand); margin-bottom: .9rem; }
[data-bs-theme="dark"] .lp-feature .ic { color: #2dd4bf; }
.lp-feature h5 { font-size: 1rem; }
.lp-feature p { color: var(--ink-2); font-size: .88rem; margin: 0; }
.mock { border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 1rem; }
.mock .bar { height: 10px; border-radius: 99px; background: var(--muted-bg); }
.lp-foot { border-top: 1px solid var(--line); padding: 2rem 0; color: var(--ink-3); font-size: .82rem; }

/* ---------------------------------------------------------------- print */
@media print {
  .sidebar, .topbar, .tabbar, .app-foot, .no-print, .toast-stack, .table-tools, .table-pager, .filter-bar { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff !important; color: #000; }
  .card-x { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .table-wrap { overflow: visible; max-height: none !important; }
  a[href]::after { content: none !important; }
}
