/* =====================================================================
   STAR LAWMAN OUTFITTERS — Payroll UI
   Brand: #FF6600. Light & dark palettes via CSS custom properties.
   Mobile-first; desktop sidebar from 992px.
   ===================================================================== */

:root {
  --brand: #FF6600;
  --brand-600: #E65C00;
  --brand-700: #C24E00;
  --brand-50: #FFF3EB;
  --brand-100: #FFE2CC;
  --brand-rgb: 255, 102, 0;

  --bg: #F6F4F1;
  --surface: #FFFFFF;
  --surface-2: #FBFAF8;
  --border: #E7E2DC;
  --text: #1F1A16;
  --muted: #6E655D;
  --sidebar-bg: #1E1A17;
  --sidebar-text: #CFC6BE;
  --sidebar-active: #FFFFFF;
  --ok: #1E8E5A;
  --warn: #B7791F;
  --bad: #C53030;
  --info: #2B6CB0;

  /* attendance cell colours */
  --att-P: #DDF3E6;  --att-P-t: #1E6B45;
  --att-A: #FCE1E1;  --att-A-t: #A12626;
  --att-H: #FFF0C7;  --att-H-t: #8A5A00;
  --att-WO: #ECE8E4; --att-WO-t: #6E655D;
  --att-HL: #E3ECFB; --att-HL-t: #2B5597;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 26, 22, .06), 0 4px 16px rgba(31, 26, 22, .05);
  --sidebar-w: 248px;
  --topbar-h: 60px;

  --bs-primary: var(--brand);
  --bs-primary-rgb: var(--brand-rgb);
  --bs-link-color: var(--brand-700);
  --bs-link-hover-color: var(--brand);
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif;
}

[data-bs-theme="dark"] {
  --brand-50: #2A1A0E;
  --brand-100: #3A220F;
  --bg: #121110;
  --surface: #1C1A18;
  --surface-2: #22201D;
  --border: #33302C;
  --text: #EDE8E3;
  --muted: #A59C93;
  --sidebar-bg: #0D0C0B;
  --sidebar-text: #B9B0A7;
  --att-P: #163626;  --att-P-t: #7FD9A8;
  --att-A: #3D1919;  --att-A-t: #F2A0A0;
  --att-H: #3A2E0E;  --att-H-t: #F3CF6E;
  --att-WO: #2A2724; --att-WO-t: #A59C93;
  --att-HL: #182740; --att-HL-t: #9EBDF0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --bs-link-color: #FF8A3D;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-tertiary-bg: var(--surface-2);
}

html, body { background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: .95rem; -webkit-tap-highlight-color: transparent; }
a { color: var(--bs-link-color); }
.text-brand { color: var(--brand) !important; }
.text-muted { color: var(--muted) !important; }
.skip-link { position: absolute; z-index: 2000; background: var(--brand); color: #fff; padding: 8px 12px; }

/* ---------- Buttons ---------- */
.btn-brand { --bs-btn-color: #fff; --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600);
  --bs-btn-active-bg: var(--brand-700); --bs-btn-active-border-color: var(--brand-700); --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); --bs-btn-disabled-color: #fff; }
.btn-outline-brand { --bs-btn-color: var(--brand-700); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand);
  --bs-btn-active-bg: var(--brand-600); --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-outline-brand { --bs-btn-color: #FF8A3D; }
.text-bg-brand { background: var(--brand) !important; color: #fff !important; }
.btn-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--text); font-size: 1.2rem; padding: 0; }
.btn-icon:hover { background: var(--surface-2); }
.btn { border-radius: 10px; }
.form-control, .form-select { border-radius: 10px; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .2); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 500; font-size: .87rem; margin-bottom: .3rem; }
.req::after { content: " *"; color: var(--bad); }

/* ---------- Sidebar ---------- */
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); width: var(--sidebar-w) !important; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand .brand-text { line-height: 1.1; display: flex; flex-direction: column; }
.sidebar-brand strong { color: #fff; letter-spacing: .04em; font-size: .95rem; }
.sidebar-brand small { color: var(--brand); font-size: .7rem; letter-spacing: .08em; }
.sidebar-brand .btn-close { filter: invert(1); }
.sidebar-nav { padding: 8px; overflow-y: auto; flex: 1; }
.sidebar .nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7D746C; padding: 14px 12px 6px; }
.sidebar .nav-link { display: flex; align-items: center; gap: 12px; color: var(--sidebar-text); padding: 9px 12px; border-radius: 10px; font-size: .9rem; white-space: nowrap; }
.sidebar .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(var(--brand-rgb), .35); }
.sidebar-foot { padding: 8px; border-top: 1px solid rgba(255,255,255,.06); }

@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1030; transition: width .2s; }
  .app-main { margin-left: var(--sidebar-w); transition: margin .2s; }
  .sb-collapsed .sidebar { width: 72px !important; }
  .sb-collapsed .app-main { margin-left: 72px; }
  .sb-collapsed .sidebar .nav-link span, .sb-collapsed .sidebar .brand-text, .sb-collapsed .sidebar .nav-section { display: none; }
  .sb-collapsed .sidebar .nav-link { justify-content: center; }
}

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 1020; height: var(--topbar-h); display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.global-search { position: relative; flex: 1; max-width: 460px; margin-right: auto; }
.global-search > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input { padding-left: 36px; background: var(--surface-2); }
.search-results { width: 100%; max-height: 60vh; overflow: auto; }
.search-results.show { display: block; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

/* ---------- Content ---------- */
.content { padding: 16px 12px 96px; max-width: 1500px; }
@media (min-width: 992px) { .content { padding: 22px 28px 40px; } }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.breadcrumb { font-size: .78rem; margin-bottom: 2px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.app-foot { color: var(--muted); font-size: .78rem; padding: 0 28px 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; padding: 12px 16px; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-700); font-weight: 700; margin: 4px 0 12px; }
[data-bs-theme="dark"] .section-title { color: #FF8A3D; }

/* KPI cards */
.kpi { padding: 16px; height: 100%; position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi .kpi-icon { position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand); font-size: 1.2rem; }
.quick-actions .btn { padding: 14px; display: flex; flex-direction: column; gap: 6px; align-items: center; font-weight: 600; font-size: .85rem; height: 100%; }
.quick-actions .btn i { font-size: 1.5rem; }

/* Tables */
.table { --bs-table-bg: transparent; color: var(--text); margin: 0; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; border-bottom: 1px solid var(--border); }
.table td, .table th { vertical-align: middle; border-color: var(--border); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ⇅"; opacity: .35; }
th.sort-asc::after { content: " ▲"; opacity: .9; }
th.sort-desc::after { content: " ▼"; opacity: .9; }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; }
.dt-toolbar input { max-width: 260px; }
.dt-pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 16px; font-size: .85rem; color: var(--muted); }

/* Tables become stacked cards on phones */
@media (max-width: 767.98px) {
  table.table-cards thead { display: none; }
  table.table-cards, table.table-cards tbody, table.table-cards tr, table.table-cards td { display: block; width: 100%; }
  table.table-cards tr { border: 1px solid var(--border); border-radius: 12px; margin: 10px 0; padding: 6px 12px; background: var(--surface); }
  table.table-cards td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.table-cards td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; font-weight: 500; }
  table.table-cards td.actions { justify-content: flex-end; }
  table.table-cards td.actions::before { content: none; }
  table.table-cards tfoot { display: block; }
  table.table-cards tfoot tr { display: block; }
}

/* Empty state */
.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty-state > i { font-size: 2.6rem; color: var(--brand); display: block; margin-bottom: 10px; }
.empty-state h5 { color: var(--text); }

/* Mobile bottom nav */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: .7rem; min-height: 56px; }
.bottom-nav a i { font-size: 1.25rem; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }

/* Busy overlay */
.busy-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.18); display: none; place-items: center; z-index: 3000; }
.busy-overlay.show { display: grid; }
.text-brand.spinner-border { color: var(--brand); }

/* Badges */
.badge { font-weight: 600; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.alert-list li:last-child { border-bottom: 0; }

/* ---------- Employee form ---------- */
.photo-box { width: 120px; height: 150px; border: 2px dashed var(--border); border-radius: 12px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.emp-photo-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.form-section { scroll-margin-top: 80px; }
.sticky-actions { position: sticky; bottom: 64px; z-index: 5; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; gap: 8px; justify-content: flex-end; }
@media (min-width: 992px) { .sticky-actions { bottom: 12px; } }

/* ID card */
.id-card { width: 86mm; height: 54mm; border-radius: 10px; border: 1px solid #ddd; overflow: hidden; background: #fff; color: #222; display: flex; flex-direction: column; font-size: 10px; }
.id-card .id-top { background: var(--brand); color: #fff; padding: 6px 10px; display: flex; align-items: center; gap: 8px; }
.id-card .id-top img { width: 26px; height: 26px; background: #fff; border-radius: 50%; padding: 2px; }
.id-card .id-body { display: flex; gap: 10px; padding: 8px 10px; flex: 1; }
.id-card .id-body img.ph { width: 22mm; height: 27mm; object-fit: cover; border: 1px solid #ddd; border-radius: 4px; }

/* ---------- Attendance ---------- */
.att-legend { display: flex; flex-wrap: wrap; gap: 6px; font-size: .78rem; }
.att-legend span { padding: 3px 9px; border-radius: 6px; }
.s-P { background: var(--att-P); color: var(--att-P-t); }
.s-A { background: var(--att-A); color: var(--att-A-t); }
.s-H { background: var(--att-H); color: var(--att-H-t); }
.s-WO { background: var(--att-WO); color: var(--att-WO-t); }
.s-HL { background: var(--att-HL); color: var(--att-HL-t); }
.s-none { background: transparent; color: var(--muted); }

.att-wrap { overflow: auto; max-height: calc(100vh - 230px); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table.att-grid { border-collapse: separate; border-spacing: 0; font-size: .8rem; }
.att-grid th, .att-grid td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; text-align: center; min-width: 38px; height: 38px; }
.att-grid thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; font-weight: 600; padding: 4px 2px; line-height: 1.1; cursor: pointer; }
.att-grid thead th small { display: block; font-weight: 400; color: var(--muted); font-size: .66rem; }
.att-grid thead th.wo, .att-grid thead th.hl { color: var(--muted); }
.att-grid th.emp, .att-grid td.emp { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; min-width: 170px; max-width: 170px; padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-grid thead th.emp { z-index: 3; background: var(--surface-2); }
.att-grid td.emp small { display: block; color: var(--muted); font-size: .7rem; }
.att-grid td.sum { padding: 2px 6px; font-variant-numeric: tabular-nums; min-width: 46px; background: var(--surface-2); }
.att-cell { width: 100%; height: 38px; border: 0; font-weight: 700; font-size: .78rem; position: relative; display: block; }
.att-cell:focus { outline: 2px solid var(--brand); outline-offset: -2px; z-index: 1; }
.att-cell .dot { position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; }
.att-cell .dot.lv { background: var(--bad); }
.att-cell .dot.ot { background: var(--info); right: 11px; }
.att-cell[disabled] { opacity: .7; cursor: not-allowed; }
.att-cell.saving { opacity: .5; }

/* Day sheet (mobile friendly) */
.day-row { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
@media (min-width: 768px) { .day-row { grid-template-columns: 220px 1fr 300px; align-items: center; } }
.day-row .seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.day-row .seg button { min-height: 46px; border-radius: 10px; border: 1px solid var(--border); font-weight: 700; background: var(--surface); color: var(--text); }
.day-row .seg button.on { border-color: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.hm-input { display: flex; gap: 4px; align-items: center; }
.hm-input input { width: 64px; text-align: center; }

/* ---------- Payroll ---------- */
.status-steps { display: flex; gap: 0; flex-wrap: wrap; }
.status-steps .st { flex: 1; min-width: 110px; padding: 10px 12px; text-align: center; border: 1px solid var(--border); background: var(--surface); font-size: .82rem; color: var(--muted); }
.status-steps .st:first-child { border-radius: 10px 0 0 10px; }
.status-steps .st:last-child { border-radius: 0 10px 10px 0; }
.status-steps .st.done { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.status-steps .st.now { background: var(--brand); color: #fff; font-weight: 700; border-color: var(--brand); }
[data-bs-theme="dark"] .status-steps .st.done { color: #FF8A3D; }
.preview-table td, .preview-table th { font-size: .8rem; padding: 6px 8px; }
.preview-table .warn { color: var(--warn); }

/* Bars (category cost) */
.hbar { height: 8px; border-radius: 4px; background: var(--brand-100); overflow: hidden; }
.hbar > span { display: block; height: 100%; background: var(--brand); }
.chart-svg text { fill: var(--muted); font-size: 11px; }
.chart-svg .bar { fill: var(--brand); }
.chart-svg .bar2 { fill: var(--brand-100); }
.chart-svg .grid { stroke: var(--border); }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-50), var(--bg)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 26px; text-align: center; box-shadow: 0 10px 40px rgba(var(--brand-rgb), .12); }
.login-logo { width: 120px; height: auto; margin-bottom: 12px; }
.login-title { font-size: 1.25rem; font-weight: 800; letter-spacing: .04em; margin: 0; }
.login-sub { color: var(--muted); margin-bottom: 22px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 50px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; transition: box-shadow .15s, border-color .15s; }
.btn-google:hover { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .15); color: var(--text); }
.login-note { font-size: .78rem; color: var(--muted); margin: 16px 0 0; }
.login-foot { margin-top: 18px; color: var(--muted); font-size: .78rem; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .page-actions, .breadcrumb, .no-print, .app-foot, .dt-toolbar, .dt-pager, .toast-container { display: none !important; }
  .app-main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body, html { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none; border: 0; }
  [data-bs-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f5f5f5; --text: #000; --border: #ccc; --muted: #555; }
  table.table-cards thead { display: table-header-group !important; }
  table.table-cards tr { display: table-row !important; }
  table.table-cards td { display: table-cell !important; }
  table.table-cards td::before { content: none !important; }
}
.nav-pills .nav-link { color: var(--text); border-radius: 10px; }
.nav-pills .nav-link.active { background: var(--brand); color: #fff; }
kbd { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
/* Bootstrap makes .offcanvas-lg transparent on desktop — keep the sidebar dark */
.sidebar.offcanvas-lg { background-color: var(--sidebar-bg) !important; }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { width: 280px !important; } }
.kpi .kpi-label { padding-right: 46px; }
@media (max-width: 575.98px) {
  .att-grid th.emp, .att-grid td.emp { min-width: 118px; max-width: 118px; }
  .kpi .kpi-value { font-size: 1.3rem; }
}
