/* Palettes: each sets accents, chart colors and the light/dark grounds. */
:root, :root[data-palette="forest"] {
  --accent: #2f7d4a; --accent-2: #8cc152; --accent-3: #f0a830;
  --grad: linear-gradient(135deg, #1e5631 0%, #3f8f4e 42%, #a4c639 74%, #f0b429 100%);
  --hero-glow: rgba(63, 143, 78, 0.55);
  --loc-1: #3f8f4e; --loc-2: #2a9d8f; --loc-3: #f0a830; --loc-4: #d9573b; --loc-5: #8b5e3c; --loc-6: #7b8fd6;
  --k1: #3f8f4e; --k2: #a4c639; --k3: #f0a830; --k4: #2a9d8f;
  --series-1: #5aa83b; --series-2: #f0a830; --series-3: #8b5e3c;
  --bar-top: #b5d65a; --bar-bottom: #2f7d4a; --heat-lo: #1e5631; --heat-hi: #c6e06b;
  --blob-1: #2f7d4a; --blob-2: #a4c639; --blob-3: #f0a830;
  --bg-l: #f2f0e3; --surface-l: rgba(255, 253, 244, 0.82); --solid-l: #fffdf4; --text-l: #1b2a1f; --muted-l: #5f6f5f; --line-l: rgba(30, 60, 35, 0.13); --input-l: #e8e6d4;
  --bg-d: #0c1810; --surface-d: rgba(20, 38, 26, 0.8); --solid-d: #15281b; --text-d: #eef5e9; --muted-d: #9fb5a3; --line-d: rgba(180, 230, 190, 0.12); --input-d: #1f3526;
  --ink: #102016;
}
:root[data-palette="autumn"] {
  --accent: #c2522d; --accent-2: #e8a33d; --accent-3: #7a8c3a;
  --grad: linear-gradient(135deg, #7a2e1f 0%, #c2522d 40%, #e8a33d 75%, #f2d16b 100%);
  --hero-glow: rgba(194, 82, 45, 0.55);
  --loc-1: #c2522d; --loc-2: #5b8a72; --loc-3: #e8a33d; --loc-4: #8b5e3c; --loc-5: #7a8c3a; --loc-6: #a35d8a;
  --k1: #c2522d; --k2: #e8a33d; --k3: #7a8c3a; --k4: #5b8a72;
  --series-1: #c2522d; --series-2: #e8a33d; --series-3: #7a8c3a;
  --bar-top: #f0b24a; --bar-bottom: #a63d24; --heat-lo: #7a2e1f; --heat-hi: #f2c14e;
  --blob-1: #c2522d; --blob-2: #e8a33d; --blob-3: #7a8c3a;
  --bg-l: #f7efe4; --surface-l: rgba(255, 250, 243, 0.82); --solid-l: #fffaf3; --text-l: #2b1b14; --muted-l: #7a6455; --line-l: rgba(90, 50, 20, 0.13); --input-l: #efe2d0;
  --bg-d: #1a0f0a; --surface-d: rgba(40, 24, 16, 0.8); --solid-d: #2a1a12; --text-d: #f8ede3; --muted-d: #c2a894; --line-d: rgba(255, 210, 170, 0.12); --input-d: #3a261a;
  --ink: #2b1b14;
}
:root[data-palette="candy"] {
  --accent: #ff4fa3; --accent-2: #4cc9f0; --accent-3: #ffc93c;
  --grad: linear-gradient(135deg, #ff6fb5 0%, #c77dff 36%, #6fd6ff 68%, #7ee8b5 100%);
  --hero-glow: rgba(255, 111, 181, 0.55);
  --loc-1: #ff5fa8; --loc-2: #4cc9f0; --loc-3: #ffc93c; --loc-4: #9b5de5; --loc-5: #2ec4a0; --loc-6: #ff8a5b;
  --k1: #ff5fa8; --k2: #9b5de5; --k3: #ffc93c; --k4: #4cc9f0;
  --series-1: #ff5fa8; --series-2: #ffc93c; --series-3: #9b5de5;
  --bar-top: #ff8ccf; --bar-bottom: #9b5de5; --heat-lo: #9b5de5; --heat-hi: #ff8ccf;
  --blob-1: #ff8ccf; --blob-2: #6fd6ff; --blob-3: #ffe066;
  --bg-l: #fff4fa; --surface-l: rgba(255, 255, 255, 0.82); --solid-l: #ffffff; --text-l: #3a1838; --muted-l: #8a6788; --line-l: rgba(200, 60, 140, 0.14); --input-l: #fde6f3;
  --bg-d: #1c0f22; --surface-d: rgba(44, 22, 52, 0.8); --solid-d: #2c1634; --text-d: #fff0fa; --muted-d: #d0a8cf; --line-d: rgba(255, 180, 230, 0.14); --input-d: #3b2045;
  --ink: #3a1838;
}
:root[data-palette="sunset"] {
  --accent: #7c3aed; --accent-2: #ec4899; --accent-3: #fb923c;
  --grad: linear-gradient(135deg, #7c3aed 0%, #ec4899 55%, #fb923c 100%);
  --hero-glow: rgba(236, 72, 153, 0.6);
  --loc-1: #7c3aed; --loc-2: #06b6d4; --loc-3: #fb923c; --loc-4: #ec4899; --loc-5: #10b981; --loc-6: #eab308;
  --k1: #7c3aed; --k2: #ec4899; --k3: #fb923c; --k4: #06b6d4;
  --series-1: #ec4899; --series-2: #fb923c; --series-3: #7c3aed;
  --bar-top: #ec4899; --bar-bottom: #7c3aed; --heat-lo: #7c3aed; --heat-hi: #ec4899;
  --blob-1: #7c3aed; --blob-2: #ec4899; --blob-3: #fb923c;
  --bg-l: #f6f3ff; --surface-l: rgba(255, 255, 255, 0.82); --solid-l: #ffffff; --text-l: #1c1530; --muted-l: #6b6485; --line-l: rgba(60, 40, 120, 0.12); --input-l: #f3f0fb;
  --bg-d: #0f0a1f; --surface-d: rgba(30, 22, 54, 0.78); --solid-d: #1e1636; --text-d: #f2eeff; --muted-d: #a59dc4; --line-d: rgba(200, 180, 255, 0.12); --input-d: #2a2048;
  --ink: #1c1530;
}

:root {
  --bg: var(--bg-l); --surface: var(--surface-l); --surface-solid: var(--solid-l); --text: var(--text-l);
  --muted: var(--muted-l); --line: var(--line-l); --input: var(--input-l);
  --red: #e5484d;
  --accent-fg: var(--accent);
  --shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 30%, transparent);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--bg-d); --surface: var(--surface-d); --surface-solid: var(--solid-d); --text: var(--text-d);
    --muted: var(--muted-d); --line: var(--line-d); --input: var(--input-d);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --accent-fg: color-mix(in srgb, var(--accent) 45%, #fff);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--bg-d); --surface: var(--surface-d); --surface-solid: var(--solid-d); --text: var(--text-d);
  --muted: var(--muted-d); --line: var(--line-d); --input: var(--input-d); color-scheme: dark;
  --accent-fg: color-mix(in srgb, var(--accent) 45%, #fff);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
}
.hidden { display: none !important; }

.bg-blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-blobs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; }
.bg-blobs span:nth-child(1) { width: 360px; height: 360px; background: var(--blob-1); top: -120px; left: -100px; }
.bg-blobs span:nth-child(2) { width: 300px; height: 300px; background: var(--blob-2); top: 30%; right: -140px; }
.bg-blobs span:nth-child(3) { width: 320px; height: 320px; background: var(--blob-3); bottom: -160px; left: 10%; opacity: 0.25; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
.view { display: flex; flex-direction: column; gap: 14px; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

h1, h2, h3 { margin: 0; }
h2 { font-size: 1.05rem; font-weight: 700; }
.page-title { font-size: 1.8rem; font-weight: 800; padding: 6px 4px 2px; }
.sub { color: var(--muted); font-size: 0.85rem; margin: 4px 0 10px; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; font-weight: 600; }

.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head, .form-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

/* Hero */
.hero {
  background: var(--grad);
  color: #fff;
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 18px 40px -16px var(--hero-glow);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); right: -60px; top: -80px;
}
.hero .big { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin-top: 6px; }
.hero .big small { font-size: 1rem; font-weight: 600; opacity: 0.85; }
.hero .gross { opacity: 0.85; font-size: 0.9rem; margin-top: 2px; }
.hero .hero-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.hero .pill { background: rgba(255, 255, 255, 0.2); border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; font-weight: 600; }
.hero .progress { height: 8px; background: rgba(255, 255, 255, 0.25); border-radius: 99px; margin-top: 14px; overflow: hidden; }
.hero .progress div { height: 100%; background: #fff; border-radius: 99px; }
.hero .forecast { margin-top: 12px; background: rgba(0, 0, 0, 0.15); border-radius: 14px; padding: 10px 12px; font-size: 0.9rem; }
.hero .forecast b { font-size: 1.1rem; }

/* Form */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field span { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.row2, .row3 { display: grid; gap: 10px; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 0.9fr; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--input);
  border: 1.5px solid transparent; border-radius: 12px; padding: 11px 12px;
  width: 100%; min-width: 0; font-size: 16px; outline: none; transition: border-color 0.15s;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.preview { font-size: 0.9rem; color: var(--muted); min-height: 1.2em; }
.preview b { color: var(--accent-fg); }
.form-actions { display: flex; gap: 10px; }
.form-actions .primary { flex: 1; }

.btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 14px; padding: 13px 18px;
  cursor: pointer; transition: transform 0.1s, opacity 0.15s; font-size: 0.95rem;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -8px var(--hero-glow); }
.btn.ghost { background: var(--input); color: var(--text); }
.btn.danger { background: rgba(239, 68, 68, 0.12); color: var(--red); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
.chip {
  font: inherit; font-size: 0.8rem; font-weight: 700; border: 0; border-radius: 999px;
  padding: 7px 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-fg); cursor: pointer;
}
.chip.ghost { background: var(--input); color: var(--muted); }
.icon-btn {
  font: inherit; font-size: 1.6rem; width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--input); color: var(--text); cursor: pointer; flex-shrink: 0;
}

/* Entries */
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entry {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border-radius: 14px; background: var(--input); cursor: pointer; transition: transform 0.1s;
}
.entry:active { transform: scale(0.99); }
.entry .day { text-align: center; border-radius: 12px; padding: 6px 0; color: #fff; font-weight: 800; line-height: 1.1; }
.entry .day small { display: block; font-size: 0.65rem; font-weight: 600; opacity: 0.9; text-transform: uppercase; }
.entry .meta { min-width: 0; }
.entry .meta .t { font-weight: 700; font-size: 0.92rem; }
.entry .meta .a { color: var(--muted); font-size: 0.84rem; margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.entry .meta .a.none { font-style: italic; opacity: 0.6; }
.entry:has(.copy-act) { grid-template-columns: 48px 1fr auto 34px; }
.copy-act {
  font: inherit; font-size: 1rem; width: 34px; height: 34px; border: 0; border-radius: 10px; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-fg);
}
.entry .h { font-weight: 800; text-align: right; }
.entry .h small { display: block; color: var(--muted); font-weight: 600; font-size: 0.72rem; }
.empty { color: var(--muted); text-align: center; padding: 18px; font-size: 0.9rem; }

/* Hours view */
.period-nav { display: flex; align-items: center; gap: 10px; }
.period-title {
  flex: 1; text-align: center; font: inherit; color: var(--text); background: none; border: 0;
  border-radius: 14px; padding: 4px 6px; cursor: pointer; min-width: 0;
}
.period-title:hover, .period-title[aria-expanded="true"] { background: var(--input); }
.period-title h2 { font-size: 1.35rem; font-weight: 800; }
.period-title .eyebrow { color: var(--muted); }
.period-title .caret { color: var(--accent-fg); font-size: 0.9rem; display: inline-block; transition: transform 0.2s; }
.period-title[aria-expanded="true"] .caret { transform: rotate(180deg); }

.period-wrap { position: relative; z-index: 5; }
.period-picker {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  max-height: min(60vh, 460px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 50px -18px rgba(0, 0, 0, 0.45); padding: 6px;
  animation: drop 0.18s ease;
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.picker-year {
  position: sticky; top: -6px; z-index: 2; display: flex; justify-content: space-between;
  padding: 10px 10px 6px; font-size: 0.75rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-solid);
}
.picker-year span:first-child { color: var(--accent-fg); font-size: 0.85rem; }
.picker-row {
  position: relative; overflow: hidden; width: 100%; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font: inherit; color: var(--text); background: none; border: 0; border-radius: 14px;
  padding: 10px 12px; cursor: pointer; text-align: left; margin-bottom: 2px;
}
.picker-row:hover { background: var(--input); }
.picker-row .bar {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 14px; pointer-events: none;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent));
}
.picker-row > span:not(.bar) { position: relative; display: flex; flex-direction: column; }
.picker-row .pm { flex-direction: row !important; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.picker-row .pm small { width: 100%; }
.picker-row small { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.picker-row .pv { text-align: right; align-items: flex-end; }
.picker-row em {
  font-style: normal; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--grad); color: #fff; border-radius: 99px; padding: 2px 7px;
}
.picker-row em.soft { background: var(--input); color: var(--muted); }
.picker-row.empty { opacity: 0.55; }
.picker-row.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.banner {
  background: linear-gradient(135deg, var(--accent-3), var(--accent)); color: #fff; border-radius: 18px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px; font-size: 0.9rem;
}

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--accent)); }
.stat .l { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.45rem; font-weight: 800; margin-top: 2px; letter-spacing: -0.01em; }
.stat .s { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* Charts */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text, .donut-wrap text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .val { fill: var(--text); font-weight: 700; font-size: 10px; }
.chart .grid { stroke: var(--line); }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap svg { width: 140px; height: 140px; flex-shrink: 0; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; flex: 1; min-width: 140px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.legend b { margin-left: auto; }
.heatmap { overflow-x: auto; }
.heatmap svg { display: block; }
.heatmap rect { rx: 3; }

.wage-summary { background: var(--input); border-radius: 14px; padding: 12px; font-size: 0.9rem; line-height: 1.6; }
.wage-summary b { color: var(--accent-fg); }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--surface); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; max-width: 140px; font: inherit; font-size: 0.72rem; font-weight: 700; color: var(--muted);
  background: none; border: 0; border-radius: 14px; padding: 6px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar .ti { font-size: 1.2rem; line-height: 1.2; }
.tabbar button.active { color: var(--accent-fg); background: color-mix(in srgb, var(--accent) 13%, transparent); }

/* Dialog + toast */
dialog {
  border: 0; border-radius: 22px; padding: 0; background: var(--surface-solid); color: var(--text);
  width: min(92vw, 380px); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(4px); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.error { color: var(--red); font-size: 0.85rem; margin: 0; min-height: 1em; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 .field:last-child { grid-column: span 2; }
  .hero .big { font-size: 2.2rem; }
}

/* Palette picker */
.palettes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.palette {
  font: inherit; font-weight: 700; font-size: 0.85rem; color: var(--text); background: var(--input);
  border: 2px solid transparent; border-radius: 16px; padding: 8px 8px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
.palette i { height: 38px; border-radius: 11px; display: block; }
.palette.active { border-color: var(--accent); }
