/* TORIS — nadpisanie Bootstrap 5. Wpiąć PO bootstrap.min.css.
   Jasny motyw, neutralna paleta, gęstość zbalansowana. */

:root {
  --toris-ink:        #14181f;
  --toris-ink-2:      #39414d;
  --toris-muted:      #5b6472;
  --toris-faint:      #8a929e;
  --toris-line:       #e4e7ec;
  --toris-line-soft:  #eef0f3;
  --toris-field:      #d5d9e0;
  --toris-bg:         #f6f7f9;
  --toris-surface:    #ffffff;
  --toris-zebra:      #fafbfc;
  --toris-nav:        #1b2029;
  --toris-brand:      #345d9d;
  --toris-brand-dark: #2a4b80;
  --toris-brand-soft: #eef2f8;

  --bs-primary: #345d9d;
  --bs-link-color: #345d9d;
  --bs-link-hover-color: #24406e;
  --bs-body-color: var(--toris-ink);
  --bs-body-bg: var(--toris-bg);
  --bs-border-color: var(--toris-line);
  --bs-border-radius: .5rem;
  --bs-border-radius-sm: .375rem;
  --bs-font-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                        "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --bs-body-font-size: .875rem;
  --bs-body-line-height: 1.55;
}

body { background: var(--toris-bg); color: var(--toris-ink); -webkit-font-smoothing: antialiased; }

h1, .h1 { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; }
h2, .h2 { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
h3, .h3 { font-size: 1rem;    font-weight: 650; }
.text-muted { color: var(--toris-muted) !important; }
.small, small { font-size: .8125rem; }

/* ---------- Nawigacja ---------- */
.navbar.bg-dark, .navbar-dark, .navbar.navbar-expand-lg.bg-body-tertiary {
  background: var(--toris-nav) !important;
  min-height: 52px;
  padding-top: 0; padding-bottom: 0;
  border-bottom: 0;
}
.navbar-brand { font-size: .95rem; font-weight: 650; letter-spacing: .04em; color: #fff !important; }
.navbar .nav-link { color: #a7aeb9 !important; font-size: .85rem; padding: .375rem .7rem !important; border-radius: .4rem; }
.navbar .nav-link:hover { color: #fff !important; background: rgba(255,255,255,.08); }
.navbar .nav-link.active { color: #fff !important; font-weight: 600; background: rgba(255,255,255,.12); }

/* drugi pasek (menu administracji) */
.toris-subnav, .nav.nav-pills {
  background: #fff;
  border-bottom: 1px solid var(--toris-line);
  padding: .25rem .5rem;
  gap: 2px;
}
.nav-pills .nav-link { color: var(--toris-muted); font-size: .8125rem; padding: .3rem .6rem; border-radius: .4rem; }
.nav-pills .nav-link:hover { background: var(--toris-bg); color: var(--toris-ink); }
.nav-pills .nav-link.active { background: #eef1f5; color: var(--toris-ink); font-weight: 600; }

.breadcrumb { font-size: .78rem; margin-bottom: .5rem; }
/* kontrast okruszków: --toris-faint dawał 2,9:1 na tle strony — za mało (min. 4,5:1) */
.breadcrumb-item, .breadcrumb-item a { color: var(--toris-muted); }
.breadcrumb-item a:hover { color: var(--toris-brand); }
.breadcrumb-item.active { color: var(--toris-ink-2); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--toris-faint); }

/* ---------- Karty / panele ---------- */
.card {
  background: var(--toris-surface);
  border: 1px solid var(--toris-line);
  border-radius: .55rem;
  box-shadow: none;
}
.card-header {
  background: var(--toris-zebra);
  border-bottom: 1px solid var(--toris-line-soft);
  font-size: .8125rem; font-weight: 650; color: var(--toris-ink);
  padding: .625rem .875rem;
}
.card-body { padding: .875rem; }

/* Kafle KPI: kolorowy pasek zamiast kolorowej ramki dookoła */
.card.border-primary, .card.border-warning, .card.border-danger,
.card.border-info, .card.border-success, .card.border-secondary {
  border-color: var(--toris-line) !important;
  border-left-width: 3px !important;
}
.card.border-primary { border-left-color: #345d9d !important; }
.card.border-warning { border-left-color: #c9922b !important; }
.card.border-danger  { border-left-color: #b34a4a !important; }
.card.border-info    { border-left-color: #3f8296 !important; }
.card.border-success { border-left-color: #3f8055 !important; }
.card.border-secondary { border-left-color: #c3c8d0 !important; }
.card .display-6, .card .display-5, .card .fs-1 {
  font-size: 1.6rem !important; font-weight: 650; font-variant-numeric: tabular-nums;
}

/* ---------- Tabele ---------- */
.table {
  --bs-table-bg: var(--toris-surface);
  --bs-table-striped-bg: var(--toris-zebra);
  --bs-table-hover-bg: #f3f6fb;
  --bs-table-border-color: var(--toris-line-soft);
  font-size: .845rem;
  margin-bottom: 0;
}
.table > :not(caption) > * > * { padding: .625rem .75rem; vertical-align: middle; }
.table > thead th {
  background: var(--toris-bg);
  border-bottom: 1px solid var(--toris-line);
  font-size: .7rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--toris-muted); white-space: nowrap;
}
.table > tbody > tr { border-color: var(--toris-line-soft); }
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table-responsive, .grid-view {
  background: var(--toris-surface);
  border: 1px solid var(--toris-line);
  border-radius: .55rem;
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
/* tabela w karcie ma już ramkę karty — bez drugiej */
.card .table-responsive { border: 0; border-radius: 0; }
.table td a, .table th a { font-weight: 600; }
.table .text-nowrap, .table td:has(> time) { font-variant-numeric: tabular-nums; }
/* nagłówek przyklejony przy długich listach */
.table-sticky > thead th { position: sticky; top: 0; z-index: 2; }

/* GridView Yii2 */
.grid-view .summary { font-size: .78rem; color: var(--toris-faint); padding: .625rem .875rem 0; }
.grid-view .filters input, .grid-view .filters select { font-size: .8125rem; }
.grid-view th a { color: var(--toris-muted); }
.grid-view th a:hover { color: var(--toris-ink); }

/* ---------- Badge stanów: stonowane ---------- */
.badge {
  font-size: .75rem; font-weight: 600; letter-spacing: 0;
  padding: .2rem .5rem; border-radius: .3rem;
}
.badge.bg-primary   { background: #eaf0fa !important; color: #2b4f86 !important; }
.badge.bg-success   { background: #e9f4ec !important; color: #256b3f !important; }
.badge.bg-warning   { background: #fdf3e2 !important; color: #8a5a12 !important; }
.badge.bg-danger    { background: #fdecec !important; color: #9b2c2c !important; }
.badge.bg-secondary { background: #f0f1f3 !important; color: #4b5563 !important; }
.badge.bg-info      { background: #e6f1f5 !important; color: #2f6070 !important; }
.badge.bg-dark      { background: #e6e8eb !important; color: #2b313a !important; }
.badge.bg-light     { background: #f0f1f3 !important; color: #4b5563 !important; }

/* ---------- Przyciski ---------- */
.btn { font-size: .8125rem; font-weight: 500; border-radius: .45rem; padding: .4rem .8rem; }
.btn-sm { font-size: .78rem; padding: .25rem .6rem; }
.btn-primary {
  background: var(--toris-brand); border-color: var(--toris-brand); font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--toris-brand-dark); border-color: var(--toris-brand-dark);
}
.btn-outline-secondary, .btn-secondary {
  background: #fff; border-color: var(--toris-field); color: var(--toris-ink-2);
}
.btn-outline-secondary:hover, .btn-secondary:hover {
  background: var(--toris-bg); border-color: #c3c8d0; color: var(--toris-ink);
}
.btn-warning, .btn-outline-warning {
  background: #fdf3e2; border-color: #f0e0c2; color: #8a5a12;
}
.btn-danger, .btn-outline-danger {
  background: #fdecec; border-color: #f6d5d5; color: #9b2c2c;
}
.btn-success, .btn-outline-success {
  background: #e9f4ec; border-color: #cfe6d7; color: #256b3f;
}
.btn:focus-visible, .form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 3px rgba(52,93,157,.18);
  border-color: var(--toris-brand);
}

/* ---------- Formularze ---------- */
.form-control, .form-select {
  font-size: .8125rem;
  border-color: var(--toris-field);
  border-radius: .45rem;
  padding: .45rem .7rem;
  color: var(--toris-ink);
}
.form-control::placeholder { color: #9aa1ab; }
.form-label { font-size: .78rem; font-weight: 600; color: var(--toris-muted); margin-bottom: .25rem; }
.form-check-input:checked { background-color: var(--toris-brand); border-color: var(--toris-brand); }
.input-group-text { background: var(--toris-bg); border-color: var(--toris-field); font-size: .8125rem; color: var(--toris-muted); }

/* ---------- Alerty i stany puste ---------- */
.alert { border-radius: .55rem; font-size: .845rem; border-width: 1px; }
.alert-success { background: #e9f4ec; border-color: #cfe6d7; color: #22603a; }
.alert-warning { background: #fdf3e2; border-color: #f0e0c2; color: #7d5211; }
.alert-danger  { background: #fdecec; border-color: #f6d5d5; color: #8d2828; }
.alert-info    { background: #eef2f8; border-color: #dbe6f6; color: #2b4f86; }

.toris-empty {
  background: var(--toris-surface);
  border: 1px solid var(--toris-line);
  border-radius: .55rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--toris-muted);
}
.toris-empty h3, .toris-empty .h3 { font-size: .9rem; font-weight: 650; color: var(--toris-ink); margin-bottom: .25rem; }
.toris-empty p { font-size: .8125rem; margin-bottom: .75rem; text-wrap: pretty; }

/* ---------- Drobiazgi ---------- */
code, kbd, .font-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  color: #6b4a8a;
  background: transparent;
}
hr { border-color: var(--toris-line); opacity: 1; }
.pagination { --bs-pagination-font-size: .8125rem; --bs-pagination-color: var(--toris-ink-2);
  --bs-pagination-active-bg: var(--toris-brand); --bs-pagination-active-border-color: var(--toris-brand);
  --bs-pagination-border-color: var(--toris-line); }
.dropdown-menu { font-size: .845rem; border-color: var(--toris-line); border-radius: .5rem;
  box-shadow: 0 6px 20px rgba(20,24,31,.10); }
.modal-content { border: 0; border-radius: .65rem; }
.modal-header, .modal-footer { border-color: var(--toris-line-soft); }

/* ================================================================
   Warstwa układu TORIS: szyna ikon (rail) + topbar z breadcrumbem.
   Przeniesione z !layout/toris-test.html (wariant 1c) + drobne dodatki.
   ================================================================ */

.toris-shell { display: flex; min-height: 100vh; }

.toris-rail {
  width: 58px; flex: none;
  background: var(--toris-nav);
  padding: 12px 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.toris-rail .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: #fff; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; margin-bottom: 10px;
}
.toris-rail a {
  width: 38px; height: 34px; border-radius: 8px;
  color: #8d95a1; text-decoration: none;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.toris-rail a:hover { background: rgba(255,255,255,.08); color: #fff; }
.toris-rail a.active { background: rgba(255,255,255,.14); color: #fff; }

.toris-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.toris-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; min-height: 44px;
  background: #fff; border-bottom: 1px solid var(--toris-line);
}
.toris-topbar .breadcrumb { margin: 0; min-width: 0; }
.toris-topbar-actions { display: flex; align-items: center; gap: 1rem; flex: none; }
.toris-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--toris-brand-soft); color: #2b4f86;
  font-size: 11px; font-weight: 650;
  display: flex; align-items: center; justify-content: center;
}

.toris-content { padding: 20px 22px 28px; flex: 1; }
.page-title { font-size: 1.35rem; font-weight: 650; letter-spacing: -.01em; margin: 0; }

/* stopka: dyskretna linijka zamiast szarego bloku */
.toris-main footer {
  background: transparent !important;
  border-top: 1px solid var(--toris-line);
  font-size: .75rem; color: var(--toris-faint);
  padding: .5rem 22px !important;
}

/* formularz strony (nowy/edycja) na białej karcie — spójnie z resztą paneli */
.toris-form-card { max-width: 860px; }
.toris-form-card > .card-body { padding: 1.125rem; }
.toris-form-card.toris-form-wide { max-width: none; }

/* nagłówek strony: tytuł + akcje; na wąskim ekranie akcje schodzą pod tytuł */
.toris-content > .d-flex, .toris-content > form.d-flex,
.toris-content > .d-flex > .d-flex, .toris-content > .d-flex > form.d-flex { flex-wrap: wrap; row-gap: .5rem; }

/* ================================================================
   Telefon / wąski ekran (< 768px): rail znika, zostaje ciemny navbar
   z pełnym menu (hamburger), topbar się zwija, tabele przewijają się
   w poziomie, lista zgłoszeń zamienia się w karty.
   ================================================================ */
@media (max-width: 767.98px) {
  .toris-rail { display: none; }
  .toris-content { padding: 14px 12px 20px; }

  /* nawigacja przyklejona do góry, menu po rozwinięciu z wygodnymi polami dotyku */
  #header { position: sticky; top: 0; z-index: 1030; }
  .navbar .navbar-collapse { padding: .25rem 0 .6rem; max-height: calc(100vh - 52px); overflow-y: auto; }
  .navbar .nav-link, .navbar-nav .nav-link.logout { padding: .6rem .7rem !important; font-size: .95rem; }

  /* topbar: jedna linia — okruszki skracane wielokropkiem, akcje kompaktowe */
  .toris-topbar { padding: 6px 12px; gap: 10px; }
  .toris-topbar-actions { gap: .5rem; }
  .toris-topbar > nav { flex: 1 1 0; min-width: 0; overflow: hidden; }
  .toris-topbar .breadcrumb { flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
  .toris-topbar .breadcrumb-item { overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
  .toris-topbar .breadcrumb-item:first-child { display: none; }
  .toris-topbar .breadcrumb-item:nth-child(2) { padding-left: 0; }
  .toris-topbar .breadcrumb-item:nth-child(2)::before { display: none; }
  .toris-topbar .breadcrumb-item:not(:last-child) { flex-shrink: 0; max-width: 45%; }
  .toris-topbar .btn { white-space: nowrap; }

  /* 16px w polach = iOS nie powiększa strony po dotknięciu pola */
  .form-control, .form-select, .form-control-sm, .form-select-sm,
  .input-group-sm > .form-control, .input-group-sm > .form-select { font-size: 16px; }
  .btn { padding: .5rem .85rem; }
  .btn-sm, .input-group-sm > .btn { font-size: .8125rem; padding: .4rem .7rem; }

  h1, .h1, .page-title { font-size: 1.2rem; }
  .card-body { padding: .75rem; }
  .toris-form-card > .card-body { padding: .875rem .75rem; }

  /* szerokie tabele: czytelne kolumny + przewijanie palcem zamiast ściskania do 1 słowa w linii */
  .table-responsive > .table:has(th:nth-child(4)) { min-width: 560px; }
  .table-responsive > .table:has(th:nth-child(6)) { min-width: 720px; width: max-content; max-width: 1100px; }
  /* siatka miesiąca: stałe 7 kolumn, przewijana */
  .table-responsive > .table.toris-calendar { width: 100% !important; min-width: 720px; max-width: none !important; }
  .table > :not(caption) > * > * { padding: .5rem .6rem; }

  /* pola filtrów z inline max-width rozciągają się na całą szerokość */
  .toris-content form.d-flex.flex-wrap > .form-select,
  .toris-content form.d-flex.flex-wrap > .form-control { max-width: none !important; flex: 1 1 100%; }

  /* paski pigułek (raporty, zakładki): jedna przewijana linia */
  .toris-content .nav.nav-pills:not(:has(.dropdown)) {
    flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none;
  }
  .toris-content .nav.nav-pills:not(:has(.dropdown))::-webkit-scrollbar { display: none; }

  /* blok dat w nagłówku zgłoszenia po zawinięciu wyrównany do lewej */
  .toris-content > .d-flex > .text-end { text-align: left !important; }

  /* stopka: sama nota praw */
  .toris-main footer { padding: .5rem 12px !important; }
  .toris-main footer span + span { display: none; }

  /* ---- lista zgłoszeń jako karty ---- */
  .toris-tickets, .toris-tickets > tbody { display: block; }
  .toris-tickets > thead { display: none; }
  .toris-tickets > tbody > tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px;
    padding: .65rem .75rem; border-bottom: 1px solid var(--toris-line-soft);
  }
  .toris-tickets > tbody > tr:nth-of-type(odd) { background: var(--toris-zebra); }
  .toris-tickets > tbody > tr > td {
    display: block; padding: 0; border: 0; background: transparent; box-shadow: none;
    font-size: .8rem; color: var(--toris-muted);
  }
  .toris-tickets > tbody > tr > td:empty { display: none; }
  .toris-tickets td.tk-num { flex: 1 1 auto; font-size: .845rem; }
  .toris-tickets td.tk-title { flex: 0 0 100%; font-size: .95rem; font-weight: 600; color: var(--toris-ink); padding: .2rem 0 .15rem; }
  .toris-tickets td.tk-title a { font-weight: 600; }
  .toris-tickets td.tk-upd { display: none; }
  .toris-tickets td[data-label]::before { content: attr(data-label) ": "; color: var(--toris-faint); }
  .toris-tickets td.tk-client div { display: none; }
  .toris-tickets td.tk-cb { order: -3; }
  .toris-tickets td.tk-num { order: -2; }
  .toris-tickets td.tk-badge { order: -1; }
  .toris-tickets td.tk-title { order: 0; }
  .toris-tickets td.tk-meta, .toris-tickets td.tk-upd { order: 1; }
  .toris-tickets .form-check-input, .toris-tickets input[type=checkbox] { width: 1.15rem; height: 1.15rem; }
  .grid-view > .d-flex { flex-direction: column; align-items: center; gap: .25rem; padding-bottom: .5rem; }
  .pagination { flex-wrap: wrap; justify-content: center; }
}

/* Bootstrap 5.3 text-bg-* — te same stonowane pastele co .badge.bg-* */
.badge.text-bg-primary   { background: #eaf0fa !important; color: #2b4f86 !important; }
.badge.text-bg-success   { background: #e9f4ec !important; color: #256b3f !important; }
.badge.text-bg-warning   { background: #fdf3e2 !important; color: #8a5a12 !important; }
.badge.text-bg-danger    { background: #fdecec !important; color: #9b2c2c !important; }
.badge.text-bg-secondary { background: #f0f1f3 !important; color: #4b5563 !important; }
.badge.text-bg-info      { background: #e6f1f5 !important; color: #2f6070 !important; }
.badge.text-bg-dark      { background: #e6e8eb !important; color: #2b313a !important; }
.badge.text-bg-light     { background: #f0f1f3 !important; color: #4b5563 !important; }

/* „Do przypisania": selecty nie kurczą się poniżej szerokości tekstu (ucięte „Priorytet *") */
.toris-triage .form-select { width: auto; flex: 0 0 auto; min-width: 9.5rem; }

/* QR w karcie pozycji ewidencji — SVG skaluje się do kontenera */
.qr-inline svg { width: 100%; height: 100%; display: block; }

/* edytor Quill (odpowiedź / notatka / nowe zgłoszenie) i render treści HTML */
.toris-editor .ql-toolbar { border-radius: .375rem .375rem 0 0; background: #fafbfc; }
.toris-editor .ql-container { border-radius: 0 0 .375rem .375rem; font-family: inherit; font-size: inherit; }
.toris-editor .ql-editor { min-height: 140px; }
.toris-editor .ql-editor img { max-width: 100%; height: auto; }
.toris-html img { max-width: 100%; height: auto; border-radius: .25rem; }
.toris-html p:last-child { margin-bottom: 0; }
.toris-html ul, .toris-html ol { padding-left: 1.4rem; }
.toris-html pre { white-space: pre-wrap; }

/* logo w railu = ikona Smart Systems */
.toris-rail .logo img { width: 26px; height: 26px; display: block; }
