/* ===========================================================
   Kanakku — design tokens
   Ledger/passbook identity: warm paper, deep ink, old-gold accent.
   =========================================================== */
:root {
  --bg: #f5efdc;
  --bg-alt: #ece1be;
  --panel: #fffdf6;
  --ink: #1f2d50;
  --ink-soft: #55618a;
  --gold: #a6791e;
  --gold-deep: #8c6417;
  --green: #2f6b4f;
  --brick: #a63d2f;
  --border: #d8cba0;
  --white: #ffffff;
  --radius: 10px;
  --font-display: 'Baloo Thambi 2', 'Noto Sans Tamil', sans-serif;
  --font-body: 'Noto Sans', 'Noto Sans Tamil', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
}

a { color: var(--gold-deep); }

button { font-family: inherit; }

/* Layout shell */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--ink);
  color: var(--bg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar .brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.topbar .brand .tamil { font-size: 1.1rem; opacity: 0.85; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--bg);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

/* Language toggle: segmented pill */
.lang-toggle {
  display: flex;
  border: 1px solid var(--gold);
  border-radius: 999px;
  overflow: hidden;
  font-size: 0.8rem;
}
.lang-toggle button {
  border: none;
  background: transparent;
  color: var(--bg);
  padding: 5px 10px;
  cursor: pointer;
}
.lang-toggle button.active {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
}
.lang-toggle.on-light { border-color: var(--gold-deep); }
.lang-toggle.on-light button { color: var(--ink-soft); }
.lang-toggle.on-light button.active { color: var(--ink); }

main {
  flex: 1;
  padding: 18px 16px 96px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

/* Passbook panel — used on the login screen */
.passbook {
  max-width: 380px;
  margin: 10vh auto 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 2px 0 var(--border);
}

.passbook .brand-block {
  text-align: center;
  margin-bottom: 22px;
}
.passbook .brand-block h1 { font-size: 2rem; color: var(--ink); }
.passbook .brand-block .tamil { font-size: 1.2rem; color: var(--gold-deep); }
.passbook .brand-block .tagline {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 1rem;
  font-family: var(--font-body);
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.hint { font-size: 0.8rem; color: var(--ink-soft); margin-top: 4px; }
.error-text { font-size: 0.9rem; color: var(--brick); margin-top: 10px; min-height: 1.2em; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border-radius: 8px;
  border: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
}
.btn-primary { background: var(--gold); color: var(--ink); font-weight: 700; }
.btn-primary:active { background: var(--gold-deep); }
.btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn-danger { background: transparent; color: var(--brick); border: 1.5px solid var(--brick); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* Section heading with count */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 12px;
}
.section-head h2 { font-size: 1.25rem; }
.section-head .count { color: var(--ink-soft); font-size: 0.9rem; }

/* Ledger-style task rows */
.task-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
  padding-left: 18px;
}
.task-row:last-child { border-bottom: none; }
.task-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
}
.task-row[data-status="pending"]::before,
.task-row[data-status="carried_over"]::before { background: var(--gold); }
.task-row[data-status="missed"]::before { background: var(--brick); }
.task-row[data-status="done"]::before { background: var(--green); }

.task-row .task-main { flex: 1; min-width: 0; }
.task-row .task-desc { font-weight: 600; }
.task-row .task-meta { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.task-row .status-label {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.task-row[data-status="pending"] .status-label,
.task-row[data-status="carried_over"] .status-label { color: var(--gold-deep); }
.task-row[data-status="missed"] .status-label { color: var(--brick); }
.task-row[data-status="done"] .status-label { color: var(--green); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state .big { font-size: 2rem; margin-bottom: 8px; }

/* Floating action button + menu */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
  border: none;
  font-size: 1.8rem;
  box-shadow: 0 3px 10px rgba(31,45,80,0.35);
  cursor: pointer;
  z-index: 10;
}
.fab-menu {
  position: fixed;
  right: 20px;
  bottom: 94px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10;
}
.fab-menu.hidden { display: none; }
.fab-menu a, .fab-menu button {
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  text-align: left;
}

/* Audio recorder widget */
.audio-recorder {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--white);
}
.audio-recorder .rec-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--brick);
  color: var(--white);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}
.audio-recorder .rec-btn.idle { background: var(--gold); }
.audio-recorder .rec-status { font-size: 0.85rem; color: var(--ink-soft); flex: 1; }
.audio-recorder audio { max-width: 100%; height: 34px; }

/* Top-level page helpers */
.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
}

/* Admin panel: staff rows and stat pills */
.data-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}
.data-row {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.data-row:last-child { border-bottom: none; }
.data-row .row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.data-row .name-block { font-weight: 700; }
.data-row .sub { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-alt);
  color: var(--ink);
}
.pill.active { color: var(--green); }
.pill.inactive { color: var(--brick); }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions input[type="number"] {
  width: 64px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.row-actions .btn {
  width: auto;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.stat-box {
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 8px 10px;
}
.stat-box .num { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); }
.stat-box .label { font-size: 0.72rem; color: var(--ink-soft); }
.target-progress {
  font-family: var(--font-display);
  font-size: 1.4rem;
}
.target-progress.behind { color: var(--brick); }
.target-progress.ontrack { color: var(--green); }

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