/* =====================================================================
   Attendance System - stylesheet
   Admin shell + clock terminal, no external dependencies.
   ===================================================================== */

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e3e8f0;
  --text:      #1a2233;
  --muted:     #6b7789;
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --primary-l: #eff4ff;
  --success:   #15803d;
  --success-l: #e8f6ed;
  --warn:      #b45309;
  --warn-l:    #fdf3e3;
  --danger:    #b91c1c;
  --danger-l:  #fdeceb;
  --info:      #0369a1;
  --info-l:    #e6f4fb;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --sidebar-w: 250px;
  --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 4px; font-size: .9em; }
.icon { flex: none; vertical-align: -3px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary); color: #fff;
  padding: .6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---- Shell ---------------------------------------------------------- */
.app { display: block; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #101828; color: #cbd5e1; overflow-y: auto; z-index: 30;
  display: flex; flex-direction: column; padding-bottom: 1.5rem;
}
.brand {
  display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: .5rem;
}
.brand-mark { font-size: 1.5rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; color: #fff; font-weight: 650; font-size: .95rem; }
.brand-text small { color: #93a2b8; font-weight: 400; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.nav-section { border: none; }
.nav-group {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 1rem 1.15rem .35rem; font-size: .68rem; letter-spacing: .09em;
  text-transform: uppercase; color: #6b7a91; font-weight: 600; cursor: pointer;
  list-style: none; user-select: none;
}
.nav-group::-webkit-details-marker { display: none; }
.nav-group:hover { color: #9fb0c9; }
.nav-group svg { flex: none; transition: transform .15s ease; opacity: .8; }
.nav-section[open] > .nav-group svg { transform: rotate(90deg); }
.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .55rem 1.15rem;
  color: #cbd5e1; font-size: .885rem; border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(37,99,235,.16); color: #fff; border-left-color: var(--primary); font-weight: 550; }

.main-wrap { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.4rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 650; font-size: 1.02rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.live-clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }
.user-chip {
  display: flex; align-items: center; gap: .55rem; cursor: pointer; list-style: none;
  padding: .3rem .5rem .3rem .3rem; border-radius: 999px; border: 1px solid transparent;
}
.user-chip::-webkit-details-marker { display: none; }
.user-menu[open] .user-chip, .user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-l); color: var(--primary);
  display: grid; place-items: center; font-weight: 650; font-size: .85rem; flex: none;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: .72rem; }
.menu-toggle { display: none; }
.nav-close { display: none; }
.nav-backdrop { display: none; }

/* ---- Account menu (topbar) -------------------------------------------- */
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg, var(--shadow)); z-index: 30; padding: .4rem;
  display: none;
}
.user-menu[open] .user-dropdown { display: block; }
@media (hover: hover) and (pointer: fine) {
  /* Mouse users get it on hover too, without needing to click first. */
  .user-menu:hover .user-dropdown { display: block; }
}
.user-dropdown a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem;
  border-radius: 8px; color: var(--text); font-size: .85rem;
}
.user-dropdown a:hover { background: var(--surface-2); }
.user-dropdown a.danger { color: var(--danger); }
.user-dropdown-divider { height: 1px; background: var(--border); margin: .35rem .2rem; }

/* ---- Org chart -------------------------------------------------------- */
.org-meta { display: flex; align-items: center; gap: 1.3rem; flex-wrap: wrap; margin-bottom: 1.15rem; }
.org-meta-pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 650; box-shadow: var(--shadow);
}
.org-meta-pill svg { color: var(--primary); }
.org-legend-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; color: var(--text); }

.org-chart-card { overflow: hidden; }
.org-chart-wrap { overflow-x: auto; padding: 2rem 1.5rem 2.5rem; }

.org-tree, .org-tree ul { display: table; margin: 0 auto; padding: 0; list-style: none; }
.org-tree li { display: table-cell; vertical-align: top; padding: 40px 14px 0; position: relative; }
.org-tree > li { padding-top: 0; }
.org-tree li::before, .org-tree li::after { content: ''; position: absolute; top: 0; }
.org-tree li::after { left: 50%; height: 24px; border-left: 2px solid var(--border); }
.org-tree li::before { top: 24px; left: 0; right: 0; border-top: 2px solid var(--border); }
.org-tree > li::before, .org-tree > li::after { display: none; }
.org-tree li:first-child::before { left: 50%; }
.org-tree li:last-child::before { right: 50%; }
.org-tree li:only-child::before { display: none; }
.org-collapsed > ul { display: none; }

.org-card {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: .3rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.4rem 1.5rem; box-shadow: var(--shadow); min-width: 190px;
}
.org-card.org-root { border-color: var(--primary); border-width: 2px; }

.org-avatar-wrap { position: relative; margin-bottom: .4rem; }
.org-avatar { width: 56px; height: 56px; font-size: 1.2rem; }
.org-dot {
  position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--surface);
}
.org-dot-active { background: var(--success); }
.org-dot-inactive { background: var(--danger); }

.org-name { font-weight: 700; color: var(--text); }
.org-name:hover { text-decoration: underline; }
.org-email { color: var(--muted); font-size: .78rem; margin-top: -.1rem; }
.org-role { margin-top: .3rem; }

.org-toggle {
  position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  border: 3px solid var(--surface); display: grid; place-items: center; cursor: pointer; z-index: 2;
}
.org-toggle svg { transform: rotate(90deg); transition: transform .15s; }
.org-collapsed > .org-card .org-toggle svg { transform: rotate(-90deg); }

/* ---- Notification bell ----------------------------------------------- */
.notif-bell { position: relative; }
.notif-bell summary {
  list-style: none; cursor: pointer; position: relative; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; color: var(--muted);
}
.notif-bell summary::-webkit-details-marker { display: none; }
.notif-bell summary:hover { background: var(--surface-2); color: var(--text); }
.notif-bell[open] summary { background: var(--surface-2); color: var(--text); }
.notif-count {
  position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff;
  font-size: .62rem; font-weight: 700; line-height: 1; padding: .2rem .32rem;
  border-radius: 999px; min-width: 1.1rem; text-align: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg, var(--shadow)); z-index: 30;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem .9rem; border-bottom: 1px solid var(--border); font-size: .85rem;
}
.notif-empty { padding: 1.2rem .9rem; color: var(--muted); font-size: .85rem; text-align: center; }
.notif-item {
  display: flex; flex-direction: column; gap: .1rem; padding: .65rem .9rem;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-l); }
.notif-item .notif-title { font-weight: 600; font-size: .85rem; }
.notif-item .notif-body { font-size: .78rem; color: var(--muted); }
.notif-item .notif-time { font-size: .7rem; color: var(--muted); margin-top: .1rem; }
.content { padding: 1.4rem; flex: 1; max-width: 1500px; width: 100%; }
.footer { padding: 1rem 1.4rem; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--border); }

/* ---- Cards & layout ------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.15rem;
}
.card-head {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1.15rem; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 1.15rem; }
.card-body.tight { padding: 0; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .spacer { margin-left: auto; }
.subtle { color: var(--muted); font-size: .85rem; }
.grid { display: grid; gap: 1.15rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.grid-sidebar { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---- Stats ---------------------------------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 1.85rem; font-weight: 680; line-height: 1.15; margin-top: .3rem; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.stat.accent-green .value { color: var(--success); }
.stat.accent-amber .value { color: var(--warn); }
.stat.accent-red   .value { color: var(--danger); }
.stat.accent-blue  .value { color: var(--primary); }
.stat-link { display: block; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.stat-link:hover { box-shadow: 0 4px 14px rgba(15,23,42,.08); transform: translateY(-1px); text-decoration: none; }

/* ---- Tables --------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th, table.data td { padding: .68rem .9rem; text-align: left; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { padding-left: 1.15rem; }
table.data th:last-child, table.data td:last-child { padding-right: 1.15rem; }
table.data th {
  background: var(--surface-2); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 700; white-space: nowrap;
  position: sticky; top: 0; z-index: 1; box-shadow: inset 0 -1px 0 var(--border);
}
table.data tbody tr { transition: background .1s ease; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Long single-line values (raw JSON, paths) truncate instead of forcing a tall row; full value on hover. */
table.data td.dt-clamp {
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help;
}
/* Denser row height for long lists where scanning many rows matters more
   than generous per-row breathing room. */
table.data.compact th, table.data.compact td { padding-top: .42rem; padding-bottom: .42rem; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); border-top: 2px solid var(--border); }
/* ---- Fact list (profile-style label/value pairs) --------------------- */
.fact-list { display: flex; flex-direction: column; margin: 0; }
.fact-row { display: flex; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.fact-row:last-child { border-bottom: none; }
.fact-row dt {
  flex: 0 0 128px; margin: 0; color: var(--muted); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; padding-top: .1rem;
}
.fact-row dd { flex: 1 1 auto; min-width: 0; margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .fact-row { flex-direction: column; gap: .2rem; }
  .fact-row dt { flex-basis: auto; }
}

.emp-cell { display: flex; align-items: center; gap: .6rem; }
.emp-cell .avatar { width: 30px; height: 30px; font-size: .75rem; }
.emp-cell small { display: block; color: var(--muted); font-size: .74rem; }

/* Row-number column: quiet, out of the way, doesn't compete with real data. */
table.data th.dt-n, table.data td.dt-n {
  width: 1%; white-space: nowrap; text-align: right; color: var(--muted);
  font-variant-numeric: tabular-nums; font-size: .78rem; padding-right: .5rem !important;
}

/* ---- Live data-table toolbar ------------------------------------------ */
.dt-toolbar {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  padding: .85rem 1.15rem; border-bottom: 1px solid var(--border);
}
.dt-toolbar .field { margin-bottom: 0; }
/* Bare selects/dates in the toolbar are flex items with no wrapper, so the
   global width:100% form rule would make each one claim the whole row's
   width and force a wrap. Give them a sane fixed sizing instead. */
.dt-toolbar select, .dt-toolbar input[type=date] { width: auto; min-width: 150px; flex: 0 0 auto; }
.dt-toolbar .spacer { flex: 1 1 auto; }
.dt-search { position: relative; flex: 1 1 220px; max-width: 340px; }
.dt-search svg {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.dt-search input[type=search] { padding-left: 2.15rem; }
.dt-search input[type=search]::-webkit-search-cancel-button { cursor: pointer; }

/* The swappable region: table + pagination. Dims briefly while a live fetch is in flight. */
.dt-region { position: relative; transition: opacity .12s ease; }
.dt-region.dt-loading { opacity: .45; pointer-events: none; }
.dt-region.dt-loading::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 60% 100%; animation: dtSweep 1s linear infinite;
}
@keyframes dtSweep {
  from { background-position: -60% 0; } to { background-position: 160% 0; }
}

.dt-meta { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.dt-meta strong { color: var(--text); font-weight: 650; }

.dt-pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.15rem; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.dt-pages { display: flex; gap: .25rem; align-items: center; margin-left: auto; }
.dt-pages a, .dt-pages span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 .4rem; border-radius: 7px;
  font-size: .82rem; font-weight: 650; color: var(--text);
}
.dt-pages a:hover { background: var(--surface-2); text-decoration: none; }
.dt-pages a.active { background: var(--primary); color: #fff; }
.dt-pages a.disabled, .dt-pages span.disabled { color: var(--muted); opacity: .35; pointer-events: none; }
.dt-pages span.ellipsis { color: var(--muted); }

/* ---- Badges --------------------------------------------------------- */
.badge {
  display: inline-block; padding: .18em .6em; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge-present    { background: var(--success-l); color: var(--success); border-color: #bfe3cd; }
.badge-late       { background: var(--warn-l);    color: var(--warn);    border-color: #f0dcb8; }
.badge-absent     { background: var(--danger-l);  color: var(--danger);  border-color: #f3c9c6; }
.badge-half_day   { background: #f3f0ff;          color: #6d28d9;        border-color: #ddd4fb; }
.badge-incomplete { background: #fff7ed;          color: #c2410c;        border-color: #fbd9bd; }
.badge-on_leave   { background: var(--info-l);    color: var(--info);    border-color: #bfe0f0; }
.badge-holiday    { background: #ecfeff;          color: #0e7490;        border-color: #bfe9f0; }
.badge-weekend    { background: var(--surface-2); color: var(--muted); }
.badge-pending    { background: var(--warn-l);    color: var(--warn);    border-color: #f0dcb8; }
.badge-approved   { background: var(--success-l); color: var(--success); border-color: #bfe3cd; }
.badge-rejected   { background: var(--danger-l);  color: var(--danger);  border-color: #f3c9c6; }
.badge-cancelled  { background: var(--surface-2); color: var(--muted); }
.badge-active     { background: var(--success-l); color: var(--success); border-color: #bfe3cd; }
.badge-inactive   { background: var(--surface-2); color: var(--muted); }
.badge-terminated { background: var(--danger-l);  color: var(--danger);  border-color: #f3c9c6; }
.badge-admin      { background: #f3f0ff; color: #6d28d9; border-color: #ddd4fb; }
.badge-manager    { background: var(--primary-l); color: var(--primary); border-color: #cfdefb; }
.badge-employee   { background: var(--surface-2); color: var(--muted); }

/* ---- Forms ---------------------------------------------------------- */
label { display: block; font-weight: 650; font-size: .8rem; margin-bottom: .32rem; color: #37455c; letter-spacing: .01em; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .58rem .75rem; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; transition: border-color .12s, box-shadow .12s;
  box-shadow: 0 1px 2px rgba(16,24,40,.03);
}
input:hover, select:hover, textarea:hover { border-color: #c7d0de; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.13);
}
input[disabled], select[disabled] { background: var(--surface-2); color: var(--muted); box-shadow: none; }
select { cursor: pointer; }
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 1.05rem; }
.field .help { color: var(--muted); font-size: .76rem; margin-top: .3rem; line-height: 1.4; }
.field-row { display: grid; gap: 1.05rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check {
  display: flex; align-items: flex-start; gap: .6rem; font-weight: 500; font-size: .875rem;
  margin-bottom: .6rem; padding: .3rem .1rem; border-radius: 6px; transition: background .1s;
}
.check:has(input:not([disabled])):hover { background: var(--surface-2); }
.check input { width: auto; margin-top: .2rem; accent-color: var(--primary); cursor: pointer; }
.check-scroll {
  max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .4rem .6rem;
}
.check-scroll .check { margin-bottom: 0; }

/* ---- File management: folders --------------------------------------- */
.file-breadcrumb { padding: .7rem 1.15rem; border-bottom: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.file-breadcrumb a { color: var(--primary); }
.file-breadcrumb span { margin: 0 .4rem; }

.file-folder-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem;
  padding: 1.15rem; border-bottom: 1px solid var(--border);
}
.file-folder {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem;
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
}
.file-folder-open { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center; color: var(--text); }
.file-folder-open:hover { text-decoration: none; color: var(--primary); }
.file-folder-open svg { color: var(--primary); }
.file-folder .row-actions { justify-content: center; }
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.15rem 1.15rem;
  margin: 0 0 1.3rem; background: var(--surface-2);
}
legend {
  font-weight: 700; font-size: .78rem; padding: 0 .5rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .52rem 1rem; border-radius: 8px; border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; font-size: .875rem;
  cursor: pointer; transition: background .12s, box-shadow .12s;
}
.btn:hover { background: var(--primary-d); text-decoration: none; color: #fff; }
.btn-sm { padding: .34rem .7rem; font-size: .8rem; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

.filters {
  display: grid; gap: .75rem; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.filters .field { margin-bottom: 0; }

/* ---- Alerts --------------------------------------------------------- */
.alert {
  padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-l); color: var(--success); border-color: #bfe3cd; }
.alert-error, .alert-danger { background: var(--danger-l); color: var(--danger); border-color: #f3c9c6; }
.alert-warning { background: var(--warn-l); color: var(--warn); border-color: #f0dcb8; }
.alert-info { background: var(--info-l); color: var(--info); border-color: #bfe0f0; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty h2 { color: var(--text); }

/* ---- Trend bars ----------------------------------------------------- */
.trend { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: .5rem; }
.trend-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: .3rem; }
.trend-bar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; }
.trend-bar.low { background: var(--danger); }
.trend-bar.mid { background: var(--warn); }
.trend-label { font-size: .65rem; color: var(--muted); white-space: nowrap; }

.progress { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }

/* ---- Day pills: read-only at-a-glance schedule (M T W T F S S) -------- */
.day-pills { display: flex; gap: .35rem; }
.day-pill {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: .72rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); flex: none;
}
.day-pill.active { background: var(--primary-l); color: var(--primary); }

/* ---- Day toggle: the interactive equivalent, used in the shift form -- */
.day-toggle { display: flex; gap: .45rem; flex-wrap: wrap; }
.day-toggle input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.day-toggle label {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 3.4rem; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: .82rem; font-weight: 650;
  cursor: pointer; user-select: none; transition: background .1s, border-color .1s, color .1s;
}
.day-toggle label:hover { border-color: var(--primary); }
.day-toggle input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.day-toggle input:focus-visible + label { box-shadow: 0 0 0 3px rgba(37,99,235,.3); }

/* ---- Shift cards -------------------------------------------------------- */
.shift-card .card-body { display: flex; flex-direction: column; gap: .8rem; }
.shift-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.shift-card-head h3 { margin: 0; }
.shift-time { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.shift-duration { color: var(--muted); font-size: .8rem; margin-top: -.5rem; }
.shift-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .8rem;
  font-size: .8rem; color: var(--muted); padding-top: .7rem; border-top: 1px solid var(--border);
}
.shift-stats strong { color: var(--text); font-weight: 650; }

/* ---- Modal (native <dialog>) ------------------------------------------- */
dialog.modal {
  border: none; border-radius: 14px; padding: 0; margin: auto;
  width: calc(100% - 2rem); max-width: 640px; max-height: 85vh;
  box-shadow: 0 24px 70px rgba(16,24,40,.28);
}
dialog.modal::backdrop { background: rgba(15,23,42,.55); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.05rem 1.3rem; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; }
.modal-close {
  background: none; border: none; font-size: 1.4rem; line-height: 1; color: var(--muted);
  cursor: pointer; padding: .2rem .5rem; border-radius: 6px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 1.3rem; max-height: calc(85vh - 64px); overflow-y: auto; }

/* ---- Compact row actions: icon buttons instead of a stack of text buttons.
   A cramped table cell with 2-3 full-text buttons wraps onto separate lines
   and looks like a pile of alarms; small square icon buttons stay on one
   line and put visual weight only where it belongs (danger = red on hover). */
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; flex-wrap: nowrap; }
.row-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; flex: none;
  transition: background .1s, color .1s, border-color .1s;
}
.row-icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: #c7d0de; text-decoration: none; }
.row-icon-btn.danger:hover { background: var(--danger-l); color: var(--danger); border-color: #f3c9c6; }
.row-icon-btn.active-on { color: var(--success); border-color: #bfe3cd; background: var(--success-l); }
.row-icon-btn svg { width: 15px; height: 15px; }

/* ---- Login ---------------------------------------------------------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(160deg, #101828 0%, #1e3a8a 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 14px;
  padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card h1 { text-align: center; margin-bottom: .25rem; }
.auth-card .subtle { text-align: center; margin-bottom: 1.5rem; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: .85rem; }

/* ---- Public careers site --------------------------------------------- */
.careers-page {
  min-height: 100vh; padding: 2.5rem 1rem 4rem;
  background: linear-gradient(160deg, #101828 0%, #1e3a8a 100%);
}
.careers-wrap { max-width: 760px; margin: 0 auto; }
.careers-header { text-align: center; color: #fff; margin-bottom: 2rem; }
.careers-header h1 { margin: 0 0 .35rem; font-size: 1.7rem; }
.careers-header p { color: #cbd5e1; margin: 0; }
.careers-back { display: inline-block; margin-bottom: 1rem; color: #cbd5e1; font-size: .85rem; }
.careers-back:hover { color: #fff; }
.careers-list { display: flex; flex-direction: column; gap: 1rem; }
.careers-job-card {
  background: #fff; border-radius: 12px; padding: 1.3rem 1.5rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.careers-job-card h2 { margin: 0 0 .3rem; font-size: 1.1rem; }
.careers-job-meta { color: var(--muted); font-size: .85rem; margin-bottom: .8rem; }
.careers-empty, .careers-detail-card {
  background: #fff; border-radius: 14px; padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.careers-empty { text-align: center; color: var(--muted); }
.careers-detail-card h1 { margin: 0 0 .3rem; font-size: 1.4rem; }
.careers-detail-meta { color: var(--muted); font-size: .9rem; margin-bottom: 1.2rem; }
.careers-description { white-space: pre-line; margin-bottom: 1.6rem; }
.careers-result { text-align: center; padding: 1.5rem 0; }
.careers-result .result-icon { font-size: 2.5rem; margin-bottom: .5rem; }
/* A real applicant never sees or fills this - only bots that blindly fill
   every field do, which is exactly what flags them. */
.careers-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* =====================================================================
   Clock terminal (kiosk)
   ===================================================================== */
body.kiosk {
  background: linear-gradient(165deg, #0b1220 0%, #15294d 100%);
  color: #e6ecf5; min-height: 100vh; display: flex; flex-direction: column;
}
.kiosk-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.8rem; gap: 1rem; flex-wrap: wrap;
}
.kiosk-org { font-size: 1.05rem; font-weight: 650; letter-spacing: .01em; }
.kiosk-org small { display: block; font-weight: 400; color: #93a7c4; font-size: .78rem; }
.kiosk-time { text-align: right; }
.kiosk-time .t { font-size: 2.5rem; font-weight: 300; font-variant-numeric: tabular-nums; line-height: 1; }
.kiosk-time .d { color: #93a7c4; font-size: .9rem; margin-top: .3rem; }

.kiosk-main { flex: 1; display: grid; place-items: center; padding: 1rem 1.5rem 2rem; }
.kiosk-panel {
  width: 100%; max-width: 560px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12); border-radius: 20px; padding: 2rem;
  backdrop-filter: blur(8px);
}
.kiosk-panel h1 { font-size: 1.45rem; text-align: center; margin-bottom: .35rem; }
.kiosk-panel .lead { text-align: center; color: #9fb3d1; margin-bottom: 1.5rem; }
#empCode, #empPin {
  width: 100%; padding: 1rem; font-size: 1.6rem; text-align: center; letter-spacing: .12em;
  border-radius: 14px; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #fff; font-weight: 600;
}
#empCode::placeholder, #empPin::placeholder { color: #7d92b3; letter-spacing: normal; font-weight: 400; }
#empCode:focus, #empPin:focus { outline: none; border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,.22); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 1.2rem 0; }
.keypad button {
  padding: 1.05rem 0; font-size: 1.5rem; font-weight: 600; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.08);
  color: #fff; cursor: pointer; transition: background .1s, transform .06s;
}
.keypad button:hover { background: rgba(255,255,255,.16); }
.keypad button:active { transform: scale(.96); }
.keypad button.wide { grid-column: span 1; font-size: 1.05rem; }
.keypad button.clear { color: #fca5a5; }
.keypad button.ok { background: #2563eb; border-color: #2563eb; }
.keypad button.ok:hover { background: #1d4ed8; }

.kiosk-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .4rem; }
.kbtn {
  padding: 1.15rem 1rem; border-radius: 14px; border: none; font-size: 1.05rem; font-weight: 650;
  cursor: pointer; color: #fff; display: flex; flex-direction: column; align-items: center; gap: .2rem;
}
.kbtn small { font-weight: 400; opacity: .82; font-size: .76rem; }
.kbtn-in { background: #15803d; } .kbtn-in:hover { background: #166534; }
.kbtn-out { background: #b91c1c; } .kbtn-out:hover { background: #991b1b; }
.kbtn-break { background: #b45309; } .kbtn-break:hover { background: #92400e; }
.kbtn-back { background: rgba(255,255,255,.12); } .kbtn-back:hover { background: rgba(255,255,255,.2); }
/* An unavailable action goes flat grey - only the action you can actually
   take keeps its colour, so the screen reads correctly at a glance. */
.kbtn[disabled] {
  background: rgba(255,255,255,.05) !important; color: #64748b;
  border: 1px solid rgba(255,255,255,.07); cursor: not-allowed; opacity: 1;
}
.kbtn[disabled] small { opacity: .9; }
/* The action the employee is expected to take next. */
.kbtn.recommended { box-shadow: 0 0 0 3px rgba(255,255,255,.4); }

.kiosk-result { text-align: center; }
.kiosk-result .who { font-size: 1.6rem; font-weight: 650; margin-bottom: .2rem; }
.kiosk-result .meta { color: #9fb3d1; margin-bottom: 1.2rem; }
.result-icon { font-size: 3.2rem; line-height: 1; margin-bottom: .6rem; }
.kiosk-msg { padding: 1rem; border-radius: 12px; font-size: 1.05rem; margin-bottom: 1.2rem; }
.kiosk-msg.ok  { background: rgba(21,128,61,.22);  border: 1px solid rgba(34,197,94,.4); color: #bbf7d0; }
.kiosk-msg.err { background: rgba(185,28,28,.22);  border: 1px solid rgba(248,113,113,.4); color: #fecaca; }
.kiosk-msg.location { background: rgba(180,131,0,.22); border: 1px solid rgba(251,191,36,.4); color: #fde68a; }
.kiosk-status { display: flex; justify-content: center; gap: 2rem; margin: 1.2rem 0; flex-wrap: wrap; }
.kiosk-status div { text-align: center; }
.kiosk-status .k { color: #93a7c4; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
.kiosk-status .v { font-size: 1.15rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Plain-language state banner on the action screen. */
.kiosk-state {
  display: flex; align-items: center; justify-content: center; gap: .65rem;
  padding: .85rem 1rem; border-radius: 12px; margin: 0 0 1.2rem;
  font-size: 1.02rem; font-weight: 600; text-align: center; line-height: 1.35;
}
.kiosk-state .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.kiosk-state.out   { background: rgba(148,163,184,.14); border: 1px solid rgba(148,163,184,.32); color: #cbd5e1; }
.kiosk-state.out .dot   { background: #94a3b8; }
.kiosk-state.in    { background: rgba(21,128,61,.22);   border: 1px solid rgba(34,197,94,.42);   color: #bbf7d0; }
.kiosk-state.in .dot    { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.2); }
.kiosk-state.break { background: rgba(180,83,9,.22);    border: 1px solid rgba(245,158,11,.42);  color: #fde68a; }
.kiosk-state.break .dot { background: #f59e0b; }

.kiosk-foot { text-align: center; padding: 1rem; color: #6b82a6; font-size: .78rem; }
.kiosk-foot a { color: #93a7c4; }
.hidden { display: none !important; }

/* ---- Responsive ----------------------------------------------------- */
@media (max-width: 1100px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-sidebar, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; }
  .main-wrap { margin-left: 0; }
  .menu-toggle {
    display: block; background: none; border: 1px solid var(--border);
    border-radius: 8px; padding: .3rem .6rem; font-size: 1.1rem; cursor: pointer;
  }
  /* The open sidebar overlays the topbar (and its toggle button), so it needs
     its own close control plus a tap-outside-to-close backdrop. */
  .nav-close { display: block; margin-left: auto; background: none; border: none;
    color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 .3rem; }
  body.nav-open .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 25;
  }
  .grid-2, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .live-clock, .user-meta { display: none; }
  .content { padding: 1rem; }
  .kiosk-time .t { font-size: 1.9rem; }
  .kiosk-panel { padding: 1.35rem; }
  /* Lower-priority table columns give way on a phone-width screen so the
     important columns (name, ID, status, actions) stay readable without
     forcing a horizontal scroll for everyone. */
  .hide-sm { display: none; }
}

/* ---- Asset dashboard ---------------------------------------------------- */
.asset-stat {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow);
}
.asset-stat .label { color: var(--muted); font-size: .85rem; }
.asset-stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: .2rem; }
.asset-stat .hint { font-size: .8rem; font-weight: 600; margin-top: .3rem; }
.asset-stat-icon {
  position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
}
.asset-stat-icon::before {
  content: ''; position: absolute; inset: -30px -10px auto auto; width: 90px; height: 90px;
  border-radius: 50%; opacity: .08; background: currentColor; z-index: -1;
}

.asset-donut-wrap { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; }
.asset-donut-center { text-align: center; }
.asset-donut-center .value { font-size: 1.7rem; font-weight: 700; }
.asset-donut-center .label { font-size: .78rem; color: var(--muted); }
.asset-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: .7rem; }
.asset-legend-row { display: flex; align-items: center; gap: .6rem; font-size: .88rem; }
.asset-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.asset-legend-row .name { flex: 1; }
.asset-legend-row .pct { color: var(--muted); font-size: .78rem; width: 3.2em; text-align: right; }

.asset-bars { display: flex; align-items: flex-end; gap: 1.1rem; height: 200px; padding-top: 1.5rem; }
.asset-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; height: 100%; justify-content: flex-end; }
.asset-bar-value { font-size: .82rem; font-weight: 650; color: var(--text); }
.asset-bar { width: 70%; max-width: 46px; border-radius: 6px 6px 0 0; min-height: 3px; }
.asset-bar-label { font-size: .72rem; color: var(--muted); text-align: center; line-height: 1.25; }

/* ---- Leave balances ------------------------------------------------------ */
.leave-bal-card .card-body { display: flex; flex-direction: column; gap: .9rem; }
.leave-bal-head { display: flex; align-items: center; gap: .75rem; }
.leave-bal-head .avatar { width: 44px; height: 44px; font-size: 1rem; }
.leave-bal-table-wrap { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--border); }
.leave-bal-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.leave-bal-table thead th {
  position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 650;
  color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .02em;
  padding: .5rem .3rem; border-bottom: 1px solid var(--border);
}
.leave-bal-table thead th.num, .leave-bal-table td.num { text-align: right; }
.leave-bal-table td { padding: .5rem .3rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.leave-bal-table tbody tr:last-child td { border-bottom: none; }
.leave-bal-table .leave-used { color: var(--danger); font-weight: 600; }
.leave-bal-table .leave-avail { color: var(--success); font-weight: 600; }
.leave-bal-info {
  width: 1.4rem; color: var(--muted); cursor: pointer; background: none; border: none; padding: 0;
}
.leave-bal-info svg { display: block; }
.leave-bal-info:hover { color: var(--primary); }

.leave-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .65rem 0; border-bottom: 1px solid var(--border); font-size: .95rem;
}
.leave-info-row:last-of-type { border-bottom: none; }
.leave-info-row.total { background: var(--surface-2); padding: .65rem .6rem; border-radius: 6px; border-bottom: none; font-weight: 650; }
.leave-info-row.available { background: var(--success-l); padding: .65rem .6rem; border-radius: 6px; border-bottom: none; font-weight: 650; }
.leave-info-neg { color: var(--danger); }
.leave-info-pos { color: var(--success); }

.leave-pol-tabs { display: flex; gap: 1.6rem; padding: .9rem 1.15rem 0; border-bottom: 1px solid var(--border); }
.leave-pol-tab {
  display: flex; align-items: center; gap: .4rem; padding: 0 0 .85rem; color: var(--muted);
  font-weight: 600; font-size: .88rem; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font-family: inherit; cursor: pointer;
}
.leave-pol-tab:hover { color: var(--text); text-decoration: none; }
.leave-pol-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.leave-pol-tab-count {
  background: var(--surface-2); color: var(--text); border-radius: 999px; font-size: .74rem;
  font-weight: 650; padding: .05rem .5rem;
}
.leave-pol-tab.active .leave-pol-tab-count { background: var(--primary-l); color: var(--primary); }
.leave-pol-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .45rem; }

/* ---- Generic status tabs (also used by Payslips) ---------------------- */
.status-tabs { display: flex; gap: 1.6rem; padding: .9rem 1.15rem 0; border-bottom: 1px solid var(--border); }
.status-tab {
  display: flex; align-items: center; gap: .4rem; padding: 0 0 .85rem; color: var(--muted);
  font-weight: 600; font-size: .88rem; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font-family: inherit; cursor: pointer;
}
.status-tab:hover { color: var(--text); text-decoration: none; }
.status-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.status-tab-count {
  background: var(--surface-2); color: var(--text); border-radius: 999px; font-size: .74rem;
  font-weight: 650; padding: .05rem .5rem;
}
.status-tab.active .status-tab-count { background: var(--primary-l); color: var(--primary); }

/* ---- Month tab strip (Payslips) ---------------------------------------- */
.month-tabs {
  display: grid; grid-template-columns: repeat(12, minmax(0,1fr)); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.15rem; overflow: hidden;
}
.month-tab {
  text-align: center; padding: .9rem .3rem; font-weight: 650; color: var(--text);
  border: none; border-right: 1px solid var(--border);
  background: none; font-family: inherit; font-size: inherit; cursor: pointer;
}
.month-tab:last-child { border-right: none; }
.month-tab:hover { background: var(--surface-2); text-decoration: none; }
.month-tab small { display: block; font-weight: 600; font-size: .72rem; margin-top: .15rem; }
.month-tab.active { background: var(--success); color: #fff; }
.month-tab.active:hover { background: var(--success); }

/* ---- Filter chips ------------------------------------------------------- */
.filter-chips { display: flex; gap: .5rem; flex-wrap: wrap; padding: 0 1.15rem .85rem; }
.filter-chip {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 999px;
  font-size: .78rem; font-weight: 600; padding: .25rem .7rem;
}

/* ---- Period navigator (month/year stepper, used above Payroll Runs) ---- */
.period-nav {
  display: flex; align-items: center; justify-content: center; gap: 1.2rem;
  padding: 1rem 1.15rem; border-bottom: 1px solid var(--border);
}
.period-nav strong { font-size: 1.05rem; }
.month-strip { display: flex; align-items: stretch; padding: .85rem 1.15rem; gap: .6rem; }
.month-tabs.nested { border: none; border-radius: var(--radius); margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.month-tab-nav {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 34px;
  color: var(--muted); border: 1px solid var(--border); border-radius: 8px;
}
.month-tab-nav:hover { background: var(--surface-2); color: var(--text); }
.month-tab small { color: rgba(255,255,255,.85); margin-left: .2rem; }

/* This must come after the base .month-tabs/.month-tab rules above so it wins
   the cascade at this width - an identical block placed earlier in the file
   (before those rules existed) was being silently overridden by them. */
@media (max-width: 860px) {
  .month-tabs { display: flex; overflow-x: auto; min-width: 0; }
  .month-tab { flex: 0 0 auto; min-width: 64px; }
}

/* ---- Attendance matrix (employee rows x day columns) --------------------- */
.att-legend .card-body { display: flex; flex-wrap: wrap; gap: .4rem 1.15rem; }
.att-legend-item { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; color: var(--text); }
.att-legend-item b { font-size: .95rem; }

.att-scroll { overflow-x: auto; }
.att-matrix { border-collapse: separate; border-spacing: 0; }
.att-matrix th, .att-matrix td { border-bottom: 1px solid var(--border); }
.att-matrix .att-emp-col {
  position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 200px;
  border-right: 1px solid var(--border);
}
.att-matrix thead .att-emp-col { z-index: 3; background: var(--surface-2); }
.att-matrix .att-total-col { background: var(--surface); border-left: 1px solid var(--border); white-space: nowrap; }
.att-matrix thead .att-total-col { background: var(--surface-2); }

.att-day { text-align: center; padding: .45rem .3rem; min-width: 40px; line-height: 1.15; }
.att-day-num { display: block; font-weight: 700; font-size: .82rem; color: var(--text); }
.att-day-name { display: block; font-size: .66rem; color: var(--muted); font-weight: 600; }
.att-day-off { background: var(--surface-2); }
.att-day-today .att-day-num { color: var(--primary); }
th.att-day-today, td.att-day-today { background: var(--primary-l); }

.att-cell { text-align: center; padding: .2rem; }
.att-mark {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 30px; border-radius: 6px; padding: .15rem .2rem;
}
.att-mark:hover { background: var(--surface-2); text-decoration: none; }
.att-mark b { font-size: .95rem; font-weight: 700; line-height: 1; }
.att-mods { display: flex; gap: 2px; }

/* Hover card for a day's cell. Lives on <body> so the matrix's own
   horizontal scroll container can't clip it. */
.att-tip {
  position: absolute; z-index: 60; pointer-events: none; min-width: 210px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15,23,42,.15); padding: .8rem .9rem;
}
.att-tip-row { display: flex; gap: .5rem; align-items: baseline; padding: .12rem 0; font-size: .84rem; }
/* display:flex would otherwise beat the UA rule for [hidden], leaving empty rows on show. */
.att-tip-row[hidden] { display: none; }
.att-tip-row span { color: var(--muted); }
.att-tip-row strong { margin-left: auto; font-weight: 650; }
.att-tip-foot {
  margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border);
  text-align: center; color: var(--muted); font-size: .8rem;
}
/* Two stacked triangles so the arrow keeps the card's border edge. */
.att-tip::before, .att-tip::after {
  content: ''; position: absolute; left: var(--arrow-x, 50%); transform: translateX(-50%);
  border: 7px solid transparent;
}
.att-tip::before { top: 100%; border-top-color: var(--border); }
.att-tip::after  { top: calc(100% - 1px); border-top-color: var(--surface); }
.att-tip.below::before {
  top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--border);
}
.att-tip.below::after {
  top: auto; bottom: calc(100% - 1px); border-top-color: transparent; border-bottom-color: var(--surface);
}

.att-present { color: var(--success); }
.att-absent  { color: var(--danger); }
.att-half    { color: #c98500; }
.att-leave   { color: var(--danger); }
.att-holiday { color: #eda100; }
.att-off     { color: #b6bfcc; }
.att-future  { color: var(--muted); }
.att-none    { color: #b6bfcc; }
.att-late    { color: #c98500; }
.att-early   { color: var(--danger); }
.att-ot      { color: var(--primary); }

/* ---- Shift roster (reuses .att-matrix/.att-emp-col/.att-day-today) -------- */
.roster-legend .card-body { display: flex; flex-wrap: wrap; gap: .4rem 1.15rem; }
.roster-legend-off   { color: var(--danger); }
.roster-legend-shift { color: var(--primary); }
.roster-day  { text-align: center; padding: .45rem .3rem; min-width: 130px; line-height: 1.15; }
.roster-cell { padding: .3rem; text-align: center; }
.roster-cell select {
  width: 100%; font-size: .78rem; padding: .35rem .3rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--text);
}
.roster-cell select.roster-off      { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.roster-cell select.roster-override { border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* ---- Calendar ------------------------------------------------------------ */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow {
  padding: .6rem; text-align: center; font-weight: 650; font-size: .78rem; color: var(--muted);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.cal-cell {
  display: flex; flex-direction: column; gap: .2rem; min-height: 96px; padding: .4rem;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  color: var(--text); background: var(--surface);
}
.cal-cell:hover { background: var(--surface-2); text-decoration: none; }
.cal-cell.outside { color: var(--muted); background: var(--surface-2); }
.cal-cell.outside .cal-daynum { color: var(--muted); }
.cal-cell.today { background: var(--primary-l); }
.cal-cell.today .cal-daynum {
  background: var(--primary); color: #fff; border-radius: 50%; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.cal-daynum { font-weight: 650; font-size: .85rem; }
.cal-pill {
  display: flex; align-items: center; gap: .25rem; font-size: .68rem; font-weight: 600;
  padding: .1rem .35rem; border-radius: 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.cal-pill-holiday { background: var(--danger-l); color: var(--danger); }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.cal-more { font-size: .68rem; color: var(--muted); font-weight: 600; }

.cal-agenda-row { display: flex; gap: .8rem; align-items: center; padding: .7rem 1.15rem; border-bottom: 1px solid var(--border); }
.cal-agenda-row:last-child { border-bottom: none; }
.cal-agenda-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .95rem; flex: none;
}
.cal-agenda-date small { font-weight: 650; font-size: .62rem; color: var(--muted); text-transform: uppercase; }

.cal-day-item { display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.cal-day-item:last-child { border-bottom: none; }

@media (max-width: 1100px) {
  .cal-cell { min-height: 72px; }
}
@media (max-width: 640px) {
  .cal-cell { min-height: 56px; padding: .25rem; }
  .cal-pill svg { display: none; }
}

/* ---- Payslip ----------------------------------------------------------- */
.strong { font-weight: 650; }

.payslip-warn {
  display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; margin-bottom: 1.15rem;
  background: var(--warn-l); border: 1px solid #f0dcb8; border-radius: var(--radius);
  color: var(--warn); font-size: .85rem;
}
.payslip-warn svg { flex: none; }
.payslip-warn a { color: inherit; text-decoration: underline; }

.payslip-doc .card-body { padding: 2rem; }
.payslip-letterhead {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem;
  padding-bottom: 1rem; border-bottom: 2px solid var(--text);
}
.payslip-company { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
.payslip-doctype { font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: .2rem; }
.payslip-period-block { text-align: right; font-size: .8rem; color: var(--muted); }

.payslip-divider { border: none; border-top: 1px solid var(--border); margin: 1.4rem 0; }

.payslip-info-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; margin-top: 1.3rem;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.3rem;
}
.payslip-info-col { display: flex; flex-direction: column; gap: .6rem; }
.pg-item .pg-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin-bottom: .2rem;
}
.pg-item .pg-value { font-size: .92rem; }

.payslip-col-head { font-size: .95rem; margin: 1.4rem 0 .5rem; }
.payslip-line-table { width: 100%; border-collapse: collapse; font-size: .85rem; border: 1px solid var(--border); }
.payslip-line-table th {
  text-align: left; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text); background: var(--surface-2); padding: .5rem .7rem; border: 1px solid var(--border);
}
.payslip-line-table th.num, .payslip-line-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.payslip-line-table td { padding: .5rem .7rem; border: 1px solid var(--border); }
.payslip-line-table tfoot td { font-weight: 650; background: var(--surface-2); border: 1px solid var(--border); }

/* Three side-by-side boxes: Deductions / Employer Wage Cost / Attendance. */
.payslip-box-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-top: 1.6rem; align-items: start; }
.payslip-box { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; height: 100%; }
.payslip-box-head {
  padding: .5rem .8rem; font-size: .78rem; font-weight: 700; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.payslip-box-body { padding: .1rem .8rem; }
.payslip-fact { display: flex; justify-content: space-between; gap: .6rem; padding: .4rem 0; font-size: .82rem; border-bottom: 1px solid var(--border); }
.payslip-fact:last-child { border-bottom: none; }
.payslip-fact span:first-child { color: var(--muted); }
.payslip-fact span:last-child { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }

/* Plain "Net Salary Payable: X" on the left, a small boxed figure on the
   right - deliberately understated (no colour-block bar), matching a
   formal payslip document rather than a dashboard summary card. */
.payslip-net-row {
  display: flex; justify-content: space-between; align-items: center; margin-top: 1.6rem; gap: 1rem;
  padding: .9rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.payslip-net-label { font-size: .95rem; }
.payslip-net-value-box { border: 1px solid var(--border); border-radius: 6px; padding: .5rem 1.1rem; text-align: center; background: var(--surface-2); }
.payslip-net-value-box .payslip-net-caption { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.payslip-net-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); line-height: 1.3; }

.payslip-words { margin-top: 1rem; font-size: .85rem; }

/* Words/notes box paired with the Loan Description box, side by side. */
.payslip-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.6rem; align-items: start; }
.payslip-note-field { margin-top: .6rem; padding-top: .3rem; border-top: 1px dashed var(--border); min-height: 1.2rem; }

/* SSNIT/Provident Fund summary, pushed to the bottom-right corner like a
   document's closing tally rather than spanning the full width. */
.payslip-corner-boxes { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1.6rem; flex-wrap: wrap; }
.payslip-corner-boxes .payslip-box { width: 260px; flex: 0 0 auto; }

.payslip-danger { color: var(--danger); }
.payslip-success { color: var(--success); }

.payslip-footnote { margin-top: 1.2rem; }

.payslip-footer { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.payslip-footer p { font-size: .72rem; line-height: 1.5; }
.payslip-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 2.2rem; }
.payslip-sig-line { border-top: 1px solid var(--text); padding-top: .4rem; font-size: .78rem; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .payslip-info-grid, .payslip-box-row, .payslip-two-col, .payslip-signatures { grid-template-columns: 1fr; }
  .payslip-net-row { flex-direction: column; align-items: flex-start; gap: .8rem; }
  .payslip-corner-boxes { justify-content: flex-start; }
  .payslip-corner-boxes .payslip-box { width: 100%; }
}

/* Compact enough to always fit one A4 sheet when printed - every spacing
   and font-size value below is deliberately tighter than the on-screen
   version, not just a scaled-down copy of it. */
@media print {
  @page { size: A4; margin: 10mm; }
  .payslip-warn { display: none !important; }
  .payslip-doc { max-width: none !important; }
  .payslip-doc .card-body { padding: 0; }

  .payslip-letterhead { padding-bottom: .4rem; }
  .payslip-company { font-size: 1rem; }
  .payslip-doctype { font-size: .7rem; }
  .payslip-period-block { font-size: .68rem; }

  .payslip-info-grid { margin-top: .5rem; padding: .5rem .7rem; gap: 0 1.2rem; }
  .payslip-info-col { gap: .25rem; }
  .pg-item .pg-label { font-size: .55rem; margin-bottom: 0; }
  .pg-item .pg-value { font-size: .75rem; }

  .payslip-col-head { font-size: .78rem; margin: .6rem 0 .3rem; }
  .payslip-line-table { font-size: .7rem; }
  .payslip-line-table th, .payslip-line-table td { padding: .22rem .4rem; }

  .payslip-box-row { margin-top: .6rem; gap: .5rem; }
  .payslip-box-head { padding: .3rem .5rem; font-size: .65rem; }
  .payslip-box-body { padding: 0 .5rem; }
  .payslip-fact { padding: .16rem 0; font-size: .68rem; }

  .payslip-net-row { margin-top: .6rem; padding: .35rem 0; }
  .payslip-net-label { font-size: .78rem; }
  .payslip-net-value-box { padding: .25rem .6rem; }
  .payslip-net-caption { font-size: .54rem; }
  .payslip-net-value { font-size: .92rem; }

  .payslip-words { margin-top: .35rem; font-size: .68rem; }
  .payslip-two-col { margin-top: .6rem; gap: .5rem; }
  .payslip-note-field { margin-top: .25rem; min-height: .4rem; }

  .payslip-corner-boxes { margin-top: .6rem; gap: .5rem; }
  .payslip-corner-boxes .payslip-box { width: 200px; }

  .payslip-footnote { margin-top: .4rem; font-size: .68rem; }
  .payslip-footer { margin-top: .7rem; padding-top: .4rem; }
  .payslip-footer p { font-size: .58rem; line-height: 1.35; }
  .payslip-signatures { margin-top: .9rem; gap: 1.5rem; }
  .payslip-sig-line { font-size: .62rem; padding-top: .25rem; }
}

/* ---- Print ---------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .footer, .no-print, .filters, .actions { display: none !important; }
  .main-wrap { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; break-inside: avoid; }
  table.data th { background: #eee !important; -webkit-print-color-adjust: exact; }
  body { background: #fff; font-size: 11px; }
  .print-head { display: block !important; margin-bottom: 1rem; }

  /* The org chart prints fully expanded, regardless of what's collapsed on
     screen - the toggle buttons themselves make no sense on paper. */
  .org-chart-card { box-shadow: none; }
  .org-chart-wrap { overflow: visible; padding: 0; }
  .org-toggle { display: none !important; }
  .org-collapsed > ul { display: table !important; }
}
.print-head { display: none; }

/* A day with no scheduled work reads as neutral, not as a failed day. */
.trend-bar.rest { background: var(--border); opacity: 1; }
