/* Aeg Vaba CRM. Brand tokens from brand/identity-v1.md (direction A, Töökoda). */

@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/static/fonts/hanken-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/static/fonts/hanken-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #ffffff;
  --ink: #1f2328;
  --muted: #4f5962;
  --accent: #1e5a3c;
  --accent-soft: rgb(30 90 60 / 0.09);
  --panel: #eeede7;
  --line: #d9d7d0;
  --error: #b23a2e;
  --error-soft: rgb(178 58 46 / 0.09);
  --font: "Hanken Grotesk", system-ui, sans-serif;
  --radius: 6px;
  --gutter: clamp(16px, 3vw, 32px);
  --fast: 150ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 0 var(--line), 0 8px 24px -16px rgb(31 35 40 / 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 500 15px/1.5 var(--font); min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: clamp(26px, 2.4vw + 14px, 36px); letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 4px; font-weight: 700; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--error); min-height: 1.4em; margin: 0; }
.empty { color: var(--muted); margin: 8px 0 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
.label, .card__title, .block__title, .field > span {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px;
  padding: 10px var(--gutter); background: rgb(255 255 255 / 0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--accent); }
.brand small { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); margin-left: 4px; }
.brand--big { font-size: 30px; margin: 0 0 24px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav__link {
  padding: 10px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 600;
  white-space: nowrap; transition: color var(--fast), background var(--fast);
}
.nav__link:hover { background: var(--panel); color: var(--ink); }
.nav__link[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.user { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); }
.is-logged-out .topbar, .is-logged-out .fab { display: none; }
.main { padding: 24px var(--gutter) 120px; max-width: 1240px; margin: 0 auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform var(--fast) var(--ease), background var(--fast), border-color var(--fast);
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #174a31; border-color: #174a31; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn--danger { color: var(--error); border-color: var(--error); }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.fab {
  position: fixed; right: var(--gutter); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20;
  min-height: 52px; padding: 0 22px; border-radius: 26px; border: 0; background: var(--ink); color: #fff;
  font-weight: 700; box-shadow: 0 10px 30px -10px rgb(31 35 40 / 0.6); cursor: pointer;
}
.fab:hover { background: var(--accent); }

/* Page head, chips, search */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 24px; margin-bottom: 20px; }
.page-head__side { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { min-height: 44px; min-width: min(360px, 100%); padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  font-size: 14px; font-weight: 600; min-height: 36px; display: inline-flex; align-items: center;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Funnel strip on Today */
.funnel { list-style: none; display: flex; gap: 0; padding: 0; margin: 0 0 32px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.funnel li { flex: 1 0 auto; border-right: 1px solid var(--line); }
.funnel li:last-child { border-right: 0; }
.funnel a { display: grid; gap: 2px; padding: 12px 16px; text-decoration: none; color: var(--ink); transition: background var(--fast); }
.funnel a:hover { background: var(--panel); }
.funnel strong { font-size: 26px; letter-spacing: -0.02em; line-height: 1; }
.funnel span { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Sections and lists */
.block { margin-bottom: 36px; }
.block__title { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.block__note { margin: 0 0 8px; font-size: 14px; }
.count { background: var(--panel); color: var(--ink); border-radius: 999px; padding: 1px 8px; letter-spacing: 0; }
.rows { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.row {
  display: flex; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; padding: 14px 4px;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; transition: background var(--fast);
}
a.row:hover { background: var(--panel); }
.row--static { align-items: center; }
.row__main { display: grid; gap: 2px; min-width: 0; flex: 1 1 280px; }
.row__title { font-weight: 700; letter-spacing: -0.01em; }
.row__meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row__side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.row__next { font-size: 14px; }
.row__next.is-overdue { color: var(--error); font-weight: 600; }
.quote { margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--line); white-space: pre-wrap; font-size: 14px; }

/* Stage badges: the green family for progress, plain for waiting, red for closed-lost */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel); white-space: nowrap; }
.badge--replied, .badge--talking, .badge--proposal { background: var(--accent-soft); color: var(--accent); }
.badge--agreed, .badge--paid { background: var(--accent); color: #fff; }
.badge--no, .badge--optout, .badge--bounced { background: var(--error-soft); color: var(--error); }
.tag { display: inline-block; padding: 1px 8px; border-radius: var(--radius); background: var(--panel); font-size: 12px; font-weight: 600; text-decoration: none; color: var(--ink); margin-right: 4px; }
.tag--warn { background: var(--error-soft); color: var(--error); }

/* Lead page */
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.lead-head { margin-bottom: 24px; }
.lead-head__stage { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.stage-select { min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 2px solid var(--accent); background: var(--bg); font-weight: 700; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.lead-grid__main, .lead-grid__side { display: grid; gap: 20px; min-width: 0; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--bg); box-shadow: var(--shadow); }
.lead-grid__side .card { background: #fbfaf7; box-shadow: none; }
.card__title { margin: 0 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.field { display: grid; gap: 4px; }
.field--wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.quick { display: flex; gap: 4px; }
.quick .btn { white-space: nowrap; padding: 0 10px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 6px 0; min-height: 32px; }
details[open] > summary { margin-bottom: 8px; }
.contacts { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 14px; }
.contact__links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.touch { padding: 12px 0 12px 16px; border-left: 2px solid var(--line); position: relative; }
.touch::before { content: ""; position: absolute; left: -6px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.touch--email_in::before, .touch--call::before, .touch--meeting::before { background: var(--accent); }
.touch__head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.touch__body { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.history { font-size: 13px; color: var(--muted); }
.history ul { padding-left: 18px; margin: 0; }

/* Login */
.login { max-width: 400px; margin: 10vh auto 0; display: grid; gap: 14px; }
.login__title { font-size: 22px; }

/* Dialog */
.sheet { border: 0; border-radius: 10px; padding: 24px; width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-shadow: 0 30px 80px -20px rgb(31 35 40 / 0.5); }
.sheet::backdrop { background: rgb(31 35 40 / 0.45); }
.sheet__title { grid-column: 1 / -1; margin: 0; font-size: 22px; letter-spacing: -0.02em; }

/* Toasts */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-weight: 600; animation: rise 200ms var(--ease); }
.toast--error { background: var(--error); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 820px) {
  .lead-grid { grid-template-columns: 1fr; }
  .topbar { gap: 12px; }
  .brand small, .user { display: none; }
  .row__side { align-items: flex-start; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
