:root {
  --dark: #102c26;
  --dark2: #173b33;
  --lime: #b8f53d;
  --lime-soft: #dff8b2;
  --soft: #edf3f0;
  --white: #fff;
  --text: #34554d;
  --line: #cedbd6;
  --muted: #6b837c;
  --red: #c2412d;
  --red-soft: #fbe4df;
  --amber: #b7791f;
  --amber-soft: #fdf1d8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(16, 44, 38, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--soft);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--dark); }
h1, h2, h3 { color: var(--dark); margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* Yläpalkki */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--dark); color: var(--white);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); }
.topbar .who { font-size: .85rem; opacity: .8; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* Alapalkki */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  background: var(--white); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--dark); }
.tabbar a.active svg { stroke: var(--dark); }

/* Kortit */
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.dark { background: var(--dark); color: var(--white); border-color: var(--dark); }
.card.dark h1, .card.dark h2, .card.dark h3 { color: var(--white); }
.muted { color: var(--muted); font-size: .9rem; }
.card.dark .muted { color: #b7cbc4; }

/* Painikkeet */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 16px; font-size: 1rem; font-weight: 700;
  cursor: pointer; text-decoration: none; min-height: 48px; font-family: inherit;
  transition: transform .05s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--lime); color: var(--dark); }
.btn-dark { background: var(--dark); color: var(--white); }
.btn-ghost { background: var(--white); color: var(--dark); border: 1px solid var(--line); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 8px 12px; font-size: .9rem; border-radius: 10px; }
.btn-call {
  width: 100%; min-height: 64px; font-size: 1.25rem; border-radius: 16px;
  background: var(--lime); color: var(--dark);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 0; }

/* Lomakkeet */
label { display: block; font-weight: 600; color: var(--dark); font-size: .9rem; margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--dark); background: var(--white);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lime); border-color: var(--dark2); }

/* Tilastot */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.stat { background: var(--dark2); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; color: var(--lime); line-height: 1.1; }
.stat span { font-size: .78rem; color: #cfe0da; }

/* Listat */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 2px; text-decoration: none; color: var(--text);
}
.item-main { min-width: 0; }
.item-title { font-weight: 700; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: .85rem; color: var(--muted); }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--soft); color: var(--dark); white-space: nowrap;
}
.badge.new { background: var(--soft); }
.badge.no_answer { background: #e7ecea; color: var(--muted); }
.badge.callback, .badge.interested { background: var(--amber-soft); color: var(--amber); }
.badge.meeting { background: var(--lime-soft); color: var(--dark); }
.badge.won { background: var(--lime); color: var(--dark); }
.badge.lost, .badge.not_interested, .badge.wrong_number, .badge.unreachable { background: var(--red-soft); color: var(--red); }

/* Listan edistyminen */
.pbar { display: flex; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.pbar span { display: block; height: 100%; }
.pb-done { background: var(--dark2); }
.pb-open { background: var(--lime); }
.card.dark .pbar { background: #2f5249; }
.card.dark .pb-done { background: #cfe0da; }
.card.dark .stats + .stats { margin-top: 10px; }
.card.dark h1 { margin-bottom: 4px; }

/* Soittokortti */
.contact-head h1 { font-size: 1.5rem; margin-bottom: 2px; }
.phone-big { font-size: 1.35rem; font-weight: 700; color: var(--dark); letter-spacing: .5px; margin: 8px 0 12px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; margin-top: 10px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--dark); word-break: break-word; }
.notes { white-space: pre-wrap; font-size: .9rem; background: var(--soft); border-radius: 10px; padding: 10px; margin-top: 10px; }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.outcome {
  border: 2px solid var(--line); background: var(--white); color: var(--dark);
  border-radius: 12px; padding: 12px 8px; font-weight: 700; font-size: .95rem; min-height: 56px;
  font-family: inherit; cursor: pointer;
}
.outcome.sel { border-color: var(--dark); background: var(--lime-soft); }
.outcome.good.sel { background: var(--lime); }
.outcome.bad.sel { background: var(--red-soft); border-color: var(--red); color: var(--red); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 7px 12px;
  font-size: .85rem; font-weight: 600; color: var(--dark); cursor: pointer; font-family: inherit;
}
.chip:active { background: var(--lime-soft); }

.history { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }

/* Ilmoitukset */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 600px; margin: 0 auto; background: var(--dark); color: var(--white);
  padding: 12px 14px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.2); font-size: .95rem;
}
.toast.error { background: var(--red); }

.modal-back {
  position: fixed; inset: 0; background: rgba(16, 44, 38, .55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--white); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal .btn { margin-top: 10px; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin: 10px 0; }
.alert.warn { background: var(--amber-soft); color: #7a4f10; }
.alert.err { background: var(--red-soft); color: var(--red); }
.alert.ok { background: var(--lime-soft); color: var(--dark); }

.center { text-align: center; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--dark); }
.login-card { width: 100%; max-width: 380px; }
.hidden { display: none !important; }
.spacer { height: 8px; }
.table-scroll { overflow-x: auto; }
table.preview { border-collapse: collapse; font-size: .8rem; min-width: 100%; }
table.preview td, table.preview th { border: 1px solid var(--line); padding: 5px 7px; white-space: nowrap; text-align: left; }
table.preview th { background: var(--soft); color: var(--dark); }
.progress { font-size: .85rem; color: #cfe0da; margin-top: 6px; }

@media (min-width: 700px) {
  main { padding: 24px 16px; }
  .outcomes { grid-template-columns: repeat(3, 1fr); }
}
