/* Panel Meble Zbyszek - paleta wzieta ze styles.css strony,
   zeby narzedzie wygladalo jak czesc tego samego projektu. */

:root {
  color-scheme: light;
  --bg: #f2eee7;
  --page: #fffdfa;
  --soft: #f0eadf;
  --ink: #171514;
  --muted: #625d55;
  --subtle: #8a8177;
  --line: #e5ddcf;
  --accent: #6f8f45;
  --accent-strong: #4f7134;
  --accent-contrast: #ffffff;
  --warn: #b4741f;
  --danger: #a2402f;
  --shadow: 0 12px 32px rgba(71, 55, 35, 0.09);
  --radius: 12px;
  --font-ui: Arial, Helvetica, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1010;
  --page: #151719;
  --soft: #1b1d1c;
  --ink: #eee8dc;
  --muted: #b9ad9d;
  --subtle: #8e8373;
  --line: #2d2b25;
  --accent: #91b66f;
  --accent-strong: #b3d693;
  --accent-contrast: #111315;
  --warn: #d9a154;
  --danger: #d97b68;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h2 { font-size: 17px; }
table { border-collapse: collapse; width: 100%; }

/* ---------------- Logowanie ---------------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: grid;
  gap: 14px;
}

.login-brand {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--subtle);
}

.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-card label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: inherit;
}

.login-card button[type="submit"] {
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 11px;
  font-weight: 600;
  margin-top: 4px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* ---------------- Układ ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }

.brand {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.02em;
}

.tabs { display: flex; gap: 2px; }

.tab {
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.tab:hover { background: var(--soft); }
.tab.is-active { background: var(--ink); color: var(--page); }

/* `display` z regul ponizej wygrywa z domyslnym `display: none`, ktore
   przegladarka nadaje atrybutowi `hidden` - bez tej reguly plakietka
   pokazywalaby "0" nawet przy braku nowych zapytan. */
[hidden] {
  display: none !important;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.range { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.range button { padding: 6px 11px; font-size: 13px; color: var(--muted); }
.range button + button { border-left: 1px solid var(--line); }
.range button.is-active { background: var(--soft); color: var(--ink); font-weight: 600; }

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
}

.icon-button:hover { background: var(--soft); }

.content { padding: 20px; max-width: 1240px; margin: 0 auto; display: grid; gap: 16px; }
.view { display: grid; gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .content { padding: 14px; }
}

/* ---------------- Karty ---------------- */

.card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-note { margin: 4px 0 0; font-size: 13px; color: var(--subtle); flex-basis: 100%; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-visitors { background: var(--accent); }
.dot-views { background: var(--subtle); }
.dot-leads { background: var(--warn); }

/* ---------------- KPI ---------------- */

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.kpi {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi-label { font-size: 12px; color: var(--subtle); letter-spacing: 0.04em; text-transform: uppercase; }
.kpi-value { font-family: var(--font-display); font-size: 27px; margin-top: 4px; letter-spacing: -0.01em; }
.kpi-delta { font-size: 12px; margin-top: 3px; color: var(--muted); }
.kpi-delta.up { color: var(--accent-strong); }
.kpi-delta.down { color: var(--danger); }
.kpi-hint { font-size: 11px; color: var(--subtle); margin-top: 2px; }

/* ---------------- Wykres ---------------- */

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; min-width: 480px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--subtle); font-size: 10px; font-family: var(--font-ui); }
.chart-bar { fill: var(--subtle); opacity: 0.35; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart-point { fill: var(--accent); }
.chart-lead { fill: var(--warn); }

/* ---------------- Tabele ---------------- */

.table-wrap { overflow-x: auto; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
}

th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--subtle); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--soft); }
td.path { white-space: normal; word-break: break-word; max-width: 320px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag-tel { border-color: var(--accent); color: var(--accent-strong); }
.tag-whatsapp { border-color: var(--accent); color: var(--accent-strong); }
.tag-mailto { border-color: var(--subtle); }

/* ---------------- Paski ---------------- */

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { grid-column: 1 / -1; height: 5px; background: var(--soft); border-radius: 3px; overflow: hidden; margin-top: -3px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-value { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.funnel-step { padding: 9px 0; border-bottom: 1px solid var(--line); }
.funnel-step:last-child { border-bottom: none; }
.funnel-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.funnel-name { font-size: 14px; }
.funnel-count { font-family: var(--font-display); font-size: 18px; }
.funnel-track { height: 7px; background: var(--soft); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.funnel-fill { height: 100%; background: var(--accent); }
.funnel-drop { font-size: 12px; color: var(--subtle); margin-top: 3px; }

/* ---------------- Skrzynka ---------------- */

.inbox-head { align-items: flex-start; }
.inbox-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: 2px; flex-wrap: wrap; }
.filters button { padding: 5px 10px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.filters button.is-active { background: var(--soft); color: var(--ink); font-weight: 600; }
#lead-search { width: 220px; }

.lead-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.lead-row:hover { background: var(--soft); }
.lead-status { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.lead-status.new { background: var(--accent); }
.lead-status.open { background: var(--warn); }
.lead-status.won { background: var(--accent-strong); }
.lead-status.lost, .lead-status.spam { background: var(--line); }

.lead-main { min-width: 0; }
.lead-title { font-size: 15px; font-weight: 600; }
.lead-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-meta { text-align: right; font-size: 12px; color: var(--subtle); white-space: nowrap; }
.lead-warn { color: var(--danger); font-size: 12px; }

.empty { padding: 28px 6px; text-align: center; color: var(--subtle); font-size: 14px; }

/* ---------------- Szuflada ---------------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 21, 20, 0.35);
  display: flex;
  justify-content: flex-end;
  z-index: 40;
}

.drawer {
  position: relative;
  width: min(460px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--page);
  border-left: 1px solid var(--line);
  padding: 24px;
}

.drawer-close {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 24px;
  color: var(--muted);
  line-height: 1;
}

.drawer h2 { margin-bottom: 2px; }
.drawer-ref { font-size: 12px; color: var(--subtle); letter-spacing: 0.05em; }

.drawer-phone {
  display: block;
  margin: 16px 0;
  padding: 13px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--page);
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.drawer-field { display: grid; grid-template-columns: 110px 1fr; gap: 8px; padding: 5px 0; font-size: 14px; }
.drawer-field dt { color: var(--subtle); font-size: 13px; }
.drawer-field dd { margin: 0; word-break: break-word; }

.drawer-message {
  margin: 14px 0;
  padding: 14px;
  background: var(--soft);
  border-radius: 10px;
  white-space: pre-wrap;
  font-size: 14px;
}

.status-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 10px; }
.status-buttons button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--muted); }
.status-buttons button.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }

.drawer textarea { min-height: 80px; resize: vertical; }
.drawer-section-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--subtle); margin: 20px 0 8px; }

.journey { display: grid; gap: 6px; font-size: 13px; }
.journey-item { display: grid; grid-template-columns: 54px 1fr; gap: 8px; color: var(--muted); }
.journey-time { color: var(--subtle); font-variant-numeric: tabular-nums; }

/* ---------------- System ---------------- */

.status-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.status-line:last-child { border-bottom: none; }
.status-ok { color: var(--accent-strong); font-weight: 600; }
.status-bad { color: var(--danger); font-weight: 600; }
.definitions { display: grid; gap: 12px; font-size: 14px; }
.definitions dt { font-weight: 600; }
.definitions dd { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--page);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 60;
  box-shadow: var(--shadow);
}
