/* Portal Warowny: czerń i żółć z logo firmy */
:root {
  --brand-yellow: #ffe600;
  --brand-black: #111;
  --bg: #f5f5f3;
  --panel: #fff;
  --text: #1c1c1c;
  --muted: #666;
  --line: #dcdcd8;
  --err: #b91c1c;
  --ok: #15803d;
  --radius: 8px;
}
* { box-sizing: border-box; }
/* atrybut hidden zawsze ukrywa, nawet gdy klasa ustawia display (np. flex) */
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }

/* pola i przyciski */
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; height: 38px; padding: 0 10px; border: 1px solid #c9c9c4; border-radius: 6px; font: inherit; background: #fff;
}
input:disabled { background: #f0f0ee; color: var(--muted); }
input:focus, select:focus { outline: 2px solid var(--brand-yellow); outline-offset: 1px; border-color: var(--brand-black); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 14px 0 0; }
button { font: inherit; cursor: pointer; }
.btn-primary {
  display: block; width: 100%; height: 40px; margin-top: 16px; border: 1px solid var(--brand-black); border-radius: 6px;
  background: var(--brand-yellow); color: var(--brand-black); font-weight: 600;
}
.btn-primary:hover { filter: brightness(0.95); }
.btn-secondary { height: 36px; padding: 0 14px; border: 1px solid #b8b8b2; border-radius: 6px; background: #fff; }
.btn-dark { height: 32px; padding: 0 12px; border: 1px solid #555; border-radius: 6px; background: transparent; color: #fff; }
.btn-dark:hover { border-color: var(--brand-yellow); color: var(--brand-yellow); }
.form-error { color: var(--err); font-size: 14px; margin: 12px 0 0; }
.form-ok { color: var(--ok); font-size: 14px; margin: 12px 0 0; }
.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }

/* logowanie */
.page-login { background: #fff; }
.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login-brand { background: var(--brand-black); color: #fff; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-logo { align-self: flex-start; background: #fff; padding: 10px 14px; border-radius: 6px; }
.login-logo img { display: block; height: 56px; width: auto; }
.login-stripe { height: 6px; width: 72px; background: var(--brand-yellow); margin-bottom: 14px; }
.login-brand h1 { color: #fff; font-size: 24px; margin: 0 0 4px; }
.login-brand p { color: #bbb; margin: 0; }
.login-brand .login-note { font-size: 12px; color: #888; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form form { width: 100%; max-width: 360px; }

/* górny pasek */
.topbar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--brand-black); color: #fff; border-bottom: 4px solid var(--brand-yellow); flex-wrap: wrap; }
.topbar-logo img { display: block; height: 30px; background: #fff; padding: 3px 6px; border-radius: 4px; }
.topbar-title { flex: 1; font-size: 15px; }
.topbar-station { font-size: 12px; color: #bbb; border: 1px solid #444; border-radius: 10px; padding: 1px 8px; }
.topbar-user { font-size: 14px; }
.topbar-user .role { color: var(--brand-yellow); }
.topbar form { margin: 0; }
.topbar-menu { display: contents; }
.topbar-chat { position: relative; order: 0; font-size: 20px; line-height: 1; text-decoration: none; padding: 6px 8px; border-radius: 6px; }
.topbar-chat:hover { background: #222; }
.chat-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand-yellow); color: var(--brand-black);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-style: normal; }
.topbar-chat .chat-badge { position: absolute; top: -2px; right: -6px; }
.chat-badge[hidden] { display: none; }
.tile .chat-badge { position: absolute; top: 10px; right: 10px; font-size: 13px; line-height: 22px; min-width: 24px; border: 1px solid var(--brand-black); }
.topbar-toggle { display: none; height: 40px; min-width: 44px; border: 1px solid #555; border-radius: 6px; background: transparent; color: #fff; font-size: 20px; line-height: 1; }

/* strony */
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.page.narrow { max-width: 560px; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; }
a.tile:hover, a.tile:focus-visible { border-color: var(--brand-black); box-shadow: 0 6px 16px rgba(0,0,0,.08), inset 0 -4px 0 var(--brand-yellow); transform: translateY(-2px); }
.tile-art { display: flex; align-items: center; justify-content: center; height: 112px; background: linear-gradient(180deg, #fafaf6 0%, #f1f1ea 100%); border-bottom: 1px solid var(--line); }
.tile-art img { display: block; width: 160px; height: 96px; }
.tile-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 16px; }
.tile strong { font-size: 16px; }
.tile-body > span { font-size: 13px; color: var(--muted); }
.tile-soon { opacity: 0.6; }
.tile-soon .tile-art img { filter: grayscale(1); }
.tag { align-self: flex-start; margin-top: 6px; font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #eee; color: #555; }

/* komunikaty */
.flash { max-width: 960px; margin: 16px auto 0; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.page .flash { margin: 0 0 16px; }
.flash-ok { background: #ecfdf3; border: 1px solid #a7e3bf; color: #14532d; }
.flash-error { background: #fef2f2; border: 1px solid #f5b5b5; color: #7f1d1d; }
.alert { background: #fffbe0; border: 1px solid #e6cf00; border-left: 4px solid var(--brand-yellow); padding: 10px 14px; margin: 0 0 16px; font-size: 14px; }
.alert a { text-decoration: none; }

/* drobne */
.muted { color: var(--muted); font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.tag-yellow { background: var(--brand-yellow); color: var(--brand-black); }
td .tag { margin: 0 4px 0 0; }
.topbar-link, a.topbar-user { color: #fff; text-decoration: none; font-size: 14px; }
.topbar-link:hover, a.topbar-user:hover { color: var(--brand-yellow); }
code.json { font-size: 12px; color: #444; word-break: break-word; }

/* administracja */
.page.wide { max-width: 1200px; }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: -4px 0 20px; }
.subnav a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--text); border-bottom-color: var(--brand-yellow); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.stat span { font-size: 13px; color: var(--muted); }
.stat strong { font-size: 26px; font-weight: 600; }
.stat em { font-style: normal; font-size: 12px; color: var(--muted); }
a.stat:hover { border-color: var(--brand-black); }
.card + .card, .card + section, section.card { margin-bottom: 16px; }
.card h2 { font-size: 16px; }
.card-accent, .card-custom { border-left: 4px solid var(--brand-yellow); }
.card-custom { background: #fffbe0; }
.table tr.row-custom td { background: #fff6b8; }
.table tr.row-custom:hover td { background: #fff0a0; }
.alert-warn { border-left-color: #f59e0b; }
.table-scroll { overflow-x: auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.cols > .card, .cols > div > .card { margin-bottom: 16px; }
.panels { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-top: 20px; }
.table-wrap { overflow-x: auto; padding: 4px 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 8px 6px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td form { margin: 0; }
.table tr.inactive td { color: #999; }
.table tr.row-bad td:nth-child(2) { color: var(--err); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; align-items: end; margin-bottom: 12px; }
.filters label { margin-top: 4px; }
.filters-actions { display: flex; gap: 12px; align-items: center; padding-top: 8px; }
.pager { display: flex; gap: 16px; align-items: center; margin: 4px 0 10px; font-size: 14px; flex-wrap: wrap; }
.pager-csv { margin-left: auto; }

/* ustawienia holowania */
h3 { font-size: 14px; margin: 18px 0 6px; }
fieldset.pricecat { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 14px; padding: 6px 14px 10px; }
fieldset.pricecat legend { font-weight: 600; padding: 0 6px; }
.grid5 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; align-items: end; }
.extras-table, .dict-table { margin-top: 8px; }
.extras-table td, .dict-table td { padding: 4px 6px; vertical-align: middle; }
.extras-table input[type=text], .dict-table input[type=text] { height: 32px; }
.extras-table th:nth-child(2) { width: 120px; }
.extras-table th:nth-child(3), .extras-table th:nth-child(4), .dict-table th:nth-child(3) { width: 70px; text-align: center; }
.table tr.new-row td { background: #fafaf7; }
.table tr.current-row td { background: #fffbe0; }
td.center { text-align: center; }
.field-error { display: block; color: var(--err); font-size: 12px; margin-top: 2px; }
.btn-auto { width: auto; padding: 0 20px; }

/* zlecenia */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.status-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 10px; background: #eef0f3; color: #374151; vertical-align: middle; }
h1 .status-badge { font-size: 13px; margin-left: 6px; }
.status-wycena .status-badge, .status-badge.status-wycena { background: #eef3ff; color: #1e40af; }
.status-przyjete .status-badge, .status-badge.status-przyjete { background: #fff7d6; color: #6b5300; }
.status-w_realizacji .status-badge, .status-badge.status-w_realizacji { background: #ffe9cc; color: #7a3d00; }
.status-zakonczone .status-badge, .status-badge.status-zakonczone { background: #dcfce7; color: #14532d; }
.status-anulowane .status-badge, .status-badge.status-anulowane { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.order-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select { width: auto; }
.btn-link.btn-primary { margin-top: 0; height: 36px; text-decoration: none; justify-content: center; }
.table.kv th { width: 38%; font-size: 13px; color: var(--muted); font-weight: 400; border-bottom: 1px solid #eee; padding: 6px 8px; }
.table.kv tr.total-row th, .table.kv tr.total-row td { font-weight: 700; font-size: 16px; color: var(--text); }
.dev-list { margin: 0 0 8px; padding-left: 20px; }
.filters .span-wide { grid-column: span 2; }
.filters-checks { grid-column: 1 / -1; display: flex; gap: 20px; flex-wrap: wrap; }
.orders-table td { font-size: 14px; }
#sheet .pg { margin-left: auto; margin-right: auto; }

/* administracja czatu */
.member-boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 12px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px 10px; }
.member-boxes label.check { margin-top: 8px; font-size: 14px; }
.channel-edit { border-bottom: 1px solid #eee; padding: 8px 0; }
.channel-edit summary { cursor: pointer; }
.transcript-body { white-space: normal; overflow-wrap: anywhere; }
.transcript tr.inactive .transcript-body { text-decoration: line-through; }

/* przyciski kontaktu i dojazdu na stronie zlecenia */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.btn-action { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border: 1px solid var(--brand-black);
  border-radius: 8px; background: #fff; color: var(--brand-black); text-decoration: none; font-weight: 600; font-size: 14px; }
.btn-action:hover { background: var(--brand-yellow); }
.btn-action small { font-weight: 400; color: var(--muted); }
.filters-toggle { display: none; }
.sheet-scroll { overflow-x: auto; }

/* ---------- telefon ---------- */
@media (max-width: 760px) {
  .cols, .panels { grid-template-columns: 1fr; }
  .filters .span-wide { grid-column: 1 / -1; }
  .login { grid-template-columns: 1fr; min-height: 0; }
  .login-brand { padding: 20px 16px; gap: 16px; }
  .login-brand .login-note { display: none; }
  .login-logo img { height: 40px; }
  .login-form { padding: 24px 16px 40px; }

  /* górny pasek: logo, nazwa i „☰”; reszta po rozwinięciu */
  .topbar { gap: 10px; padding: 8px 12px; }
  .topbar-toggle { display: block; }
  .topbar-menu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 0 4px; border-top: 1px solid #333; }
  .topbar.open .topbar-menu { display: flex; }
  .topbar-menu > a, .topbar-menu > span { padding: 10px 4px; font-size: 16px; }
  .topbar-menu .btn-dark { width: 100%; height: 44px; font-size: 16px; }
  .topbar-station { align-self: flex-start; }

  /* pola: 16 px (iPhone nie powiększa strony przy wpisywaniu), większe cele dotyku */
  input[type=text], input[type=password], input[type=date], input[type=number], input[type=tel], select, textarea { font-size: 16px; }
  input[type=text], input[type=password], input[type=date], select { height: 44px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  label.check { min-height: 32px; font-size: 15px; }
  .btn-secondary, .btn-link.btn-primary { min-height: 44px; }
  .page { padding: 16px 12px; }
  h1 { font-size: 19px; }
  .card { padding: 14px; }

  /* menu modułu przewijane w poziomie zamiast łamania na wiele wierszy */
  .subnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .subnav a { white-space: nowrap; }

  /* aplikacje po dwie w rzędzie */
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile-art { height: 76px; }
  .tile-art img { width: 112px; height: 67px; }
  .tile-body { padding: 10px 12px 12px; }
  .tile strong { font-size: 15px; }
  .tile-body > span { font-size: 12px; line-height: 1.35; }

  /* filtry: widać wyszukiwanie, reszta pod przyciskiem „Filtry” */
  .filters-toggle { display: inline-flex; align-items: center; }
  .filters:not(.filters-open) > div:not(.span-wide):not(.filters-actions) { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters-actions { grid-column: 1 / -1; }

  /* lista zleceń jako karty (cały wiersz klikalny) */
  .table-wrap.orders-wrap { padding: 0; background: none; border: 0; overflow: visible; }
  .orders-table thead { display: none; }
  .orders-table, .orders-table tbody { display: block; }
  .orders-table tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "num status" "veh amount" "client client" "route route" "created created";
    gap: 2px 10px; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
  .orders-table td { display: block; padding: 0; border: 0; }
  .orders-table td:nth-child(1) { grid-area: num; }
  .orders-table td:nth-child(2) { grid-area: created; font-size: 12px; color: var(--muted); }
  .orders-table td:nth-child(2) br { display: none; }
  .orders-table td:nth-child(2) .muted::before { content: " · "; }
  .orders-table td:nth-child(3) { grid-area: status; text-align: right; }
  .orders-table td:nth-child(4) { grid-area: veh; }
  .orders-table td:nth-child(5) { grid-area: client; }
  .orders-table td:nth-child(6) { grid-area: route; font-size: 13px; }
  .orders-table td:nth-child(7) { grid-area: amount; font-weight: 600; }
  .orders-table td[colspan] { grid-column: 1 / -1; }
  .orders-table td:first-child a::after { content: ""; position: absolute; inset: 0; }
  .orders-table td:first-child br { display: none; }
  .orders-table td:first-child .tag { margin-left: 6px; }
  .table.orders-table tr.row-custom td { background: none; }
  .table.orders-table tr.row-custom { background: #fff6b8; border-color: #e6cf00; }

  /* strona zlecenia */
  .quick-actions .btn-action { flex: 1 1 100%; justify-content: center; min-height: 48px; font-size: 16px; }
  .order-actions > .btn-link { flex: 1 1 100%; }
  .order-actions .inline-form { flex: 1 1 auto; }
  .order-actions .inline-form select { flex: 1; }
  .table.kv th { width: 40%; }
  .history-table tr { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; padding: 6px 0; border-bottom: 1px solid #eee; }
  .history-table td { border: 0; padding: 0 4px; }
  .history-table td:nth-child(4) { grid-column: 1 / -1; }
  .printopts { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .printopts .btn-primary { align-self: stretch; width: 100%; height: 48px; }
}

/* Powiadomienia portalu (przypomnienia zadań itp.): okienka w prawym górnym rogu, do zamknięcia */
.notice-stack { position: fixed; top: 64px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100% - 32px)); }
.notice { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--brand-yellow); border-radius: 8px; padding: 10px 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18); font-size: 14px; }
.notice strong { display: block; overflow-wrap: anywhere; }
.notice-body { color: var(--muted); font-size: 13px; margin-top: 2px; }
.notice-bar { display: flex; gap: 8px; margin-top: 8px; }
.notice-bar .btn-primary { margin: 0; text-decoration: none; display: inline-flex; align-items: center; }

/* nazwa modułu w górnym pasku (zamiast nagłówka „Auta zastępcze”, „Pliki”… na każdej stronie) */
.topbar-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topbar-module { font-weight: 700; color: var(--brand-yellow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-module::before { content: '›'; color: #9ca3af; font-weight: 400; margin-right: 8px; }
@media (max-width: 760px) {
  .topbar-title .topbar-app:has(+ .topbar-module) { display: none; }
  .topbar-module::before { display: none; }
}

/* pasek nad listą: główny przycisk i „Szukaj” rozwijający filtry (Holowanie) */
.orders-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.orders-bar .btn-secondary, .orders-bar .btn-primary { margin: 0; }
.sub-check { margin-left: 24px; }
