/* =====================================================================
 * Portal Klienta — odwzorowanie wyglądu legacy (ORLEN Ochrona / Syenbi.fm)
 * Wzorzec: migration/docs/portal/screenshots-legacy/*
 * ===================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 12px;
  color: #2b2b2b;
  background: #4a4d52;
}
a { color: #1c4fb0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- kolory marki ---------- */
:root {
  --sidebar-top: #494c52;
  --sidebar-bot: #303237;
  --topbar-top: #3232cf;
  --topbar-bot: #1f1fa6;
  --active-blue: #1a5fd0;
  --btn-top: #4a4a9e;
  --btn-bot: #262663;
  --btn-border: #1a1a44;
  --panel-top: #ffffff;
  --panel-bot: #e6e6e6;
  --panel-border: #b9b9b9;
  --table-head: #17178a;
  --stripe: #dcebfb;
  --content-bg: #f6f7f8;
  --sidebar-w: 172px;
  --header-h: 46px;
}

/* ====================== LAYOUT SHELL ====================== */
.shell { min-height: 100vh; }

/* nagłówek: logo (lewy górny biały) + niebieski górny pasek */
.topband {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  display: flex; z-index: 50;
}
.brand-box {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: #ffffff; display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid #d7d7d7;
}
.topbar {
  flex: 1; background: linear-gradient(180deg, var(--topbar-top), var(--topbar-bot));
  display: flex; align-items: center; color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.topbar .tb-item {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 100%;
  font-size: 11px; font-weight: bold; letter-spacing: .3px;
  text-transform: uppercase; color: #fff; cursor: pointer;
  border-right: 1px solid rgba(255,255,255,.12);
}
.topbar .tb-item:first-child { border-left: 1px solid rgba(255,255,255,.12); }
.topbar .tb-item:hover { background: rgba(255,255,255,.10); text-decoration: none; }
.topbar .tb-item .ico { width: 15px; height: 15px; opacity: .95; }
.topbar .tb-instrukcja { color: #ffef3f; }
.topbar .tb-spacer { flex: 1; }
.topbar .tb-logo { padding: 0 18px; display: flex; align-items: center; }

/* Syenbi.fm logo */
.syenbi-logo { display: inline-flex; align-items: center; font-weight: 800; font-style: italic; }
.syenbi-logo .s-txt { color: #fff; font-size: 17px; letter-spacing: -.5px; }
.syenbi-logo .s-fm {
  background: #2aa8e0; color: #fff; border-radius: 50%;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; margin-left: 3px; box-shadow: inset 0 -2px 4px rgba(0,0,0,.2);
}
.syenbi-logo.small .s-txt { color: #2b3ea0; font-size: 13px; }
.syenbi-logo.small .s-fm { width: 20px; height: 20px; font-size: 10px; background: #2aa8e0; }

/* ORLEN Ochrona logo */
.orlen-logo { display: inline-flex; align-items: center; gap: 6px; }
.orlen-mark {
  background: #ec1c24; color: #fff; font-weight: 800; font-size: 13px; font-style: italic;
  padding: 3px 7px 3px 6px; border-radius: 3px; letter-spacing: .5px; position: relative;
}
.orlen-mark::before {
  content: ""; position: absolute; top: -3px; left: 8px; width: 12px; height: 8px;
  background: #ec1c24; clip-path: polygon(0 100%, 50% 0, 100% 100%); transform: rotate(-18deg);
}
.orlen-ochrona { color: #2b3560; font-weight: 800; font-size: 18px; }

/* lewe menu */
.sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bot));
  z-index: 40; padding-top: 8px;
}
.menu-item {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 14px; color: #e9e9ec;
  font-size: 12px; font-weight: bold; letter-spacing: .3px; text-transform: uppercase;
  cursor: pointer; position: relative; border-bottom: 1px solid rgba(0,0,0,.18);
  border-top: 1px solid rgba(255,255,255,.03);
}
.menu-item .ico { width: 20px; height: 20px; opacity: .85; flex: 0 0 20px; }
.menu-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.menu-item.active {
  background: linear-gradient(180deg, #2f7ae6, var(--active-blue));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.menu-item.active::after {
  content: ""; position: absolute; right: -14px; top: 0;
  border-top: 20px solid transparent; border-bottom: 20px solid transparent;
  border-left: 14px solid var(--active-blue);
}
.menu-item.active .ico { opacity: 1; }

/* obszar treści */
.content {
  margin-left: var(--sidebar-w); padding: 10px 14px 40px;
  min-height: calc(100vh - var(--header-h)); background: var(--content-bg);
  padding-top: calc(var(--header-h) + 10px);
}

/* ====================== PANELE ====================== */
.panel {
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  border: 1px solid var(--panel-border); border-radius: 7px;
  box-shadow: 0 1px 2px rgba(0,0,0,.12); padding: 22px 26px; margin: 8px 4px 0;
}
.panel-title { color: #1c4fb0; font-weight: bold; margin: 4px 6px 2px; font-size: 12px; }

/* ====================== PRZYCISKI ====================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bot));
  border: 1px solid var(--btn-border); border-radius: 5px;
  color: #fff; font-weight: bold; font-size: 11px; text-transform: uppercase;
  padding: 7px 14px; cursor: pointer; letter-spacing: .3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 1px rgba(0,0,0,.25);
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { filter: brightness(.92); }
.btn.btn-back { background: linear-gradient(180deg, #34346f, #1a1a3f); }
/* SNMIG-100 (D80): sciezka negatywna — odrzucenie kosztow przez klienta */
.btn.btn-danger { background: linear-gradient(180deg, #b34141, #8a2020); }
.btn.btn-sm { padding: 4px 9px; font-size: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ====================== FORMULARZE ====================== */
.form-row { display: flex; align-items: flex-start; margin-bottom: 14px; }
.form-row .lbl {
  width: 210px; min-width: 210px; text-align: right; padding: 6px 14px 0 0;
  font-weight: bold; color: #333;
}
.form-row .fld { flex: 1; max-width: 560px; }
input[type=text], input[type=password], input[type=date], input[type=number],
select, textarea {
  font-family: inherit; font-size: 12px; padding: 5px 7px;
  border: 1px solid #9aa0aa; border-radius: 3px; background: #fff; color: #222;
  width: 100%; max-width: 420px;
}
textarea { resize: vertical; min-height: 70px; }
select { max-width: 420px; }
.fieldset {
  border: 1px solid #cfcfcf; border-radius: 4px; padding: 12px 16px; margin-bottom: 14px;
  background: rgba(255,255,255,.4);
}
.fieldset > legend { font-weight: bold; color: #444; padding: 0 6px; }
.hint { color: #666; font-size: 11px; margin-top: 4px; }
/* SFM-226: walidacja per pole — podswietlenie pola + komunikat przy polu
   (paleta bledow spojna z .toast.err / .login-error) */
input.invalid, select.invalid, textarea.invalid {
  border-color: #e03131; background: #fff5f5;
}
.field-err { color: #842029; font-size: 11px; margin-top: 4px; }
/* SFM-222 / SO-102: parametry świadczenia usługi ciągłej (O2) — checkboxy dni/miesięcy */
.cs-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.cs-chk { display: inline-flex; align-items: center; gap: 3px; font-weight: normal; white-space: nowrap; }
.cs-checks.invalid { outline: 1px solid #e03131; outline-offset: 3px; border-radius: 3px; background: #fff5f5; }
/* SO-101: typeahead lokalizacji z chipami (formularz O2) */
.loc-ta { position: relative; max-width: 420px; }
.loc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.loc-chips:not(:empty) { margin-bottom: 5px; }
.loc-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  background: #eaf1fc; border: 1px solid #9db6e0; color: #1c4fb0; border-radius: 12px;
  padding: 2px 8px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.loc-chip-x { color: #1c4fb0; font-weight: bold; text-decoration: none; }
.loc-chip-x:hover { color: #a33; text-decoration: none; }
.loc-dd {
  position: absolute; left: 0; right: 0; z-index: 20; max-height: 260px; overflow-y: auto;
  background: #fff; border: 1px solid #9aa0aa; border-top: none; border-radius: 0 0 3px 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,.12); font-size: 12px;
}
.loc-opt { padding: 5px 8px; cursor: pointer; }
.loc-opt:hover, .loc-opt.active { background: #dce8fb; }
.loc-empty, .loc-more { padding: 6px 8px; color: #666; font-size: 11px; }
.loc-more { border-top: 1px solid #eee; }
.loc-more-btn { background: none; border: none; padding: 0; color: #1c4fb0; cursor: pointer; font: inherit; text-decoration: underline; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; padding-left: 210px; }

/* ====================== TABELE / LISTA ====================== */
.tabs { display: flex; gap: 4px; margin: 6px 4px 0; align-items: flex-end; }
.tab {
  background: linear-gradient(180deg,#f2f2f2,#dcdcdc); border: 1px solid #bfbfbf;
  border-bottom: none; border-radius: 6px 6px 0 0; padding: 7px 16px;
  font-size: 11px; color: #333; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #eaeaea; text-decoration: none; }
.tab.active { background: #fff; color: #1c4fb0; font-weight: bold; box-shadow: 0 -2px 0 var(--table-head) inset; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 4px; }
.pager { display: flex; align-items: center; gap: 6px; margin: 6px 4px; font-size: 11px; color: #333; }
.pager .pg {
  border: 1px solid #9db6e0; background: #eaf1fc; color: #1c4fb0; border-radius: 3px;
  padding: 2px 8px; cursor: pointer;
}
.pager .pg.active { background: #1c4fb0; color: #fff; border-color: #1c4fb0; }
.pager .pg:hover { background: #dce8fb; text-decoration: none; }

.grid-wrap { overflow-x: auto; border: 1px solid #b7c4da; border-radius: 3px; background: #fff; }
table.grid { border-collapse: collapse; width: 100%; font-size: 11px; }
table.grid thead th {
  background: linear-gradient(180deg,#2323a6,var(--table-head)); color: #fff;
  text-align: left; padding: 6px 8px; font-weight: bold; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.15); position: sticky; top: 0;
}
table.grid tbody td { padding: 5px 8px; border-bottom: 1px solid #cfe0f3; white-space: nowrap; }
table.grid tbody tr:nth-child(odd) { background: var(--stripe); }
table.grid tbody tr:nth-child(even) { background: #ffffff; }
table.grid tbody tr:hover { background: #cfe0f5; }
.status-pill {
  display: inline-block; padding: 2px 7px; border-radius: 3px; color: #fff;
  font-weight: bold; font-size: 10px; white-space: nowrap;
}
.mode-badge { font-size: 10px; color: #b00; font-weight: bold; }
.summary { margin: 12px 4px; color: #333; }
.row-actions a { margin-right: 6px; font-size: 11px; }

/* ====================== SZCZEGÓŁY (definicja pól) ====================== */
.detail { }
.detail .drow { display: flex; padding: 6px 0; }
.detail .drow:nth-child(odd) { background: rgba(0,0,0,.02); }
.detail .dlbl { width: 230px; min-width: 230px; text-align: right; padding-right: 16px; font-weight: bold; color: #333; }
.detail .dval { flex: 1; color: #222; }
.detail .dval .muted { color: #777; }
.section-h { color: #1c4fb0; font-weight: bold; margin: 20px 4px 8px; border-bottom: 1px solid #d5d5d5; padding-bottom: 4px; }
.history-item, .chat-item { padding: 8px 10px; border-bottom: 1px solid #e3e3e3; }
.history-item .meta, .chat-item .meta { color: #555; font-size: 11px; }
.chat-item.internal { background: #fff7e0; }
.badge-int { background: #b8860b; color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 3px; }

/* ====================== LOGIN ====================== */
.login-bg {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #d7dbe2; overflow: hidden;
}
.login-bg::before {
  content: "Syenbi"; position: absolute; left: 4%; top: 40%; font-size: 220px;
  font-weight: 800; font-style: italic; color: #b9c0cc; filter: blur(6px);
  font-family: Tahoma, sans-serif; letter-spacing: -8px;
}
.login-bg::after {
  content: "fm"; position: absolute; right: 6%; top: 22%;
  width: 260px; height: 260px; border-radius: 50%; background: #8fb9d8;
  filter: blur(6px); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 150px; font-weight: 800; font-style: italic;
  line-height: 260px; text-align: center;
}
.login-card {
  position: relative; z-index: 2; width: 400px; background: linear-gradient(180deg,#fbfbfd,#eef0f4);
  border-radius: 10px; box-shadow: 0 14px 40px rgba(0,0,0,.25); padding: 30px 34px 22px;
}
.login-card .lc-logo { text-align: center; margin-bottom: 22px; }
.login-card .lc-fields { display: flex; gap: 8px; align-items: stretch; }
.login-card .lc-inputs { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.login-card input {
  background: linear-gradient(180deg,#3f4fb0,#33409a); border: none; color: #fff;
  padding: 10px 12px; border-radius: 4px; max-width: none; width: 100%;
}
.login-card input::placeholder { color: #cdd4f2; }
.login-lock {
  width: 74px; background: linear-gradient(180deg,#3a3f7a,#262a52); border: none; border-radius: 6px;
  color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.login-lock:hover { filter: brightness(1.12); }
.login-card .lc-foot { text-align: right; margin-top: 14px; }
.login-card .lc-links { margin-top: 12px; font-size: 11px; }
/* SO-113: wskazówka „portal ma osobne hasło (nie Keycloak)” pod formularzem logowania */
.login-card .lc-note { margin-top: 10px; font-size: 11px; line-height: 1.4; color: #555; }
.login-error { background: #f8d7da; color: #842029; border: 1px solid #f1aeb5; border-radius: 4px; padding: 8px 10px; margin-bottom: 12px; font-size: 11px; }
.login-ok { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; border-radius: 4px; padding: 8px 10px; margin-bottom: 12px; font-size: 11px; }

/* ====================== TOASTY / KOMUNIKATY ====================== */
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2b52; color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); border-left: 4px solid #2f7ae6; max-width: 340px;
}
.toast.ok { border-left-color: #37b24d; }
.toast.err { border-left-color: #e03131; }

.env-flag {
  position: fixed; left: 8px; bottom: 8px; z-index: 200; font-size: 10px;
  background: #b8860b; color: #fff; padding: 3px 8px; border-radius: 3px; opacity: .9;
}
.env-flag.real { background: #2f7a2f; }

.empty { padding: 20px; color: #777; text-align: center; }
.spinner { padding: 30px; text-align: center; color: #777; }

/* ====================== BUDŻET (P7 — SFM-239) ======================
 * Tabela roczna read-only: rubryki × miesiące I–XII, pod-wiersze
 * Plan / Wykorzystano / Pozostało. Ujemne "Pozostało" (przekroczenie
 * planu) wyróżnione. Zebra wyłączona — grupy 3-wierszowe rozdziela
 * obramowanie, a rowspan psułby naprzemienne tło. */
table.budget-grid tbody tr:nth-child(odd),
table.budget-grid tbody tr:nth-child(even) { background: #fff; }
table.budget-grid th.bg-num, table.budget-grid td.bg-num { text-align: right; white-space: nowrap; }
table.budget-grid td.bg-name { font-weight: bold; background: #eef3fb; vertical-align: top; border-bottom: 2px solid #b7c4da; }
table.budget-grid td.bg-sub { color: #555; white-space: nowrap; }
table.budget-grid td.bg-neg { color: #b3261e; font-weight: bold; background: #fdecea; }
table.budget-grid tr.bg-total td { border-top: 2px solid #b7c4da; background: #f4f7fc; font-weight: bold; }
table.budget-grid tbody tr:nth-child(3n) td { border-bottom: 2px solid #b7c4da; }

@media (max-width: 720px) {
  .form-row { flex-direction: column; }
  .form-row .lbl { width: auto; text-align: left; padding: 0 0 4px; }
  .form-actions { padding-left: 0; }
  .detail .dlbl { width: 130px; min-width: 130px; }
}

/* SO-114: pliki zlecenia w O3 (protokół, zdjęcia przed/po) */
.file-row { padding: 2px 0; }
.photo-group { margin: 4px 0 10px; }
.photo-group-h { font-weight: bold; color: #444; margin-bottom: 6px; }
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-tile {
  display: flex; flex-direction: column; align-items: center; width: 132px; text-decoration: none;
  border: 1px solid #cfd6e2; border-radius: 4px; background: #fff; padding: 4px; color: #1c4fb0;
}
.photo-tile:hover { border-color: #1c4fb0; text-decoration: none; }
.photo-tile img, .photo-ph {
  width: 122px; height: 92px; object-fit: cover; display: flex; align-items: center; justify-content: center;
  background: #f1f3f7; color: #888; font-size: 11px; border-radius: 3px;
}
.photo-name { font-size: 10px; color: #555; max-width: 122px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
