:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --ink: #17153a;
  --muted: #61647d;
  --line: #e3e5ee;
  --accent: #2b2080;
  --accent-ink: #241a6b;
  --accent-soft: #eceaf8;
  --brand-green: #3ecf8e;
  --ok: #18794e;
  --ok-soft: #e3f4ea;
  --warn: #8a5300;
  --warn-soft: #fdf1dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 21, 58, .05), 0 4px 16px rgba(23, 21, 58, .04);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); min-height: 100%; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 650; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 12px; cursor: pointer;
  font-weight: 600; white-space: nowrap;
}
button:hover { border-color: #c9cbe0; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-ink); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; }
button.wide { width: 100%; padding: 10px; }
button.small { padding: 4px 9px; font-size: 12.5px; }
.field { display: block; margin-bottom: 12px; }
.field > span, .field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13.5px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--accent-ink); }

/* ------------------------------------------------------------------ kirjautuminen */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 80% 10%, #3a2ba8 0, transparent 50%), linear-gradient(135deg, #2b2080, #1a1348); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 28px 24px;
  box-shadow: 0 30px 80px rgba(5, 3, 30, .45); }
.login-logo { width: 52px; height: 52px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; }
.login-card .muted { margin-bottom: 20px; }
.seller-list { display: grid; gap: 6px; margin-bottom: 14px; }
.seller-list button { text-align: left; padding: 10px 12px; }

/* ------------------------------------------------------------------ runko */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #1c1552; color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 750; font-size: 16px; padding: 0 8px 18px; }
.logo img { width: 32px; height: 32px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cfcbef; text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.side-foot .me { font-weight: 650; margin-bottom: 4px; }
.side-foot .link { color: #b8b3e6; font-weight: 500; font-size: 13px; }
.main { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.cols-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ------------------------------------------------------------------ tilastot */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ listat */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.cb-list { display: grid; }
.cb { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 4px; border-top: 1px solid var(--line); }
.cb:first-child { border-top: 0; }
.cb-time { font-weight: 700; font-size: 13px; }
.cb-time.late { color: var(--bad); }
.cb-main a.company { font-weight: 650; text-decoration: none; color: var(--ink); }
.cb-main a.company:hover { color: var(--accent); }
.cb-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-actions { display: flex; gap: 6px; }
.empty { color: var(--muted); padding: 10px 4px; }
.tel { white-space: nowrap; }

.pipeline { display: grid; gap: 8px; }
.pipe-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-size: 13px; text-decoration: none; color: var(--ink); }
.pipe-bar { grid-column: 1 / -1; height: 6px; background: var(--accent-soft); border-radius: 3px; overflow: hidden; }
.pipe-bar i { display: block; height: 100%; border-radius: 3px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 300px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filters button { border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; }
.filters button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.filters button .n { opacity: .65; margin-left: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; font-weight: 600; }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }

table.leads { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); }
table.leads th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 10px 12px; background: #fafbfd; border-bottom: 1px solid var(--line); }
table.leads td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.leads tr:last-child td { border-bottom: 0; }
table.leads tbody tr { cursor: pointer; }
table.leads tbody tr:hover { background: #fafaff; }
table.leads td .company { font-weight: 650; }

/* ------------------------------------------------------------------ asiakas */
.lead-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.lead-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--muted); }
.next-call { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 8px;
  background: var(--accent-soft); margin-bottom: 14px; }
.next-call b { font-size: 15px; }
.next-call.late { background: var(--bad-soft); color: var(--bad); }
.outcomes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.outcomes button { font-weight: 600; font-size: 13px; }
.outcomes button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.slots button { font-weight: 600; font-size: 13px; }
.slots button.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.timeline { display: grid; gap: 0; }
.ev { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.ev-dot.puhelu { background: #2563eb; } .ev-dot.sahkoposti { background: #7c3aed; } .ev-dot.takaisinsoitto { background: var(--brand-green); }
.ev-dot.tila { background: #94a3b8; } .ev-dot.muistiinpano { background: #d97706; }
.ev-title { font-weight: 650; font-size: 13.5px; }
.ev-time { color: var(--muted); font-size: 12px; }
.ev-note { white-space: pre-wrap; font-size: 13.5px; margin-top: 2px; }

/* ------------------------------------------------------------------ dialogit */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(5, 3, 30, .35); }
dialog::backdrop { background: rgba(23, 21, 58, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 18px 20px; max-height: calc(100vh - 200px); overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfd; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px 6px; color: var(--muted); }
.attach { display: grid; gap: 6px; }
.attach label { display: flex; gap: 8px; align-items: center; }
.results { display: grid; gap: 6px; margin-top: 8px; }
.results button { text-align: left; font-weight: 500; }
.results button b { display: block; }

/* ------------------------------------------------------------------ kalenteri (Outlook-tyyli: /panel/olcal.css) */
.olc-wrap { box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ asetukset */
.steps { margin: 0 0 12px; padding-left: 20px; }
.steps li { margin-bottom: 4px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.tpl { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.ph { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ph code { background: var(--accent-soft); padding: 1px 6px; border-radius: 4px; font-size: 12px; cursor: help; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 8px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); z-index: 100; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }

.loading { color: var(--muted); padding: 24px 0; }

/* ------------------------------------------------------------------ mobiili */
@media (max-width: 960px) {
  .cols, .cols-even { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; z-index: 20; gap: 8px; }
  .logo { padding: 0; } .logo span { display: none; }
  .nav { display: flex; overflow-x: auto; flex: 1; }
  .nav a { padding: 7px 9px; font-size: 13px; } .nav .ico { display: none; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 48px; }
  .grid2 { grid-template-columns: 1fr; }
  .cb { grid-template-columns: 1fr; gap: 4px; }
  table.leads .hide-m { display: none; }
  h1 { font-size: 21px; }
}

/* Ruudukon solut saavat kutistua (pitkät rivit eivät levitä sivua mobiilissa) */
.cols > *, .cols-even > *, .cb-main, .main { min-width: 0; }

/* ------------------------------------------------------------------ lähetettävät sopimukset */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--brand-green); color: #0b3d27;
  font-size: 11.5px; font-weight: 800; text-align: center; }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); }
.sends { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.card.send { margin: 0; display: grid; gap: 14px; }
.send-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.send-company { font-size: 16px; font-weight: 700; color: var(--ink); text-decoration: none; }
.send-company:hover { color: var(--accent); }
.send-mail .copy input { font-family: inherit; font-size: 14px; }
.button-like { display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.button-like:hover { border-color: #c9cbe0; }
.send-docs { display: grid; gap: 6px; }
.doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; }
.doc-ico { font-size: 10px; font-weight: 800; color: #b42318; background: #fde8e6; border-radius: 4px; padding: 3px 5px; }
.doc-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc a { font-weight: 600; font-size: 13px; }
.send-docs .zip { font-size: 13px; font-weight: 600; justify-self: start; }
.send-reminder { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 16px;
  border-radius: var(--radius); background: #fff7e6; border: 1px solid #f5d9a8; color: #7a4b00; text-decoration: none; }
.send-reminder:hover { border-color: #e9b862; }
@media (max-width: 760px) { .sends { grid-template-columns: 1fr; } .nav-badge { margin-left: 4px; } }
