/* Curvi Collab – vaalea, lämmin ja ammattimainen ulkoasu. */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f6f2fb;
  --text: #231c2e;
  --muted: #5d5470;
  --border: #e7e0d6;
  --border-strong: #cfc5d9;

  --violet-900: #3a2760;
  --violet: #5b3f8c;
  --violet-600: #6d50a3;
  --violet-100: #e9e1f5;
  --violet-50: #f4effa;
  --gold: #c9a24a;
  --gold-soft: #d4ae5a;
  --gold-text: #7a5a12;
  --gold-50: #fbf4e2;

  --danger: #b42318;
  --danger-50: #fdeeec;
  --warn: #8a4b00;
  --warn-50: #fff4e1;
  --success: #1e6e45;
  --success-50: #e7f4ec;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(35, 28, 46, .05), 0 4px 16px rgba(35, 28, 46, .05);
  --shadow-lg: 0 10px 40px rgba(35, 28, 46, .16);
  --focus: 0 0 0 3px var(--surface), 0 0 0 5px var(--violet);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --bottom-nav: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--violet); }
a:hover { color: var(--violet-900); }
code { background: var(--violet-50); padding: .1em .35em; border-radius: 6px; font-size: .9em; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

/* Fokus: selkeä violetti rengas kaikille interaktiivisille elementeille */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--violet); }
main:focus, h1:focus, [tabindex="-1"]:focus { outline: none; }
.error-summary:focus { outline: 3px solid var(--danger); outline-offset: 2px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 1rem; top: -100px; background: var(--violet); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 1rem; color: #fff; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.block { display: block; }
.mt { margin-top: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ---------- Yläpalkki ja navigaatio ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(250, 247, 242, .92); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .65rem 1.25rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--violet); color: #fff; display: grid; place-items: center; font: 700 1.2rem var(--font-display); position: relative; }
.brand-mark::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-soft); }
.brand-name { font: 700 1.25rem var(--font-display); letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--violet); font-weight: 600; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a { display: flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 550; font-size: .95rem; }
.nav a:hover { background: var(--violet-50); color: var(--violet-900); }
.nav a[aria-current="page"] { background: var(--violet-100); color: var(--violet-900); }
.nav a.nav-new { background: var(--violet); color: #fff; }
.nav a.nav-new:hover, .nav a.nav-new[aria-current="page"] { background: var(--violet-900); color: #fff; }
.nav-icon-wrap { position: relative; display: inline-flex; margin-right: .3rem; }
.nav-badge { position: absolute; top: -7px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #2b1d00; font-size: .7rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.nav-badge.badge-overdue { background: var(--danger); color: #fff; }
.nav-badge[hidden] { display: none; }

/* ---------- Sivupohja ---------- */
main { display: block; }
.page { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.narrow-page { max-width: 780px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-head p { margin: 0; }
.eyebrow { text-transform: capitalize; color: var(--gold-text); font-weight: 600; font-size: .9rem; margin-bottom: .25rem !important; }
.lead { font-size: 1.1rem; color: var(--muted); }
.head-actions, .btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.crumbs { margin-bottom: .75rem; }
.crumbs a { display: inline-flex; align-items: center; gap: .25rem; text-decoration: none; font-weight: 550; font-size: .95rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.card h2 { display: flex; align-items: center; gap: .5rem; }
.card h2 .icon { color: var(--violet); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* ---------- Painikkeet ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1.05rem; border-radius: 999px; border: 1px solid transparent; font: 600 .95rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s; white-space: nowrap; }
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: var(--violet-900); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--violet-900); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--violet-50); border-color: var(--violet-600); color: var(--violet-900); }
.btn-gold { background: var(--gold-50); color: var(--gold-text); border-color: #e6cf98; }
.btn-gold:hover { background: #f6e7bf; color: #5e4409; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1b12; color: #fff; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-50); border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 36px; padding: .35rem .8rem; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--violet-50); color: var(--violet-900); }
.icon-btn.bordered { border: 1px solid var(--border-strong); background: var(--surface); }
.link-btn { background: none; border: 0; color: var(--violet); text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }
.text-link { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; text-decoration: none; font-size: .925rem; }
.text-link:hover { text-decoration: underline; }

/* ---------- Merkit ---------- */
.pill { display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.status-idea { background: #f0edf4; color: #463d55; }
.status-lahestyttava { background: #eaf0fb; color: #2b4680; }
.status-yhteytta { background: #e5f1fa; color: #1b5480; }
.status-neuvottelu { background: #fbf0dc; color: #6f4a0c; }
.status-sovittu { background: var(--violet-100); color: var(--violet-900); }
.status-tuotannossa { background: #f6e6f6; color: #722a75; }
.status-hyvaksynta { background: #ffeedd; color: #803f00; }
.status-julkaistu { background: #e2f3e9; color: #1a6340; }
.status-laskutettu { background: #e3f0ef; color: #1f5a58; }
.status-valmis { background: #ebebeb; color: #383838; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip { display: inline-flex; align-items: center; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 550; background: #f3efe8; color: #4a4152; border: 1px solid var(--border); }
.chip-account { background: var(--gold-50); color: var(--gold-text); border-color: #ecdcb1; }
.chip-sample { background: #fff; border-style: dashed; color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: .1rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge-overdue { background: var(--danger-50); color: var(--danger); }
.badge-soon { background: var(--warn-50); color: var(--warn); }

/* ---------- Ilmoituslaatikot ---------- */
.notice { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 1rem; }
.notice > .icon { margin-top: .15rem; width: 1.3em; height: 1.3em; }
.notice p:last-child, .notice ul:last-child { margin-bottom: 0; }
.notice ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.notice-error { background: var(--danger-50); border-color: #f2c4bf; color: #7a1a12; }
.notice-error a { color: #7a1a12; }
.notice-warn { background: var(--warn-50); border-color: #f1d9ad; color: #5f3500; }
.notice-warn a { color: #5f3500; }
.notice-info { background: var(--violet-50); border-color: var(--violet-100); color: var(--violet-900); }
.notice-success { background: var(--success-50); border-color: #bfe1cc; color: #134a2e; }
.notice.compact { text-decoration: none; margin: 0; align-items: center; font-size: .925rem; }
.notice.compact:hover { filter: brightness(.98); text-decoration: underline; }
.sample-note { align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sample-note p { margin: 0; flex: 1 1 300px; }
.inline-list { list-style: none; padding: 0 !important; margin: .2rem 0 0 !important; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.inline-list a { font-weight: 550; }
.reminders { margin-bottom: .25rem; }
.reminder-strip { display: grid; gap: .5rem; margin-bottom: 1rem; }

/* ---------- Etusivu ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: .85rem; align-items: center; padding: 1.1rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
.stat:hover { border-color: var(--violet-600); transform: translateY(-1px); color: var(--text); }
.stat-icon { grid-row: 1 / 3; width: 44px; height: 44px; border-radius: 12px; background: var(--violet-50); color: var(--violet); display: grid; place-items: center; }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-value { font: 700 1.9rem/1 var(--font-display); }
.stat-label { font-weight: 600; font-size: .95rem; }
.stat-sub { grid-column: 1 / -1; margin-top: .55rem; font-size: .825rem; color: var(--muted); }
.stat.tone-danger .stat-icon { background: var(--danger-50); color: var(--danger); }
.stat.tone-danger .stat-sub { color: var(--danger); font-weight: 600; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.fees { background: linear-gradient(160deg, #fff 55%, var(--gold-50)); }
.fee-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0 0 1rem; }
.fee-figures dt { font-size: .85rem; color: var(--muted); font-weight: 600; }
.fee-figures dd { margin: 0; font: 700 1.75rem/1.2 var(--font-display); }
.fee-figures dd.realized { color: var(--success); }
.progress { height: 10px; background: #efe9f5; border-radius: 99px; overflow: hidden; margin-bottom: .5rem; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); border-radius: 99px; transition: width .3s; }
.mini-progress { display: inline-block; width: 56px; height: 6px; background: #efe9f5; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: .3rem; }
.mini-progress span { display: block; height: 100%; background: var(--violet); }

.event-list, .simple-list { list-style: none; margin: 0; padding: 0; }
.event-item + .event-item, .simple-list li + li { border-top: 1px solid var(--border); }
.event-link { display: flex; align-items: center; gap: .85rem; padding: .6rem .35rem; text-decoration: none; color: var(--text); border-radius: 8px; }
.event-link:hover { background: var(--violet-50); color: var(--text); }
.event-date { flex: 0 0 5.6rem; display: flex; flex-direction: column; }
.event-day { font-weight: 650; font-size: .9rem; }
.event-rel { font-size: .78rem; color: var(--muted); }
.urg-overdue .event-rel { color: var(--danger); font-weight: 650; }
.urg-soon .event-rel { color: var(--warn); font-weight: 650; }
.event-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.event-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-sub { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind-dot, .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; vertical-align: .05em; }
.kind-publish { --k: var(--violet); }
.kind-deadline { --k: var(--gold); }
.kind-dot, .dot { background: var(--k, var(--violet)); }
.dot.urg-overdue { background: var(--danger); }
.dot.urg-done { background: #b9b3c2; }
.simple-list a { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .35rem; text-decoration: none; color: var(--text); border-radius: 8px; }
.simple-list a:hover { background: var(--violet-50); color: var(--text); }
.wait-days { flex: none; font-weight: 700; font-size: .85rem; color: var(--muted); background: #f3efe8; padding: .15rem .55rem; border-radius: 99px; }
.wait-days.wait-long { background: var(--warn-50); color: var(--warn); }
.empty-small { color: var(--muted); margin: .25rem 0; }

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: .5rem; }
.pipe-item { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: .7rem .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); text-decoration: none; color: var(--text); }
.pipe-item:hover { border-color: var(--violet-600); background: var(--violet-50); color: var(--text); }
.pipe-item.is-empty .pipe-count { color: #a8a0b4; }
.pipe-count { font: 700 1.4rem/1 var(--font-display); }

/* ---------- Lista ---------- */
.filters { margin-bottom: 1rem; display: grid; gap: .85rem; }
.filter-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .65rem; }
.filter-foot { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.filter-foot .segmented { margin-left: auto; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 2.4rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: #f1ece4; border: 1px solid var(--border); }
.segmented button { display: inline-flex; align-items: center; gap: .35rem; border: 0; background: transparent; padding: .4rem .85rem; border-radius: 999px; font: 600 .875rem var(--font); color: var(--muted); cursor: pointer; min-height: 36px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--violet-900); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: .925rem; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: .75rem .9rem; border-bottom: 1px solid var(--border); background: #fcfaf7; white-space: nowrap; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfaff; }
.table .num { text-align: right; white-space: nowrap; }
.row-link { font-weight: 650; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--violet); text-decoration: underline; }
.next-ev { white-space: nowrap; }
.next-ev.urg-overdue { color: var(--danger); font-weight: 650; }
.next-ev.urg-soon { color: var(--warn); font-weight: 650; }
.next-ev .icon { margin-right: .2rem; }

.status-select { appearance: none; -webkit-appearance: none; border: 1px solid transparent; border-radius: 999px; padding: .35rem 1.9rem .35rem .75rem; font: 650 .825rem var(--font); cursor: pointer; min-height: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23231c2e' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .55rem center; background-size: 14px; max-width: 100%; }
.status-select:hover { border-color: currentColor; }

.collab-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.collab-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; display: flex; flex-direction: column; gap: .75rem; position: relative; transition: border-color .15s; }
.collab-card:hover { border-color: var(--violet-600); }
.collab-card h3 { font-size: 1.1rem; margin: 0; }
.card-link { color: var(--text); text-decoration: none; }
.card-link:hover { color: var(--violet); text-decoration: underline; }
.cc-campaign { margin: .15rem 0 .5rem; font-size: .925rem; }
.cc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem; margin: 0; font-size: .9rem; }
.cc-meta dt { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.cc-meta dd { margin: 0; }
.cc-status { margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-title { font: 700 1.2rem var(--font-display); }

/* ---------- Yksityiskohdat ---------- */
.status-card { margin-bottom: 1rem; }
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.step { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .8rem .35rem .4rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: 600 .85rem var(--font); cursor: pointer; min-height: 38px; }
.step:hover { border-color: var(--violet-600); color: var(--violet-900); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #f1ece4; font-size: .75rem; color: var(--muted); }
.step.is-past { color: var(--violet-900); }
.step.is-past .step-dot { background: var(--violet-100); color: var(--violet); }
.step.is-current { background: var(--violet); border-color: var(--violet); color: #fff; }
.step.is-current .step-dot { background: var(--gold-soft); color: #2b1d00; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.col { display: grid; gap: 1rem; min-width: 0; }
.checklist { list-style: none; margin: .75rem 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: .65rem; padding: .2rem 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { flex: 1; padding: .55rem 0; cursor: pointer; }
.checklist li.is-done label { color: var(--muted); text-decoration: line-through; text-decoration-color: #b9b0c4; }
.checklist .icon-btn { opacity: .55; }
.checklist li:hover .icon-btn, .checklist .icon-btn:focus-visible { opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--violet); flex: none; margin: 0; cursor: pointer; }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { flex: 1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; align-items: center; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline label, .timeline .tl-label { flex: 1; cursor: pointer; }
.timeline .tl-label { cursor: default; }
.tl-pub { width: 22px; display: grid; place-items: center; color: var(--violet); }
.timeline li.urg-done strong { text-decoration: line-through; color: var(--muted); }
.timeline li.urg-overdue strong { color: var(--danger); }
.dl { margin: 0; display: grid; gap: .65rem; }
.dl dt { font-size: .8rem; color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 550; }
.deliverables { list-style: none; margin: 0; padding: 0; }
.deliverables li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.deliverables li:last-child { border-bottom: 0; }
.qty { font-weight: 700; color: var(--violet); }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.links a { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; color: var(--text); min-width: 0; }
.links a > span { min-width: 0; }
.links a:hover { border-color: var(--violet-600); background: var(--violet-50); }
.links .icon { color: var(--violet); }
.notes { white-space: pre-wrap; margin: 0; }
.meta-line { text-align: right; }

/* ---------- Lomakkeet ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .radio-group legend { font-weight: 600; font-size: .9rem; }
.field-compact label { font-size: .8rem; color: var(--muted); }
.hint { font-size: .825rem; color: var(--muted); margin: 0; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 400 1rem var(--font); transition: border-color .15s, box-shadow .15s;
}
select:not(.status-select) { appearance: none; -webkit-appearance: none; padding-right: 2.2rem; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d5470' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right .7rem center / 16px; }
.field-compact select { min-height: 40px; font-size: .925rem; }
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: #a99cb9; }
input::placeholder, textarea::placeholder { color: #8a8297; }
[aria-invalid="true"] { border-color: var(--danger) !important; background-color: #fffafa !important; }
.field-error { color: var(--danger); font-size: .85rem; font-weight: 600; margin: 0; }
.field-error:empty { display: none; }
.form-page { max-width: 900px; }
.form-section { border: 1px solid var(--border); margin: 0 0 1rem; display: grid; gap: .9rem; }
.form-section legend { font: 700 1.1rem var(--font-display); padding: 0 .4rem; margin-left: -.4rem; float: left; width: 100%; margin-bottom: .1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.grid-fee { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: .9rem; max-width: 460px; }
.narrow { max-width: 240px; }
.rep-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.rep-list:empty { display: none; }
.rep-row { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem; border-radius: var(--radius-sm); background: #fcfaf7; border: 1px solid var(--border); }
.rep-row .grow { flex: 1; }
.rep-row .qty { width: 90px; flex: none; }
.rep-row .date { width: 180px; flex: none; }
.rep-row .kind { width: 150px; flex: none; }
.rep-row .rep-remove { margin-top: 1.55rem; }
.quick-add { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-btn { display: inline-flex; align-items: center; gap: .3rem; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--violet-900); padding: .35rem .75rem; border-radius: 999px; font: 600 .85rem var(--font); cursor: pointer; min-height: 36px; }
.chip-btn:hover { border-style: solid; border-color: var(--violet-600); background: var(--violet-50); }
.form-actions { position: sticky; bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; gap: .6rem; padding: .85rem 1rem; margin: 0 -1rem; background: rgba(250, 247, 242, .95); backdrop-filter: blur(8px); border-top: 1px solid var(--border); z-index: 5; }
.error-summary h2 { display: flex; gap: .4rem; align-items: center; color: var(--danger); }
.error-summary { display: block; }
.error-summary[hidden] { display: none; }
.stack { display: grid; gap: 1rem; }
.radio-group { border: 0; padding: 0; margin: 0; display: grid; gap: .5rem; }
.radio-group label { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.check-inline { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 550; }
.check-inline input { width: 18px; height: 18px; }
input[type="file"] { font: inherit; padding: .5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fcfaf7; max-width: 100%; }
.narrow-page .card { margin-bottom: 1rem; }
.danger-zone { border-color: #f2c4bf; }

/* ---------- Kalenteri ---------- */
.calendar-card { padding: 1rem; margin-bottom: 1rem; }
.cal-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .85rem; }
.cal-nav { display: flex; align-items: center; gap: .5rem; }
.cal-nav h2 { font: 700 1.35rem var(--font-display); margin: 0 .35rem; min-width: 10ch; text-align: center; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--muted); align-items: center; }
.cal-grid { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal-grid th { font-size: .78rem; text-transform: uppercase; color: var(--muted); font-weight: 650; padding: .25rem; }
.cal-grid abbr { text-decoration: none; }
.cal-grid td { vertical-align: top; height: 108px; background: #fcfaf7; border: 1px solid var(--border); border-radius: 10px; padding: 0; overflow: hidden; }
.cal-grid td.out { background: transparent; border-color: transparent; color: #aaa1b5; }
.cal-grid td.today { border-color: var(--violet); box-shadow: inset 0 0 0 1px var(--violet); background: var(--violet-50); }
.day { padding: .35rem .4rem; height: 100%; display: flex; flex-direction: column; gap: .25rem; }
.day-num { font-size: .85rem; font-weight: 650; }
.day-link { color: inherit; text-decoration: none; align-self: flex-start; }
.day-link:hover { color: var(--violet); text-decoration: underline; }
.cal-grid td { position: relative; }
.today .day-num > span[aria-hidden] { background: var(--violet); color: #fff; border-radius: 99px; padding: .05rem .45rem; }
.day-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.cal-ev { display: block; font-size: .75rem; line-height: 1.3; padding: .15rem .4rem; border-radius: 6px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--k); background: var(--surface); color: var(--text); font-weight: 600; }
.cal-ev.kind-publish { background: var(--violet-50); }
.cal-ev.kind-deadline { background: var(--gold-50); }
.cal-ev.urg-overdue { border-left-color: var(--danger); background: var(--danger-50); color: #7a1a12; }
.cal-ev.urg-done { opacity: .6; text-decoration: line-through; }
.cal-ev:hover { filter: brightness(.96); color: var(--text); }
.cal-ev-label { font-weight: 450; color: var(--muted); }
.cal-more { font-size: .72rem; font-weight: 650; }
.dots { display: none; }
.cal-lists { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.agenda-day + .agenda-day { margin-top: .9rem; }
.agenda-day h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .2rem; }
.agenda-day.is-today h3 { color: var(--violet); }
.sub-h { font-size: .9rem; margin-top: 1rem; color: var(--muted); }

/* ---------- Ilmoitukset (toast) ja dialogi ---------- */
.toasts { position: fixed; right: 1rem; bottom: calc(1rem + var(--bottom-nav) + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: .5rem; width: min(400px, calc(100vw - 2rem)); pointer-events: none; }
.toasts > div { display: grid; gap: .5rem; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; padding: .8rem .6rem .8rem .95rem; border-radius: 12px; background: #2b2238; color: #fff; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; }
.toast p { margin: .1rem 0 0; flex: 1; font-size: .925rem; }
.toast > .icon { margin-top: .2rem; color: #9ee2b8; }
.toast-error { background: #8f1b12; }
.toast-error > .icon { color: #ffd2cc; }
.toast-close { background: transparent; border: 0; color: #fff; opacity: .8; cursor: pointer; padding: .2rem; border-radius: 6px; display: grid; place-items: center; }
.toast-close:hover { opacity: 1; }
.toast-close:focus-visible { outline-color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.dialog { border: 0; border-radius: var(--radius); padding: 1.4rem; width: min(440px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); color: var(--text); }
.dialog::backdrop { background: rgba(35, 28, 46, .45); }
.dialog h2 { font: 700 1.25rem var(--font-display); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---------- Responsiivisuus ---------- */
@media (max-width: 1100px) {
  .filter-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .cal-lists { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  :root { --bottom-nav: 64px; }
  body { font-size: 15.5px; }
  .topbar-inner { padding: .55rem 1rem; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); border-top: 1px solid var(--border); padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; height: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); }
  .nav a { flex-direction: column; gap: .1rem; font-size: .7rem; padding: .3rem .4rem; border-radius: 12px; flex: 1; justify-content: center; min-width: 0; }
  .nav a .icon { width: 22px; height: 22px; }
  .nav-icon-wrap { margin-right: 0; }
  .nav a.nav-new { background: transparent; color: var(--violet); }
  .nav a.nav-new .icon { background: var(--violet); color: #fff; border-radius: 12px; width: 38px; height: 30px; padding: 5px; }
  .nav a.nav-new:hover, .nav a.nav-new[aria-current="page"] { background: var(--violet-50); color: var(--violet-900); }
  .page { padding: 1.1rem 1rem 2rem; }
  .page-head { align-items: flex-start; }
  .page-head .btn-primary { width: 100%; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
  .stats { gap: .65rem; }
  .stat { padding: .85rem; grid-template-columns: 1fr; }
  .stat-icon { grid-row: auto; width: 36px; height: 36px; margin-bottom: .4rem; }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: .875rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .grid-fee { max-width: none; grid-template-columns: minmax(0, 1fr) 110px; }
  .narrow { max-width: none; }
  .rep-row { flex-wrap: wrap; }
  .rep-row .grow { flex: 1 1 100%; }
  .rep-row .date, .rep-row .kind { flex: 1 1 auto; width: auto; }
  .rep-row .qty { flex: 1 1 auto; width: auto; }
  .rep-row[data-rep="link"] .grow { order: 3; }
  .rep-row .rep-remove { margin-top: 1.55rem; }
  .form-actions { margin: 0 -1rem; }
  .form-actions .btn { flex: 1; }
  .step { font-size: .8rem; }
  .cal-grid { border-spacing: 2px; }
  .cal-grid td { height: 58px; border-radius: 8px; }
  .day { padding: .25rem; align-items: center; }
  .day-events { display: none; }
  .day-link { align-self: center; }
  .day-link::after { content: ""; position: absolute; inset: 0; }
  .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
  .dots .dot { width: 7px; height: 7px; margin: 0; }
  .cal-nav h2 { font-size: 1.15rem; }
  .cal-toolbar { flex-direction: column; align-items: stretch; }
  .cal-nav { justify-content: space-between; }
  .event-date { flex-basis: 4.9rem; }
  .table { font-size: .875rem; }
  .meta-line { text-align: left; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .nav a span:not(.nav-icon-wrap) { font-size: .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .toasts, .form-actions, .head-actions { display: none !important; }
  body { background: #fff; }
}

/* ---------- Kirjautuminen ---------- */
body.logged-out .nav { display: none; }
body.logged-out { --bottom-nav: 0px; }
.login-page { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: min(420px, 100%); display: grid; gap: 1rem; padding: 2rem 1.75rem; }
.login-card h1 { font-size: 1.6rem; margin: 0; }
.login-card p { margin: 0; }
.login-brand .brand-mark { width: 48px; height: 48px; font-size: 1.5rem; border-radius: 14px; }
.btn-block { width: 100%; }
input[type="password"] { width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 400 1rem var(--font); }
input[type="password"]:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--violet); }
