:root {
  --primary: #0065ee;
  --primary-dark: #0049b8;
  --primary-light: #dbeafe;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #059669;
  --red: #dc2626;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans Sinhala", "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* Header — full-bleed blue, edge-to-edge safe-area aware */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 18px;
}
.header-title { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.header-sub { font-size: 13px; opacity: 0.85; margin-top: 2px; }

main { flex: 1; padding: 16px 16px calc(84px + env(safe-area-inset-bottom, 0px)); }
.tab { display: none; }
.tab.active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin-top: 10px; }

input[type="number"], input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--primary); background: #fff; }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row .cur { font-weight: 700; color: var(--muted); font-size: 15px; }
.input-row input { flex: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }

/* OT hours rows */
.hour-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.hour-row:last-child { border-bottom: none; }
.hour-label { font-size: 15px; font-weight: 600; }
.hour-mult { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.hour-amount { font-size: 13px; color: var(--primary); font-weight: 700; margin-top: 2px; }

/* Result */
.result-card { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 15px; padding: 4px 0; }
.result-row.total { font-size: 18px; padding-top: 10px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.3); }
.result-row.total strong { font-size: 24px; }
.breakdown { margin-top: 10px; font-size: 13px; opacity: 0.9; line-height: 1.7; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn:active { transform: scale(0.98); }
.btn.danger-outline { color: var(--red); border-color: #fecaca; background: #fff; width: 100%; margin-top: 12px; }

/* History */
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.history-item:last-child { border-bottom: none; }
.history-month { font-weight: 700; font-size: 15px; }
.history-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.history-total { font-weight: 800; color: var(--primary); font-size: 15px; white-space: nowrap; }
.history-del { background: none; border: none; color: var(--red); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 0; }

/* Settings multipliers */
.mult-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mult-row:last-of-type { border-bottom: none; }
.mult-row .field-label { margin-bottom: 0; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 10;
}
.nav-btn {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.nav-btn.active { color: var(--primary); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
