:root {
  --ink: #1c1917;
  --muted: #6b6258;
  --line: #e4ddd3;
  --paper: #f3efe7;
  --card: #fffcf7;
  --sidebar: #1f2933;
  --sidebar-2: #2a3640;
  --amber: #c4841d;
  --amber-2: #f1c40f;
  --green: #2f7d4a;
  --red: #b42318;
  --blue: #1d4e89;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Noto Sans Sinhala", "Source Sans 3", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #15202a 100%);
  color: #f8f4ec;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 10px 22px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--amber-2); color: #1c1917;
  display: grid; place-items: center; font-weight: 800; letter-spacing: -0.04em;
}
.brand h1 { font-size: 16px; margin: 0; }
.brand p { margin: 2px 0 0; font-size: 11px; color: #c5bbae; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  color: #ddd4c6; text-decoration: none; font-size: 14px; margin-bottom: 4px;
}
.nav a:hover { background: var(--sidebar-2); color: #fff; }
.nav a.active { background: var(--amber-2); color: #1c1917; font-weight: 700; }
.nav .dot { width: 8px; height: 8px; border-radius: 99px; background: currentColor; opacity: 0.7; }
.sidebar-foot { margin-top: auto; padding: 18px 10px 4px; font-size: 12px; color: #c5bbae; }
.sidebar { display: flex; flex-direction: column; }

.main { padding: 22px 28px 48px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; }
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.topbar .sub { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 0; background: var(--ink); color: #fff;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  text-decoration: none; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.btn.amber { background: var(--amber); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.wa { background: #128c7e; color: #fff; }
.btn.small { padding: 6px 10px; font-size: 12px; }

.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, 1fr); }
.att-stats { grid-template-columns: repeat(5, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 28px; font-weight: 750; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat.alert { border-color: #f3c0b8; background: #fff6f4; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid #efe8dc; vertical-align: middle; }
tr:hover td { background: #faf6ef; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge {
  display: inline-flex; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge.present, .badge.ok, .badge.approved, .badge.final { background: #dcf5e4; color: #166534; }
.badge.late { background: #fef3c7; color: #92400e; }
.badge.absent, .badge.error, .badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.pending, .badge.draft { background: #e0e7ff; color: #3730a3; }
.badge.leave, .badge.holiday { background: #f3e8ff; color: #6b21a8; }
.badge.unmarked, .badge.none { background: #fef3c7; color: #92400e; }
.badge.active { background: #dbeafe; color: #1e40af; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  background: #fff; color: var(--ink); font-size: 14px;
}
textarea { min-height: 80px; resize: vertical; }
.search { min-width: 240px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash.ok { background: #dcf5e4; }
.flash.error { background: #fee2e2; }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(900px 400px at 10% 0%, #f1c40f55, transparent),
    linear-gradient(160deg, #1f2933, #3d4d3f);
}
.login-card {
  width: min(920px, 94vw); display: grid; grid-template-columns: 1.1fr 1fr;
  background: var(--card); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
}
.login-art { padding: 36px; background: #24303a; color: #f8f4ec; }
.login-art h2 { font-size: 32px; margin: 40px 0 10px; }
.login-art p { color: #d7cbb8; line-height: 1.5; }
.login-form { padding: 36px; }
.hint { background: #f7f1e4; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 18px; color: #5b5348; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a, .tabs span, .tabs button {
  padding: 7px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; font-size: 13px; cursor: pointer; color: inherit;
}
.tabs a.on, .tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.split { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 16px; }
.muted { color: var(--muted); }
.emp-hero { display: flex; gap: 16px; align-items: center; }
.avatar {
  width: 64px; height: 64px; border-radius: 18px; background: #24303a; color: var(--amber-2);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
}
.payslip { max-width: 800px; margin: 0 auto; background: #fff; padding: 28px; }
.payslip table td, .payslip table th { border-bottom: 1px dashed #ddd; }
@media print {
  @page { size: A4; margin: 12mm; }
  .no-print, .flash, .side-search { display: none !important; }
  .print-only { display: block !important; }
  .layout { display: block; }
  .sidebar, .topbar { display: none !important; }
  .main { padding: 0; }
  .payslip, .card { box-shadow: none; border: 0; padding: 0; }
  .report-head { margin-bottom: 10px; }
  .report-head h2 { margin: 0 0 4px; font-size: 16px; }
  .report-head p { margin: 0 0 8px; color: #555; font-size: 11px; }
  a { text-decoration: none; color: inherit; }
  table { font-size: 10px; }
  th, td { padding: 4px 6px; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  .split { display: block; }
  .badge { border: 1px solid #ccc; }
}
.print-only { display: none; }
.report-cards { grid-template-columns: repeat(3, 1fr); margin-bottom: 8px; }
.report-card { text-decoration: none; display: block; }
.report-card h3 { margin: 0 0 8px; }
.report-card p { color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 54px; }
.filterbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px;
}
.filterbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

.emp-combo { position: relative; }
.emp-combo input[type="search"] {
  width: 100%;
}
.emp-combo .emp-list {
  display: none;
  position: absolute;
  z-index: 40;
  left: 0; right: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.emp-combo.open .emp-list { display: block; }
.emp-combo .emp-item {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent;
  padding: 9px 12px; cursor: pointer; font-size: 14px;
}
.emp-combo .emp-item:hover, .emp-combo .emp-item.active { background: #f7f1e4; }
.emp-combo .emp-item .no { font-weight: 700; margin-right: 6px; }
.emp-combo .emp-item .si { color: var(--muted); font-size: 12px; }
.emp-combo .emp-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.emp-combo select.emp-search { position: absolute; opacity: 0; pointer-events: none; height: 0; }

.side-search { position: relative; margin: 0 8px 16px; }
.side-search input {
  width: 100%; background: #2a3640; border-color: #425260; color: #f8f4ec;
}
.side-search input::placeholder { color: #c5bbae; }
.side-search .emp-list {
  display: block; position: absolute; z-index: 50;
  left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow: auto;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.side-search .emp-list[hidden] { display: none; }
.side-search .emp-item { text-decoration: none; }

.att-filterbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.att-filterbar input { min-width: 220px; flex: 1; }
.att-quick { gap: 4px; }
.att-times input[type="time"] { width: 112px; }
.row-unmarked td { background: #fffbeb; }
.dash-att { max-height: 440px; overflow: auto; }
.pending-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.pending-row:last-child { border-bottom: 0; }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.confirm-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(28, 25, 23, 0.5);
  display: none;
  place-items: center;
  padding: 16px;
}
.confirm-overlay:not([hidden]) { display: grid; }
.confirm-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px 22px 18px;
  width: min(440px, 100%); box-shadow: var(--shadow);
}
.confirm-box p { margin: 0 0 18px; font-size: 15px; line-height: 1.5; }
.att-toolbar form { display: flex; gap: 8px; align-items: center; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
  .stats, .att-stats, .split, .form-grid, .form-grid.three, .login-card, .report-cards { grid-template-columns: 1fr; }
}
