/* ================================================================
   Kontakty — arkusz stylów
   Układ: „tablica dyspozytora” — gęsta siatka, kolor niesie
   informację (rynek, status, zaległy kontakt), reszta jest cicha.
   ================================================================ */

:root {
  --ink:        #131820;
  --ink-soft:   #4b5563;
  --paper:      #eceff4;
  --surface:    #ffffff;
  --line:       #dde3ec;
  --line-soft:  #eef1f6;

  --accent:     #2b4acb;
  --accent-dk:  #1f39a3;

  --first:      #0f7a6c;   /* rynek pierwotny */
  --first-bg:   #ddf1ee;
  --second:     #a95c18;   /* rynek wtórny */
  --second-bg:  #fbe9d6;

  --warn:       #b3261e;
  --warn-bg:    #fbe4e2;

  --radius:     8px;
  --shadow:     0 1px 2px rgba(19,24,32,.06), 0 6px 18px -12px rgba(19,24,32,.25);
  --sans:       system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif:      Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- marka ---------- */
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  min-width: 34px; height: 34px; flex: none; padding: 0 9px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-family: var(--serif); font-size: 14px; font-weight: 700;
  letter-spacing: .04em; line-height: 1;
  border-radius: 6px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.brand-text small { font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; text-transform: uppercase; }

/* ---------- logowanie ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 26px 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.brand--gate { margin-bottom: 6px; }
.gate-error { margin: 0; color: var(--warn); font-size: 13px; }
.gate-info { margin: 0; padding: 8px 10px; background: #eef1f6; border-radius: 6px;
             color: var(--ink-soft); font-size: 12.5px; }

/* ---------- pasek górny ---------- */
.top {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.search { flex: 1 1 320px; display: flex; gap: 8px; min-width: 220px; }
.search input { flex: 1; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }

.flash {
  background: #132; color: #fff;
  background: var(--ink);
  padding: 9px 22px; font-size: 13.5px;
}

/* ---------- kontener ---------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 22px; }

/* ---------- kafelki ---------- */
.board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 18px;
}
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  color: inherit; text-decoration: none;
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color .12s ease, transform .12s ease;
}
.tile:hover { text-decoration: none; transform: translateY(-1px); border-left-color: var(--accent); }
.tile b { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.tile span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.tile.is-on { border-left-color: var(--accent); box-shadow: var(--shadow); }
.tile--meet.is-on { border-left-color: var(--first); }
.tile--stale b { color: var(--warn); }
.tile--stale.is-on { border-left-color: var(--warn); }

/* ---------- filtry ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
}
.filters-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.count { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }

label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px;
        text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }

input[type=text], input[type=search], input[type=email], input[type=password],
input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; min-width: 0;
}
select { min-width: 140px; }
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9aa3b2; }

/* ---------- przyciski ---------- */
.btn {
  font: inherit; font-size: 13.5px; line-height: 1;
  padding: 9px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: #f5f7fa; text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn--ghost { background: transparent; }
.btn--wide { width: 100%; }
.btn--mini { padding: 5px 9px; font-size: 12px; }
.btn--danger { background: #fff; border-color: #e4b8b4; color: var(--warn); }
.btn--danger:hover { background: var(--warn-bg); }
.inline { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- tabela ---------- */
.grid-scroll { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.grid { width: 100%; border-collapse: collapse; min-width: 940px; }
.grid th {
  text-align: left; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f8fafc;
  position: sticky; top: 0;
}
.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.grid tbody tr:hover { background: #f8fafc; }
.grid tbody tr.is-parked { background: #fbfbfc; color: var(--ink-soft); }
.grid tbody tr.is-parked .who { color: var(--ink-soft); }

.c-rail { width: 6px; padding: 0 !important; }
.c-act  { width: 170px; }
.c-date { width: 120px; white-space: nowrap; }
.c-wish { max-width: 260px; }

.rail { display: block; width: 4px; height: 100%; min-height: 34px; border-radius: 2px; }
.rail--pierwotny { background: var(--first); }
.rail--wtorny    { background: var(--second); }

.who { font-weight: 600; font-size: 15px; color: var(--ink); }
.who:hover { color: var(--accent); }
.sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.sub a { color: var(--ink-soft); }
.sub--muted { color: #98a1af; }
.dot { padding: 0 4px; color: #c3cad6; }
.muted { color: #a8b0bd; }
.agent { font-size: 13.5px; }

.age { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.age--stale { color: var(--warn); font-weight: 600; }
.meet { font-size: 13px; }
.meet--soon { background: var(--first-bg); color: var(--first); font-weight: 600;
              padding: 2px 6px; border-radius: 4px; }

/* ---------- pigułki statusu ---------- */
.pill {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: #eef1f6; color: var(--ink-soft);
}
.pill--nowy         { background: #e8edfb; color: #2b4acb; }
.pill--kontakt      { background: #eef1f6; color: #4b5563; }
.pill--rozmowa      { background: #e6f0fa; color: #14618f; }
.pill--spotkanie    { background: var(--first-bg); color: var(--first); }
.pill--po_spotkaniu { background: #e4f3ea; color: #1f6b3d; }
.pill--oferta       { background: #f3ecfb; color: #6b34a8; }
.pill--negocjacje   { background: var(--second-bg); color: var(--second); }
.pill--transakcja   { background: #1f6b3d; color: #fff; }
.pill--rezygnacja   { background: var(--warn-bg); color: var(--warn); }

/* ---------- legenda / pusto ---------- */
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px;
          color: var(--ink-soft); margin: 14px 2px 0; }
.legend .rail { width: 12px; height: 4px; min-height: 0; margin-left: 10px; }
.legend .rail:first-child { margin-left: 0; }

.empty { background: var(--surface); border: 1px dashed var(--line);
         border-radius: var(--radius); padding: 44px; text-align: center; }
.empty p { color: var(--ink-soft); margin: 0 0 14px; }

/* ---------- karta klienta ---------- */
.card-wrap { padding-top: 16px; }
.crumbs { margin-bottom: 12px; font-size: 13px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 22px 18px;
}
.panel + .panel, .panel + .danger { margin-top: 14px; }
.panel--tight { padding: 16px 16px 14px; }
.panel-title { font-family: var(--serif); font-size: 22px; font-weight: 600;
               margin: 0 0 18px; letter-spacing: -.01em; }
.side-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
              color: var(--ink-soft); margin: 0 0 10px; font-weight: 600; }

.row { display: grid; gap: 14px; margin-bottom: 14px; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.row-2 { grid-template-columns: repeat(2, 1fr); }
.full { margin-bottom: 14px; }

.markets { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.markets legend { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
                  color: var(--ink-soft); padding: 0; margin-bottom: 4px; }
.chip {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 13.5px; text-transform: none; letter-spacing: 0; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
  flex-direction: row;
}
.chip input { accent-color: var(--first); }
.chip--pierwotny.is-on { background: var(--first-bg); border-color: var(--first); color: var(--first); font-weight: 600; }
.chip--wtorny.is-on    { background: var(--second-bg); border-color: var(--second); color: var(--second); font-weight: 600; }
.chip--wtorny input    { accent-color: var(--second); }

.panel-foot { display: flex; align-items: center; gap: 14px; padding-top: 6px;
              border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 16px; }
.meta { font-size: 12px; color: var(--ink-soft); }

.side .panel form { display: flex; flex-direction: column; gap: 8px; }
.side .panel form input[name=reason] { font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.5; }
.note { font-size: 13px; padding: 8px 10px; border-radius: 6px; margin: 0 0 10px; }
.note--parked { background: var(--second-bg); color: var(--second); }

.logform-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { flex-direction: row; align-items: center; gap: 6px; font-size: 11.5px; }

.timeline { list-style: none; margin: 16px 0 0; padding: 0 0 0 14px;
            border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before {
  content: ""; position: absolute; left: -21px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.t-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.t-body { font-size: 13.5px; margin-top: 2px; }

.danger { margin-top: 14px; }

/* ---------- responsywność ---------- */
@media (max-width: 1040px) {
  .cols { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .wrap { padding: 14px; }

  .top { padding: 10px 14px; gap: 10px; }
  .top-actions { width: 100%; margin-left: 0; }
  .top-actions .btn { flex: 1; }
  .row-3, .row-2 { grid-template-columns: 1fr; }
  .filters { gap: 10px; }
  .filters label { flex: 1 1 140px; }
  .filters-end { width: 100%; margin-left: 0; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .top, .filters, .board, .c-act, .legend { display: none; }
  body { background: #fff; }
}

/* ---------- nowe elementy ---------- */
.tile--new.is-on { border-left-color: var(--first); }
.c-city { width: 130px; }

.section-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: var(--accent);
  margin: 6px 0 12px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

input:disabled { background: #f4f6f9; color: var(--ink-soft); }

/* ---------- przełącznik filtrów (tylko telefon) ---------- */
.filters-toggle {
  display: none; width: 100%; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; padding: 11px 14px;
  font: inherit; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer;
}
.filters-toggle b {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px;
  margin-left: 4px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; letter-spacing: 0;
}
.filters-toggle .chev { color: var(--ink-soft); transition: transform .15s ease; }
.filters-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

@media (max-width: 720px) {
  .filters-toggle { display: flex; }
  .filters { display: none; }
  .filters.is-open { display: flex; }
  .filters label { flex: 1 1 100%; }
  .filters select { width: 100%; }
  .filters-end { width: 100%; margin-left: 0; justify-content: space-between; }
}
