/* =========================================================================
   Payroll Tracker — "modern ledger" theme
   Rebrand by editing the --brand* variables below.
   ========================================================================= */
:root {
  /* Brand — DHANVI Tunneling (provisional; swap to exact logo colors) */
  --brand-ink:    #12314a;   /* deep tunnel-slate blue (header, primary) */
  --brand-ink-2:  #1c4a66;   /* lighter slate for gradient */
  --brand-money:  #e08a1e;   /* safety amber — money / net pay accent */
  --brand-money-2:#f2a942;

  /* Semantic */
  --present: #1f7a5f;
  --absent:  #c04a3f;
  --half:    #c07d1e;
  --night:   #3f5578;

  /* Paper / surfaces (cool, not cream) */
  --paper:   #eef1f6;
  --surface: #ffffff;
  --line:    #dde3ec;
  --ink-1:   #1b2740;   /* primary text */
  --ink-2:   #5a667c;   /* secondary text */
  --ink-3:   #8b97ac;   /* muted */

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(27,39,64,.06), 0 6px 18px rgba(27,39,64,.06);
  --tap: 46px;
  --maxw: 480px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The `hidden` attribute must beat any display rule below (modal, spinner, etc.) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
}

/* lock to a comfortable phone column, centered on larger screens */
body {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: contain;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- Header ---------- */
.app-header {
  background: linear-gradient(135deg, var(--brand-ink) 0%, var(--brand-ink-2) 100%);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  position: sticky; top: 0; z-index: 20;
}
.header-row { display: flex; align-items: center; gap: 10px; }
.logo-chip {
  flex-shrink: 0; background: #fff; border-radius: 10px; padding: 5px 7px;
  display: inline-flex; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.logo-chip img { height: 30px; width: auto; max-width: 90px; object-fit: contain; display: block; }
.brand { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.app-title-main { font-size: 1.05rem; font-weight: 700; letter-spacing: .2px; line-height: 1.1; }
.company {
  font-size: .68rem; font-weight: 600; letter-spacing: .02em; margin-top: 2px;
  color: rgba(255,255,255,.66);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.month-pill {
  display: inline-flex; flex-direction: column; align-items: flex-end;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 5px 12px; flex-shrink: 0;
}
.month-pill__label { font-size: .58rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.month-pill input[type="month"] {
  background: transparent; border: 0; color: #fff; font-size: .84rem; font-weight: 600;
  font-family: inherit; padding: 0; min-width: 92px;
}
.month-pill input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .7; }

/* ---------- Main ---------- */
.app-main { flex: 1; padding: 14px 14px 24px; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card__title { margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.field--inline .field__label { flex-shrink: 0; }
.field__opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-3); font-size: .9em; }

select, input[type="date"], input[type="number"], input[type="text"] {
  width: 100%; min-height: var(--tap);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 12px; font-size: 1rem; font-family: inherit; color: var(--ink-1);
  font-variant-numeric: tabular-nums;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235a667c' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
select:focus, input:focus { outline: none; border-color: var(--brand-ink-2); box-shadow: 0 0 0 3px rgba(43,60,99,.14); }
.field--inline input[type="date"] { width: auto; flex: 1; }
.field--hours { flex: 1; }
.field--hours input { text-align: center; }

/* Empty state */
.empty { text-align: center; padding: 34px 20px; color: var(--ink-2); }
.empty__mark {
  width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 16px;
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--brand-money), var(--brand-money-2));
}
.empty__text { margin: 0; font-size: .95rem; }

/* ---------- Payslip (signature) ---------- */
.payslip { padding: 0; overflow: hidden; }
.payslip__top { padding: 14px 16px 12px; border-bottom: 1px dashed var(--line); }
.payslip__who { display: flex; flex-direction: column; }
.payslip__name { font-size: 1.24rem; font-weight: 700; line-height: 1.15; }
.payslip__meta { font-size: .84rem; color: var(--ink-2); margin-top: 2px; }
.payslip__meta .num, #empSalary { font-variant-numeric: tabular-nums; }

.payslip__total {
  position: relative; padding: 16px 16px 18px;
  background:
    linear-gradient(135deg, rgba(224,138,30,.07), rgba(242,169,66,.04));
  display: flex; flex-direction: column; align-items: flex-start;
}
.payslip__label { font-size: .68rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--brand-money); }
.payslip__amount {
  font-size: 2.5rem; font-weight: 800; line-height: 1; margin: 4px 0 6px;
  color: var(--brand-ink); font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.payslip__days { font-size: .82rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* stamp corner */
.payslip__total::after {
  content: "PAID"; position: absolute; top: 14px; right: 12px;
  font-size: .62rem; font-weight: 800; letter-spacing: .18em;
  color: rgba(224,138,30,.55); border: 2px solid rgba(224,138,30,.4);
  padding: 3px 7px; border-radius: 6px; transform: rotate(-8deg);
}

/* ---------- Tally tiles ---------- */
.tally { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 4px; text-align: center; box-shadow: var(--shadow);
  border-top: 3px solid var(--ink-3);
}
.tile__num { display: block; font-size: 1.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tile__key { display: block; font-size: .64rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-top: 4px; }
.tile--present { border-top-color: var(--present); } .tile--present .tile__num { color: var(--present); }
.tile--absent  { border-top-color: var(--absent);  } .tile--absent  .tile__num { color: var(--absent); }
.tile--half    { border-top-color: var(--half);    } .tile--half    .tile__num { color: var(--half); }
.tile--night   { border-top-color: var(--night);   } .tile--night   .tile__num { color: var(--night); }

/* ---------- Mark attendance ---------- */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg {
  min-height: var(--tap); border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: var(--radius-sm); font-size: .95rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: transform .05s ease;
}
.seg:active { transform: scale(.97); }
.seg[aria-pressed="true"][data-status="Present"] { background: var(--present); border-color: var(--present); color: #fff; }
.seg[aria-pressed="true"][data-status="Half Day"] { background: var(--half); border-color: var(--half); color: #fff; }
.seg[aria-pressed="true"][data-status="Absent"]  { background: var(--absent); border-color: var(--absent); color: #fff; }

.mark__row { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.night-toggle {
  min-height: var(--tap); flex: 1; border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: var(--radius-sm); font-size: .92rem; font-weight: 700; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.night-toggle__moon { font-size: 1.05rem; }
.night-toggle[aria-pressed="true"] { background: var(--night); border-color: var(--night); color: #fff; }

.hint { font-size: .78rem; color: var(--ink-2); margin: 10px 0 0; min-height: 1.1em; font-variant-numeric: tabular-nums; }
.edit-note { font-size: .78rem; color: var(--brand-money); margin: 8px 0 0; font-weight: 600; }

/* Buttons */
.btn {
  width: 100%; min-height: var(--tap); border: 0; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 700; font-family: inherit; cursor: pointer; margin-top: 12px;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--brand-ink); color: #fff; }
.btn--ghost { background: #fff; border: 1.5px solid var(--line); color: var(--ink-1); }
.btn--danger { background: var(--absent); color: #fff; }
.btn--danger-ghost { background: #fff; border: 1.5px solid var(--absent); color: var(--absent); }

/* Disclosure / details */
.disclosure {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: .84rem; font-weight: 700; color: var(--ink-1); padding: 2px 0;
}
.disclosure::-webkit-details-marker { display: none; }
.disclosure::before { content: "▸"; color: var(--ink-3); transition: transform .15s ease; }
details[open] .disclosure::before { transform: rotate(90deg); }
.disclosure__hint {
  margin-left: auto; font-size: .72rem; font-weight: 600; color: var(--ink-2);
  background: var(--paper); border-radius: 999px; padding: 2px 9px; font-variant-numeric: tabular-nums;
}
.adj-body { padding-top: 12px; }
.adj-body .mark__row { margin-top: 0; }

/* Entries list */
.entries { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entry {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; cursor: pointer;
  border-left: 4px solid var(--ink-3);
}
.entry:active { background: var(--paper); }
.entry--Present { border-left-color: var(--present); }
.entry--Half.Day, .entry--HalfDay { border-left-color: var(--half); }
.entry--Absent  { border-left-color: var(--absent); }
.entry__date { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 46px; }
.entry__body { flex: 1; min-width: 0; }
.entry__status { font-size: .92rem; font-weight: 600; }
.entry__sub { font-size: .74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.entry__val { font-weight: 800; color: var(--brand-ink); font-variant-numeric: tabular-nums; }
.entry__night { color: var(--night); font-weight: 700; }
.entries__empty { color: var(--ink-2); font-size: .88rem; padding: 8px 2px; }

/* Footer */
.app-footer {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 16px);
  font-size: .72rem; color: var(--ink-3);
}
.footer-logo { height: 22px; width: auto; opacity: .7; }

/* Offline banner */
.offline-banner {
  background: var(--absent); color: #fff; text-align: center;
  font-size: .8rem; font-weight: 600; padding: 7px 12px;
}

/* Spinner */
.spinner-overlay { position: fixed; inset: 0; background: rgba(27,39,64,.28); display: grid; place-items: center; z-index: 60; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: var(--ink-1); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; z-index: 70; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: 90%; text-align: center;
}
.toast--error { background: var(--absent); }
.toast--success { background: var(--present); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(27,39,64,.5); display: grid; place-items: center; z-index: 80; padding: 24px; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal__title { margin: 0 0 8px; font-size: 1.1rem; }
.modal__body { margin: 0 0 18px; font-size: .92rem; color: var(--ink-2); }
.modal__actions { display: flex; gap: 10px; }
.modal__actions .btn { margin-top: 0; }
.field--stack { margin-top: 12px; }
.modal__actions--stack { margin-top: 18px; }

/* Field validation */
.field--error select, .field--error input, .segmented.field--error { border-color: var(--absent) !important; }
.field-error-msg { color: var(--absent); font-size: .74rem; margin-top: 4px; }

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