/* Inter (SIL OFL 1.1, vendored in static/vendor/inter) – latin + latin-ext covers Polish */
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/vendor/inter/inter-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/vendor/inter/inter-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Light theme is the default; dark only when chosen with the switch in the header (data-theme="dark") */
:root {
  color-scheme: light;
  --page: #f5f6f8; --surface: #ffffff; --surface-2: #f1f3f6; --surface-3: #e9ecf1;
  --text: #111827; --text-2: #4b5563; --muted: #8a919c;
  --grid: #eceef2; --axis: #d5d9e0; --border: #e4e7ec;
  --s1: #3b6ef5; --s2: #f0763c; --s3: #e0a400; --s4: #8b5cf6; --s5: #14a3a3; --s6: #c2417b;
  --good: #11804a; --good-bg: #e7f6ee; --bad: #d23f3f; --bad-bg: #fdecec;
  --warn-bg: #fff5dc; --warn-text: #7a5300;
  --accent: #3b6ef5; --accent-hover: #2f5bd4; --accent-soft: #ebf0fe; --accent-text: #fff;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 4px 12px rgba(16,24,40,.08);
  --radius: 14px; --radius-sm: 9px;
  --focus: 0 0 0 3px rgba(59,110,245,.25);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f1115; --surface: #171a21; --surface-2: #1f232c; --surface-3: #272c37;
  --text: #f3f4f6; --text-2: #b4bac5; --muted: #7f8794;
  --grid: #252a33; --axis: #353b47; --border: #2a2f3a;
  --s1: #5b8aff; --s2: #f08a55; --s3: #f0c040; --s4: #a78bfa; --s5: #2dd4bf; --s6: #f472b6;
  --good: #3ccf86; --good-bg: rgba(60,207,134,.12); --bad: #f07272; --bad-bg: rgba(240,114,114,.12);
  --warn-bg: #3a2f10; --warn-text: #f5d58a;
  --accent: #5b8aff; --accent-hover: #7aa0ff; --accent-soft: rgba(91,138,255,.14);
  --shadow: none; --shadow-lg: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* --- header ---------------------------------------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 20px; display: flex; align-items: center; gap: 20px; min-height: 60px;
}
header.top .brand { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
header.top .brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), #7c5cf5); color: #fff;
}
header.top .brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0; }
nav.main { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; padding: 10px 0; }
nav.main::-webkit-scrollbar { display: none; }
nav.main a {
  padding: 7px 12px; color: var(--text-2); border-radius: 8px; white-space: nowrap; font-weight: 500;
  transition: background .15s, color .15s;
}
nav.main a:hover { text-decoration: none; color: var(--text); background: var(--surface-2); }
nav.main a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.syncinfo { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.syncinfo .who { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }

/* --- layout ---------------------------------------------------------------- */
main { max-width: 1320px; margin: 0 auto; padding: 28px 20px 56px; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 15px; letter-spacing: -.005em; margin: 0 0 14px; font-weight: 650; }
h2 a.small { font-weight: 500; margin-left: 6px; }
.sub { color: var(--text-2); margin: 0 0 22px; max-width: 80ch; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }
/* phones: wide tables scroll inside their card instead of widening the whole page */
.grid > *, .card { min-width: 0; }
.card { overflow-x: auto; }
.scroll { max-width: 100%; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

/* --- KPI tiles ------------------------------------------------------------- */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.card .tiles { margin-bottom: 0; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card .tile { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.tile .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.tile .value { white-space: nowrap; font-size: clamp(18px, 1.9vw, 28px); font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.alert { background: var(--warn-bg); border-color: transparent; }
.tile.alert .label, .tile.alert .value { color: var(--warn-text); }
.up { color: var(--good); } .down { color: var(--bad); }

/* --- tables ---------------------------------------------------------------- */
.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th {
  color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; background: var(--surface); position: sticky; top: 0;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.n .small { white-space: normal; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* --- pills / messages ------------------------------------------------------ */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.pill.missed { background: var(--bad-bg); color: var(--bad); }
.pill.answered { background: var(--good-bg); color: var(--good); }
.pill.lost { background: var(--warn-bg); color: var(--warn-text); }
.msg { background: var(--accent-soft); color: var(--text); padding: 10px 14px; margin-bottom: 18px; border-radius: var(--radius-sm); }
.msg.error, .error { background: var(--bad-bg); }
.def { color: var(--muted); font-size: 12px; margin-top: 8px; }
details summary { cursor: pointer; color: var(--text-2); }

/* --- forms ----------------------------------------------------------------- */
form.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.card form.filters { border: none; box-shadow: none; padding: 0; background: transparent; }
form.filters label { display: flex; flex-direction: column; font-size: 12px; font-weight: 500; color: var(--text-2); gap: 4px; }
input, select, button, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--axis);
  border-radius: var(--radius-sm); padding: 7px 10px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--axis) 50%, var(--text-2)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
button, .btn {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; padding: 7px 14px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
button.ghost, .btn.ghost { background: transparent; color: var(--text-2); border-color: var(--axis); font-weight: 500; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.presets { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.presets a { padding: 6px 10px; border-radius: 999px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); }
.presets a:hover { text-decoration: none; color: var(--accent); background: var(--accent-soft); }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }

/* phone search on /polaczenia */
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search input { width: 100%; padding: 10px 14px 10px 38px; font-size: 15px; border-radius: 12px; }
.search::before {
  content: ""; position: absolute; left: 13px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%);
  background: var(--muted); -webkit-mask: var(--icon-search) center / contain no-repeat; mask: var(--icon-search) center / contain no-repeat;
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.searchbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.searchbar .count { color: var(--muted); font-size: 13px; }
.searchbar .quick a { margin-right: 10px; font-size: 13px; }
.loading { opacity: .55; transition: opacity .15s; }
mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* theme switch */
.theme-toggle { padding: 6px 8px; line-height: 0; }

/* --- charts / heatmap ------------------------------------------------------ */
.heat td { text-align: center; padding: 0; border: 2px solid var(--surface); font-size: 11px; height: 28px; min-width: 30px; font-variant-numeric: tabular-nums; border-radius: 6px; }
.heat th { text-align: center; padding: 2px; font-weight: 500; text-transform: none; letter-spacing: 0; position: static; }
.heat tbody tr:hover { background: transparent; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.chartbox { position: relative; height: 270px; }
ul.obs { margin: 0; padding-left: 18px; } ul.obs li { margin-bottom: 6px; }

/* --- login ----------------------------------------------------------------- */
body.auth { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--page); }
body.auth main { width: 100%; max-width: 400px; padding: 24px 16px; }
body.auth .card { padding: 28px; box-shadow: var(--shadow-lg); }
body.auth h1 { font-size: 22px; }
body.auth form input, body.auth form button { padding: 10px 12px; font-size: 15px; }
body.auth form button { justify-content: center; }

@media (max-width: 900px) {
  header.top { flex-wrap: wrap; gap: 0 12px; padding: 0 14px; }
  nav.main { order: 3; flex-basis: 100%; padding: 0 0 8px; }
  .syncinfo { margin-left: auto; }
}
@media (max-width: 640px) {
  main { padding: 20px 14px 40px; }
  .g2 { grid-template-columns: 1fr; }
  .tile .value { font-size: 23px; }
  h1 { font-size: 22px; }
  .syncinfo .who, .syncinfo .synctime { display: none; }
}
@media print {
  header.top, form.filters, .noprint, .searchbar { display: none !important; }
  body { background: #fff; } .card, .tile { border: none; box-shadow: none; }
}
form.filters label.check { gap: 4px; }
form.filters .checkbox { display: inline-flex; align-items: center; gap: 6px; height: 36px; color: var(--text); font-size: 13px; white-space: nowrap; }
form.filters .checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
form.filters .search { flex: 1 1 100%; }

/* call funnel */
.funnel { display: grid; gap: 10px; }
.funnel .step { display: grid; grid-template-columns: minmax(120px, 2fr) 3fr; gap: 12px; align-items: center; }
.funnel .bar { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.funnel .bar span { display: block; height: 100%; background: var(--s1); border-radius: 999px; }
.funnel .step:last-child .bar span { background: var(--good); }
@media (max-width: 640px) { .funnel .step { grid-template-columns: 1fr; gap: 4px; } }
.pending { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; margin-bottom: 6px;
  background: var(--accent-soft); border-radius: var(--radius-sm); }
.pending button { padding: 4px 10px; font-size: 12.5px; }
a.btn.tel { padding: 6px 10px; }
.multiples { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* callback list as cards on phones */
@media (max-width: 640px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 10px; }
  table.cards td { border: none; padding: 3px 0; text-align: left; white-space: normal; }
  table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  table.cards td.n { text-align: left; }
  table.cards select, table.cards button { margin-top: 4px; }
}
.presets a.key { font-weight: 700; color: var(--accent); background: var(--accent-soft); }
pre.report { margin: 0; white-space: pre-wrap; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; }
