:root {
  --bg: #f1f5f4;
  --card: #ffffff;
  --text: #13201e;
  --muted: #5d6b69;
  --line: #dde5e3;
  --accent: #0f766e;
  --accent-soft: #d5efe9;
  --danger: #b42318;
  --today: #f59e0b;
}

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

html, body { margin: 0; }

[hidden] { display: none !important; }

body {
  font-family: "Noto Sans Malayalam", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  position: sticky; top: 0; z-index: 5;
}
.top h1 { margin: 0; font-size: 22px; }
.top .icon-btn { color: #fff; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 26px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:active { background: rgba(0,0,0,.08); }

.tabs {
  position: fixed; z-index: 6;
  left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
  padding: 6px; border-radius: 22px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.08);
}
.tab {
  border: 2px solid transparent; border-radius: 16px;
  padding: 6px 4px; font-weight: 600; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 0;
}
.tab span { font-size: 24px; }
.tab.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

main { padding: 12px 16px calc(110px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }

.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 8px; font-size: 18px; }

.due { text-align: center; }
.due-label { color: var(--muted); font-weight: 600; }
.due-amount { font-size: 44px; font-weight: 700; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.due-amount.zero { color: var(--accent); }

.btn {
  border-radius: 14px; padding: 12px 16px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: #fde8e6; color: var(--danger); }
.btn.big { width: 100%; font-size: 19px; padding: 14px; }
.btn:active { filter: brightness(.92); }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-title { font-size: 20px; font-weight: 700; }

.month-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
  margin: 8px 0 12px; text-align: center;
}
.month-stats div { background: var(--bg); border-radius: 12px; padding: 6px 2px; }
.month-stats small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.month-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.weekdays { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 5px; }

.day {
  aspect-ratio: 1 / 1.1; border-radius: 12px; border: 1.5px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 600; font-size: 17px; padding: 0; min-width: 0;
}
.day .amt { font-size: 10.5px; font-weight: 600; line-height: 1; margin-top: 2px; }
.day.marked { background: var(--accent); border-color: var(--accent); color: #fff; }
.day.worked { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.day.absent { background: #fde8e6; border-color: #f5b5ae; color: var(--danger); }
.day.extra { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.day.absent .amt { font-size: 10px; }

.legend { display: flex; justify-content: center; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw.worked { background: var(--accent-soft); border: 1px solid var(--accent); }
.sw.absent { background: #fde8e6; border: 1px solid var(--danger); }
.sw.extra { background: #fef3c7; border: 1px solid #f59e0b; }

.worker-info {
  display: block; width: 100%; margin-top: 10px; padding: 10px;
  background: var(--bg); border-radius: 12px; font-size: 14px; color: var(--muted); font-weight: 600;
}

.day.today { border: 2.5px solid var(--today); }
.day.future { opacity: .45; }
.day.empty { border: 0; }

.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 0; }

.payments { list-style: none; margin: 0; padding: 0; }
.payments li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.payments li:first-child { border-top: 0; }
.payments .p-amt { font-weight: 700; font-size: 18px; }
.payments .p-date { color: var(--muted); font-size: 14px; flex: 1; }
.payments .del { color: var(--danger); font-size: 20px; width: 40px; height: 40px; border-radius: 10px; }
.payments .empty-msg { color: var(--muted); justify-content: center; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet h3 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.sheet label { display: block; font-weight: 600; margin: 10px 0 4px; color: var(--muted); }
.sheet input {
  width: 100%; font: inherit; font-size: 26px; font-weight: 700;
  padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px;
  text-align: center; font-variant-numeric: tabular-nums;
}
.sheet input[type=date] { font-size: 18px; }
.sheet input:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: center; }
.chip {
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 18px;
  padding: 8px 16px; border-radius: 999px;
}
.chip:active { filter: brightness(.9); }
.sheet .actions { display: grid; gap: 8px; margin-top: 16px; }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #13201e; color: #fff; padding: 10px 18px; border-radius: 999px;
  z-index: 20; font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1413; --card: #17201f; --text: #e8efed; --muted: #97a6a3;
    --line: #2a3634; --accent: #2bb3a3; --accent-soft: #163b36;
  }
  .top { background: #115e56; }
  .day.marked { color: #062522; }
  .btn.danger { background: #3b1715; color: #ff9b91; }
  .day.absent, .sw.absent { background: #3b1715; border-color: #7a2a24; color: #ff9b91; }
  .day.extra, .sw.extra { background: #3d2e0a; border-color: #b7791f; color: #fcd34d; }
}

.sheet .note { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 0 0; }
