:root {
  --bg: #fff6f1;
  --surface: #ffffff;
  --surface-2: #fcece6;
  --text: #2a1330;
  --muted: #7d6383;
  --border: #f1dcdc;
  --accent: #e0245e;          /* vadelmahillo */
  --accent-2: #7c3aed;        /* violetti */
  --accent-ink: #ffffff;
  --accent-soft: #ffe0ea;
  --pop: #d4f53c;             /* lime-korostus */
  --pop-ink: #213000;
  --warn: #b45309;
  --warn-soft: #fff0d6;
  --danger: #c81e3a;
  --holiday: #e8590c;
  --holiday-soft: #ffeadb;
  --hero: linear-gradient(135deg, #7c3aed 0%, #c026d3 48%, #e0245e 100%);
  --radius: 20px;
  --shadow: 0 1px 2px rgba(42,19,48,.04), 0 8px 24px rgba(124,58,237,.07);
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #140a19; --surface: #1f1126; --surface-2: #2a1833; --text: #f8ebf4; --muted: #b69abd;
    --border: #38223f; --accent: #ff4f8b; --accent-2: #a78bfa; --accent-ink: #1a0712; --accent-soft: #4a1630;
    --pop: #d4f53c; --pop-ink: #213000; --warn: #fbbf24; --warn-soft: #3a2a10; --danger: #ff6b81;
    --holiday: #ff8f4d; --holiday-soft: #3d1f12; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #140a19; --surface: #1f1126; --surface-2: #2a1833; --text: #f8ebf4; --muted: #b69abd;
  --border: #38223f; --accent: #ff4f8b; --accent-2: #a78bfa; --accent-ink: #1a0712; --accent-soft: #4a1630;
  --pop: #d4f53c; --pop-ink: #213000; --warn: #fbbf24; --warn-soft: #3a2a10; --danger: #ff6b81;
  --holiday: #ff8f4d; --holiday-soft: #3d1f12; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.15; font-family: var(--font-display); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; } h2 { font-size: 1.2rem; font-weight: 700; } h3 { font-size: 1rem; font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: block; }
.beta { font: 700 .62rem/1 var(--font-display); letter-spacing: .08em; background: var(--pop); color: var(--pop-ink);
  padding: 4px 7px; border-radius: 99px; text-transform: uppercase; }
.topbar-sub { color: var(--muted); font-size: .88rem; margin-left: auto; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; justify-content: center; gap: 4px; max-width: 520px; margin: 0 auto;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 22px; padding: 6px; box-shadow: 0 10px 30px rgba(42,19,48,.12);
}
.tabbar button {
  flex: 1; background: none; border: 0; padding: 7px 4px; color: var(--muted); border-radius: 16px;
  font: inherit; font-size: .78rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
}
.tabbar button span { font-size: 1.15rem; }
.tabbar button.active { color: var(--accent-ink); background: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.hero { background: var(--hero); color: #fff; border: 0; position: relative; overflow: hidden; }
.card.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 70%); pointer-events: none; }
.card.hero .kpi-label, .card.hero .muted { color: rgba(255,255,255,.8); }
.card.hero .badge { background: rgba(255,255,255,.18); color: #fff; }
.card.hero .bar { background: rgba(255,255,255,.22); }
.card.hero .bar > div { background: var(--pop); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack > * + * { margin-top: 10px; }

.kpi { font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.kpi-label { color: var(--muted); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar > div { height: 100%; background: var(--accent); border-radius: 99px; }

/* Työnantajakohtaiset elementit: väri tulee muuttujasta --c */
.emp-card { border-top: 5px solid var(--c); }
.emp-head { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--c); color: #fff; font: 800 .9rem/1 var(--font-display); letter-spacing: .02em;
}
.datebox {
  width: 48px; flex: none; border-radius: 12px; background: var(--c); color: #fff; text-align: center; padding: 6px 0 5px;
  font-family: var(--font-display); line-height: 1;
}
.datebox b { display: block; font-size: 1.25rem; font-weight: 800; }
.datebox span { display: block; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; opacity: .9; }
.emp-item {
  display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 8px; border-radius: 14px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
}
.emp-item:last-child { margin-bottom: 0; }
.emp-item .grow { flex: 1; min-width: 0; }
.emp-name { font-weight: 700; color: color-mix(in srgb, var(--c) 75%, var(--text)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-item .amount { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { margin: 0; }
.swatches input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 10px; background: var(--c); cursor: pointer; border: 3px solid transparent; }
.swatches input:checked + span { border-color: var(--text); }
.swatches input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 7px 4px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .74rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
td.r, th.r { text-align: right; }
tr.total td { font-weight: 800; border-bottom: 0; }
tr.sub td { color: var(--muted); }

button, .btn {
  font: inherit; font-weight: 600; border-radius: 99px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 9px 16px; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
button:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { margin-bottom: 12px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
fieldset { border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 700; padding: 0 6px; font-family: var(--font-display); }
.notice { background: var(--warn-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: .88rem; }
.notice.info { background: var(--accent-soft); }
a { color: var(--accent); font-weight: 600; }

/* Kalenteri */
.cal-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-head select { width: auto; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal .dow { text-align: center; font-size: .72rem; color: var(--muted); padding: 4px 0; font-weight: 700; text-transform: uppercase; }
.day {
  min-height: 92px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; overflow: hidden; text-align: left;
  font: inherit; color: inherit;
}
.day:hover { border-color: var(--accent); }
.day.other { opacity: .4; }
.day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day.today .dnum { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 6px; align-self: flex-start; }
.day.sunday .dnum, .day.holiday .dnum { color: var(--holiday); }
.day.today.sunday .dnum, .day.today.holiday .dnum { color: var(--accent-ink); }
.day.holiday { background: var(--holiday-soft); }
.dnum { font-weight: 700; font-size: .85rem; font-family: var(--font-display); }
.hname { font-size: .65rem; color: var(--holiday); line-height: 1.1; font-weight: 600; }
.chip {
  font-size: .7rem; font-weight: 600; border-radius: 6px; padding: 2px 5px; line-height: 1.2; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.past { opacity: .6; }
.day-sum { margin-top: auto; font-size: .7rem; color: var(--muted); font-weight: 600; }
@media (max-width: 560px) {
  .day { min-height: 64px; padding: 3px; border-radius: 10px; }
  .chip { font-size: 0; padding: 0; height: 6px; }
  .hname { display: none; }
  .kpi { font-size: 1.6rem; }
}

.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.clickable { cursor: pointer; transition: transform .12s ease; }
.clickable:hover { transform: translateY(-1px); }
.list-item.clickable:hover { transform: none; background: var(--surface-2); }

dialog {
  border: 0; border-radius: 24px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--text); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(30,8,36,.45); backdrop-filter: blur(3px); }
#modal-body { padding: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; }

.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps div { flex: 1; height: 5px; border-radius: 5px; background: var(--border); }
.steps div.on { background: var(--accent); }
.badge { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.period-nav { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px; background: var(--surface-2); border-radius: 14px; }
.period-nav > button { padding: 4px 12px; font-size: 1.1rem; line-height: 1; }
.period-nav > button.link { font-size: .85rem; padding: 4px 6px; }
.period-nav .grow { flex: 1; min-width: 0; }
.period-nav select { padding: 6px 8px; }

.welcome-icon { width: 72px; height: 72px; border-radius: 20px; display: block; margin-bottom: 12px; box-shadow: 0 10px 24px rgba(224,36,94,.25); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 400px) { .grid.wide { grid-template-columns: 1fr; } }
.tabbar button.feedback-tab { color: var(--pop-ink); background: color-mix(in srgb, var(--pop) 70%, transparent); }
.tabbar button.feedback-tab:hover { background: var(--pop); }
.chip-radio { margin: 0; }
.chip-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radio span { display: inline-block; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); color: var(--text); font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip-radio input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { resize: vertical; min-height: 110px; }

/* Julkaisupalvelun (Netlify) oikeaan alakulmaan lisäämä merkki: nostetaan alavalikko sen yläpuolelle */
body.has-host-badge { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
body.has-host-badge .tabbar { bottom: calc(70px + env(safe-area-inset-bottom)); }
