:root {
  --accent: #0aa3c2;
  --accent-dark: #087e96;
  --ink: #1a2230;
  --muted: #667085;
  --line: #e3e8ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --good: #1f9d57;
  --warn: #d98a00;
  --bad: #d64545;
  --al: #0aa3c2;
  --sl: #d98a00;
  --lwop: #8a63d2;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
/* hidden must always win — otherwise display:flex on .auth keeps the overlay visible */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0 0 .5em; }
a { color: var(--accent-dark); }

/* ---- auth ---- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: linear-gradient(160deg, #0aa3c2 0%, #075f72 100%);
}
.auth-card {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 380px; padding: 28px;
}
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-msg { color: var(--bad); min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.auth-msg.ok { color: var(--good); }
.field { display: block; margin: 14px 0 4px; font-weight: 600; font-size: 14px; }
.auth input, .auth select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; background: #fff;
}
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 11px 16px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
}
.btn:hover { background: var(--accent-dark); }
.btn.block { width: 100%; margin-top: 18px; }
.btn.secondary { background: #eef2f6; color: var(--ink); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: var(--bad); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 18px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; font-size: 18px; color: var(--accent-dark); }
.brand span { color: var(--ink); font-weight: 600; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  border: none; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; color: var(--muted); font-size: 14px;
}
.tab:hover { background: #eef2f6; color: var(--ink); }
.tab.active { background: var(--accent); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; }
.who-name { font-weight: 600; }
.who-role {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  background: #eef2f6; color: var(--muted); padding: 2px 8px; border-radius: 999px;
}
.who-role.admin { background: #e7f6fb; color: var(--accent-dark); }
.text-btn { border: none; background: transparent; color: var(--muted); font-weight: 600; }
.text-btn:hover { color: var(--bad); }

/* ---- views ---- */
.view { padding: 20px; max-width: 1000px; margin: 0 auto; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.section-title { font-size: 16px; font-weight: 700; }

/* week nav */
.weeknav { display: flex; align-items: center; gap: 10px; }
.weeknav .nav-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 36px; height: 36px; font-size: 16px;
}
.week-label { font-weight: 700; min-width: 220px; text-align: center; }

/* status pill */
.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.pill.draft { background: #eef2f6; color: var(--muted); }
.pill.submitted { background: #fff4e0; color: var(--warn); }
.pill.approved { background: #e6f6ec; color: var(--good); }

/* timesheet table */
.ts-table, .data-table { width: 100%; border-collapse: collapse; }
.ts-table th, .ts-table td, .data-table th, .data-table td {
  border-bottom: 1px solid var(--line); padding: 8px 8px; text-align: left; vertical-align: middle;
}
.ts-table th, .data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.ts-table td .daycell { font-weight: 600; }
.ts-table td .datecell { font-size: 12px; color: var(--muted); }
.ts-table input[type=time], .ts-table input[type=number], .ts-table input[type=text], .ts-table select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: 14px; width: 100%;
  background: #fff;
}
.ts-table input[type=number] { width: 80px; }
.ts-table .hours { font-weight: 700; }
.ts-row.is-leave { background: #fbf7ff; }
.ts-row.weekend td .daycell { color: var(--muted); }
.ts-foot { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-top: 14px; }
.ts-foot .note { flex: 1; min-width: 240px; }
.ts-foot textarea {
  width: 100%; min-height: 54px; border: 1px solid var(--line); border-radius: 10px; padding: 9px; font-size: 14px;
  font-family: inherit; resize: vertical;
}
.ts-total { font-size: 22px; font-weight: 800; }
.ts-total small { font-size: 13px; font-weight: 600; color: var(--muted); display: block; }
.actions-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.locked-banner {
  background: #e6f6ec; border: 1px solid #bfe6cd; color: #1c7a47; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; font-weight: 600;
}

/* balance cards */
.bal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.bal {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--card);
}
.bal h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 0; }
.bal .big { font-size: 30px; font-weight: 800; margin: 6px 0 2px; }
.bal .sub { color: var(--muted); font-size: 13px; }
.bar { height: 10px; border-radius: 999px; background: #eef2f6; overflow: hidden; margin-top: 12px; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.bal.al .bar > span { background: var(--al); }
.bal.sl .bar > span { background: var(--sl); }
.bal.lwop .big { color: var(--lwop); }

/* data tables */
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .name-link { color: var(--accent-dark); font-weight: 700; background: none; border: none; padding: 0; font-size: 15px; }
.data-table .name-link:hover { text-decoration: underline; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select, .toolbar input[type=number] {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
}
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.tag.al { background: #e7f6fb; color: var(--accent-dark); }
.tag.sl { background: #fff4e0; color: var(--warn); }
.tag.lwop { background: #f1ebfb; color: var(--lwop); }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal h2 { font-size: 18px; }
.modal label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.modal input, .modal select {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; background: #fff;
}
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; z-index: 100; box-shadow: var(--shadow);
}
.toast.bad { background: var(--bad); }

@media (max-width: 720px) {
  .view { padding: 12px; }
  .topbar { gap: 10px; }
  .week-label { min-width: 0; font-size: 14px; }
  .ts-table { font-size: 13px; display: block; overflow-x: auto; }
  .who-name { display: none; }
}
