/* Kiri CRM — štýly. Vysoký kontrast (čitateľné na slnku), dotykové plochy min. 48 px, tmavý režim. */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #e9eeec;
  --text: #0d1714;
  --muted: #4a5753;
  --border: #c9d3cf;
  --brand: #0f5c4d;
  --brand-ink: #ffffff;
  --call: #0b7a3b;
  --call-ink: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #8a5300;
  --warn-bg: #fff4dc;
  --info-bg: #e3f1ee;
  --focus: #1a73e8;
  --radius: 14px;
  --nav-h: 64px;
  --tap: 48px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1412;
    --surface: #14201d;
    --surface-2: #1d2b27;
    --text: #eef4f2;
    --muted: #a9b8b3;
    --border: #2e403b;
    --brand: #4fc3a1;
    --brand-ink: #062019;
    --call: #2fbf6a;
    --call-ink: #04140a;
    --danger: #ff8a80;
    --danger-bg: #3a1513;
    --warn: #ffc56b;
    --warn-bg: #33260d;
    --info-bg: #15302a;
    --focus: #8ab4f8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 720px; margin: 0 auto; }
.screen-body { padding: 12px 16px 24px; }
.pad { padding: 16px; }
.pad-x { padding: 0 4px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.text-danger { color: var(--danger); font-weight: 600; }

/* --- horná lišta --- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 0 12px; padding-top: env(safe-area-inset-top);
  background: var(--brand); color: var(--brand-ink);
}
.topbar-title { flex: 1; margin: 0; font-size: 20px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-back {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); margin-left: -8px;
  color: inherit; text-decoration: none; font-size: 34px; line-height: 1;
}
.btn-link { background: none; border: 0; color: inherit; font: inherit; font-size: 15px; min-height: var(--tap); padding: 0 8px; text-decoration: underline; cursor: pointer; }
.is-mock .topbar::after { content: "MOCK"; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #ffd54f; color: #222; }

/* --- spodná navigácia --- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.bottom-nav a[aria-current="page"] { color: var(--brand); }
.nav-icon { width: 26px; height: 26px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.nav-icon-today { --m: url("icons/nav-today.svg"); }
.nav-icon-deals { --m: url("icons/nav-deals.svg"); }

/* --- tlačidlá --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 2px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; user-select: none;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 64px; font-size: 22px; }
.btn-sm { min-height: 44px; padding: 6px 12px; font-size: 15px; }
.btn-call { background: var(--call); color: var(--call-ink); min-height: 56px; min-width: 120px; font-size: 18px; }
.btn-call-small { min-height: var(--tap); min-width: 0; font-size: 16px; }
.icon-phone { width: 22px; height: 22px; background: currentColor; -webkit-mask: url("icons/phone.svg") center / contain no-repeat; mask: url("icons/phone.svg") center / contain no-repeat; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn-row-stack { flex-direction: column; }
.btn-row-stack .btn { width: 100%; }

/* --- zoznamy --- */
.greeting { margin: 4px 4px 8px; }
.list-section { margin-bottom: 18px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 4px 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.section-title.danger { color: var(--danger); }
.section-title.warn { color: var(--warn); }
.badge { min-width: 28px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 15px; text-align: center; }
.section-title.danger .badge { background: var(--danger); color: #fff; }
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.item-overdue { border-left: 5px solid var(--danger); }
.item-main { flex: 1; min-width: 0; min-height: var(--tap); display: flex; flex-direction: column; justify-content: center; color: var(--text); text-decoration: none; }
.item-title { font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 15px; }
.btn-open { min-width: 96px; }

/* --- karty --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-compact { padding: 12px 16px; }
.card-title { margin: 6px 0; font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
.card-title-sm { margin: 0; font-size: 20px; font-weight: 700; }
.card-link { display: inline-block; min-height: 32px; font-weight: 600; overflow-wrap: anywhere; }
.card-note { background: var(--surface-2); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--info-bg); color: var(--text); font-size: 14px; font-weight: 600; }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-muted { background: var(--surface-2); color: var(--muted); }
.chip-btn { min-height: 44px; padding: 6px 14px; border: 1px solid var(--border); font: inherit; font-size: 15px; cursor: pointer; }
.person-name { margin: 8px 0 4px; font-size: 19px; font-weight: 700; }
.note-preview { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); white-space: pre-wrap; }
.note-body { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.call-list { display: grid; gap: 8px; margin-bottom: 12px; }
.call-line { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.call-list .btn-call { flex: 1; min-height: 64px; font-size: 22px; }
.phone-text { font-variant-numeric: tabular-nums; }
.email-link { display: inline-flex; align-items: center; min-height: 40px; overflow-wrap: anywhere; }
.ext-link { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }

/* --- detail dealu --- */
.block { margin: 18px 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.block-title { margin: 0 0 8px; font-size: 18px; }
.person { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.person .person-name { margin-top: 0; }
.list-plain { gap: 8px; }
.act { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.act-overdue { border-left: 5px solid var(--danger); }
.act-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.act-subject { font-weight: 600; overflow-wrap: anywhere; }
.note { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.note .small { margin: 0; }

/* --- formuláre --- */
.form { display: grid; gap: 14px; }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fieldset-next { padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field-label { font-weight: 700; font-size: 16px; padding: 0; margin-bottom: 6px; }
.fieldset-next .field { margin-top: 10px; }
.field-hint { color: var(--muted); font-size: 14px; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea.input { resize: vertical; }
.input:focus { border-color: var(--brand); outline: none; }
.input-search { font-size: 18px; margin-bottom: 8px; }
.outcome-grid { display: grid; gap: 8px; }
.btn-outcome { min-height: 60px; font-size: 19px; background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outcome[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 2px solid var(--brand); border-radius: 12px; overflow: hidden; }
.seg { min-height: var(--tap); border: 0; background: var(--surface); color: var(--brand); font: inherit; font-weight: 700; cursor: pointer; }
.seg + .seg { border-left: 2px solid var(--brand); }
.seg[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.row-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: var(--tap); }
.check { width: 24px; height: 24px; accent-color: var(--brand); }

/* --- hlášky --- */
.alert { padding: 12px 14px; border-radius: 12px; margin: 8px 0; }
.alert p { margin: 0 0 6px; }
.alert-error { background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.alert-error .btn { margin-top: 6px; }
.alert-info { background: var(--info-bg); }
.alert-warn { background: var(--warn-bg); color: var(--text); }
.empty { text-align: center; padding: 48px 16px; }
.empty-title { font-size: 20px; font-weight: 700; }
.done { text-align: center; padding: 32px 8px; display: grid; gap: 12px; }
.done-mark { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; background: var(--call); -webkit-mask: url("icons/check.svg") center / contain no-repeat; mask: url("icons/check.svg") center / contain no-repeat; }
.done-title { margin: 0; font-size: 26px; font-weight: 800; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-weight: 600; z-index: 20; transition: opacity .4s;
}
.toast-hide { opacity: 0; }

@media (min-width: 720px) {
  .outcome-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Prihlásenie */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 16px; text-align: center; }
.login-logo { width: 96px; height: 96px; border-radius: 22px; }
.login-title { margin: 8px 0 0; font-size: 36px; font-weight: 800; letter-spacing: .5px; }
.login-sub { margin: 0 0 16px; }
.login-btn { min-width: 260px; }
.login-note { font-size: 14px; margin-top: 8px; }
