/* PropertyMS CRM2 – wspólny arkusz stylów (układ wzorowany na "Staleks Reports") */
:root {
  --bg: #eceee9;
  --sidebar: #e6e9e3;
  --card: #ffffff;
  --line: #d6dbd3;
  --line-soft: #e8ebe6;
  --text: #1c2420;
  --muted: #5f6b64;
  --faint: #8b958f;
  --primary: #1f5c46;
  --primary-h: #174a38;
  --primary-soft: #e4efe9;
  --danger: #9b2c2c;
  --danger-soft: #f8e9e7;
  --warn: #c98a1b;
  --warn-soft: #fbf1de;
  --ok: #2f7a55;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.inline { display: inline; margin: 0; }
.hidden, [hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt0 { margin-top: 0 !important; }
.gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.red { color: var(--danger); } .green { color: var(--ok); } .orange { color: var(--warn); }

/* ------------------------------------------------------------------ szkielet */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 228px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; padding: 20px 20px 18px; color: var(--text); text-decoration: none !important; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 26px; height: 26px; }
.logo-text { font-weight: 800; font-size: 19px; letter-spacing: .2px; color: #18211d; }
.logo-sub { display: block; margin: 4px 0 0 34px; font-size: 11px; font-weight: 700; letter-spacing: 2.6px; color: #4b5650; }
.nav { padding: 6px 0; }
.nav-group { margin: 2px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 12px; margin: 0 0 0 12px; border-left: 3px solid var(--mc, #9aa49e); border-radius: 3px 0 0 3px; color: var(--text); font-weight: 500; text-decoration: none !important; }
.nav-item .ic { color: #39443e; }
.nav-item:hover { background: rgba(255,255,255,.55); }
.nav-item.active { background: #fff; font-weight: 700; }
.nav-sub { padding: 6px 0 8px 48px; display: flex; flex-direction: column; border-left: 3px solid var(--mc); margin-left: 12px; }
.nav-sub a { color: #4b5650; padding: 4px 8px 4px 0; font-size: 13.5px; text-decoration: none; position: relative; }
.nav-sub a:hover { color: var(--text); }
.nav-sub a.on { color: var(--text); font-weight: 700; }
.nav-sub a.on::before { content: ""; position: absolute; left: -14px; top: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--text); }
.nav-bottom { margin-top: auto; padding-bottom: 12px; }
.sidebar-foot { padding: 14px 20px 0; font-size: 11px; color: var(--muted); line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 28px; border-bottom: 1px solid var(--line-soft); background: var(--bg); position: sticky; top: 0; z-index: 30; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: #a6afa9; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { position: relative; display: flex; align-items: center; gap: 8px; width: 290px; height: 34px; padding: 0 8px 0 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--faint); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; font: inherit; background: transparent; height: 32px; padding: 0; }
.search kbd { font: 11px var(--font); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; color: var(--muted); background: #f7f8f6; }
.search-results { position: absolute; top: 38px; left: 0; right: -120px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 420px; overflow-y: auto; z-index: 50; padding: 4px 0; }
.search-results .grp { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .6px; padding: 8px 12px 2px; }
.search-results a { display: flex; gap: 8px; align-items: baseline; padding: 6px 12px; color: var(--text); text-decoration: none; }
.search-results a.sel, .search-results a:hover { background: var(--primary-soft); }
.search-results a span { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font: 600 13px var(--font); cursor: pointer; text-decoration: none !important; max-width: 230px; }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .ic { width: 16px; height: 16px; }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.langs a { padding: 0 10px; line-height: 32px; font-size: 12px; font-weight: 700; color: var(--text); text-decoration: none; border-left: 1px solid var(--line); }
.langs a:first-child { border-left: 0; }
.langs a.on { background: var(--primary); color: #fff; }
.content { padding: 24px 28px 40px; max-width: 1500px; width: 100%; }
.content-wide { max-width: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 1px solid transparent; background: transparent; border-radius: 4px; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: #fff; border-color: var(--line); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.only-mobile { display: none; }

/* ------------------------------------------------------------------ nagłówki stron */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.2px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 720px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 10px; }

/* ------------------------------------------------------------------ karty */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-top { border-top: 3px solid var(--primary); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-big .card-body { padding: 24px 24px 26px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-3 + .card, .grid-2 + .grid-2 { margin-top: 18px; }
.empty-state { text-align: center; padding: 50px 20px; }
.empty-state h1 { font-size: 22px; margin-bottom: 8px; }

/* lista "aplikacji" – jak "Najczęściej otwierane" */
.applist { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.applist a { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line-soft); color: var(--text); text-decoration: none; }
.applist a:first-child { border-top: 0; }
.applist a:hover { background: #f7f9f6; }
.applist .ico { width: 34px; height: 34px; border-radius: 6px; background: #eef1ec; display: flex; align-items: center; justify-content: center; color: var(--mc, var(--primary)); flex: none; }
.applist .ico .ic { width: 18px; height: 18px; }
.applist .tt { font-weight: 700; }
.applist .ds { color: var(--muted); font-size: 13px; }
.applist .tag { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ok)); margin-right: 6px; vertical-align: 1px; flex: none; }

/* spis działów */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; align-items: start; }
.dept { background: #fff; border: 1px solid var(--line); border-top: 2px solid var(--mc); border-radius: var(--radius); padding: 14px 16px 12px; }
.dept-h { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.dept-h .cnt { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; }
.dept a { display: block; padding: 4px 0; color: var(--text); font-size: 13.5px; }

/* ------------------------------------------------------------------ przyciski */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 16px; border: 1px solid var(--primary); background: #fff; color: var(--primary); border-radius: var(--radius); font: 700 13.5px var(--font); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: var(--primary-soft); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger.solid { background: var(--danger); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: #f4f6f3; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ------------------------------------------------------------------ formularze */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: #2c3530; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search]:not(.search input), input[type=tel], input:not([type]), select, textarea {
  font: 14px var(--font); color: var(--text); background: #fff; border: 1px solid #cdd3ca; border-radius: 4px; padding: 0 10px; height: 36px; width: 100%; min-width: 0;
}
textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31, 92, 70, .15); }
input:disabled, select:disabled, textarea:disabled { background: #f4f6f3; color: #66716b; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end; padding-bottom: 16px; border-bottom: 1px solid var(--line-soft); margin-bottom: 14px; }
.filters .field { width: auto; }
.filters .field select, .filters .field input { width: auto; min-width: 150px; }
.filters .grow input { min-width: 220px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
fieldset { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 16px 16px; margin: 0; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; }

/* ------------------------------------------------------------------ tabele */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12.5px; color: #2c3530; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbf9; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fafbf9; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl .row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.tbl .row-muted td { color: var(--faint); }
.tbl a.rowlink { color: var(--text); font-weight: 600; }
.tbl .actions { white-space: nowrap; text-align: right; }
.sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------------ znaczniki */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #e3f1e9; color: #22663f; }
.badge-warn { background: var(--warn-soft); color: #8a5a07; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #eef0ed; color: var(--muted); }
.badge-blue { background: #e4edf6; color: #2d5f86; }
.flash { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; background: #fff; }
.flash-success { border-color: #b7d8c4; background: #f1f8f4; color: #1f5c46; }
.flash-error { border-color: #e3bcb7; background: var(--danger-soft); color: var(--danger); }
.flash-info { border-color: #c9d8e6; background: #f2f6fa; color: #2d5f86; }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid #ecd6a8; color: #6d4b0b; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 22px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stats .card { margin: 0; padding: 14px 16px; }

/* zakładki */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--primary); }

/* pliki */
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.files li:last-child { border-bottom: 0; }
.files li a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.files li .muted { margin-left: auto; white-space: nowrap; }
.ft { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 22px; border-radius: 3px; font-size: 10px; font-weight: 800; color: #fff; flex: none; }
.ft-pdf { background: #c8462b; } .ft-img { background: #7b4fc6; } .ft-doc { background: #2b6cb0; } .ft-xls { background: #217346; } .ft-cad { background: #a14f79; } .ft-other { background: #7b857f; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 8px; border: 2px dashed #c4ccc1; border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbf9; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { display: none; }

/* pager */
.pager { display: flex; gap: 4px; padding: 14px 0 0; flex-wrap: wrap; }
.pager a { min-width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--text); text-decoration: none; padding: 0 8px; }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-gap { padding: 0 6px; line-height: 30px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 24, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 8px; border-top: 3px solid var(--primary); width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 860px; }
.modal-body { padding: 22px 24px; }
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* sticky pasek akcji */
.sticky-bar { position: sticky; top: 60px; z-index: 20; background: rgba(236, 238, 233, .96); backdrop-filter: blur(4px); padding: 10px 0; margin: -10px 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line-soft); }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state.dirty { color: var(--warn); }
.save-state.err { color: var(--danger); font-weight: 600; }

/* uprawnienia */
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.perm-line { display: flex; gap: 6px; align-items: center; font-size: 13px; padding: 2px 0; }
.perm-line.yes .ic { color: var(--ok); } .perm-line.no { color: var(--faint); }
.matrix th.rot { height: 120px; vertical-align: bottom; padding-bottom: 8px; }
.matrix th.rot div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.matrix td.c, .matrix th.c { text-align: center; }
.matrix .modrow td { background: #f4f6f3; font-weight: 700; }

/* ------------------------------------------------------------------ logowanie */
.auth-body { background: var(--bg); }
.auth-wrap { width: 388px; max-width: calc(100% - 32px); margin: 120px auto 40px; }
.auth-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.brand-auth { padding: 0; }
.auth-card .card-body { padding: 26px 26px 24px; }
.auth-card .h1 { font-size: 20px; }
.auth-card .muted { margin: 4px 0 18px; }
.auth-links { display: flex; justify-content: space-between; font-size: 13px; margin-top: 4px; }
.auth-links a { text-decoration: underline; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ------------------------------------------------------------------ portal */
.portal-top { display: flex; align-items: center; gap: 24px; padding: 0 28px; height: 66px; background: var(--sidebar); border-bottom: 1px solid var(--line-soft); }
.portal-top .brand { padding: 0; }
.portal-top .logo-sub { margin-top: 2px; }
.portal-tabs { display: flex; gap: 4px; }
.portal-tabs a { padding: 8px 12px; border-radius: 4px; color: var(--muted); font-weight: 600; text-decoration: none; }
.portal-tabs a.on { background: #fff; color: var(--text); box-shadow: inset 0 -2px 0 var(--primary); }
.portal-content { max-width: 1200px; margin: 0 auto; }
.portal-foot { max-width: 1200px; margin: 0 auto; padding: 10px 28px 30px; display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.portal-foot span { margin-left: auto; }

/* ------------------------------------------------------------------ kalendarz */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--line); border-top: 1px solid var(--line); background: #fff; }
.cal-h { padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafbf9; text-align: center; }
.cal-d { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px 6px; position: relative; }
.cal-d.out { background: #f6f7f5; }
.cal-d.out .cal-n { color: var(--faint); }
.cal-d.we { background: #fbfaf5; }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-n { font-size: 12px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.cal-add { opacity: 0; border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0 2px; }
.cal-d:hover .cal-add { opacity: 1; }
.cal-ev { display: block; margin-top: 3px; padding: 2px 6px; font-size: 12px; border-radius: 3px; color: #fff; background: #2f7a55; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; text-decoration: none !important; }
.cal-ev.due { background: #fff !important; color: var(--text); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--warn)); }
.cal-ev.due.over { border-left-color: var(--danger); }
.cal.small .cal-d { min-height: 64px; }

/* ------------------------------------------------------------------ responsywność */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .search { width: 200px; }
  .chip-text { display: none; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; z-index: 60; transition: left .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .only-mobile { display: inline-flex; }
  .grid-2, .grid-3, .row-2, .row-3, .row-4 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 30px; }
  .topbar { padding: 0 12px; }
  .search { display: none; }
  .crumbs { display: none; }
  .kv { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head .actions { margin-left: 0; justify-content: flex-start; }
  .portal-top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
}

/* ------------------------------------------------------------------ przeglądy */
.pick { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.pick > .card { margin: 0; }
.pick-list .card-body { max-height: calc(100vh - 230px); overflow-y: auto; }
.applist.flat { border: 0; border-radius: 0; }
.applist.flat a { padding: 10px 16px; }
.applist a.sel { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.applist a > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.insp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.insp-layout > .card, .insp-side > .card { margin-bottom: 18px; }
.insp-side { position: sticky; top: 124px; }
.insp-proto .card-body { padding: 16px; }
.kv-tight { grid-template-columns: 120px 1fr; font-size: 13px; }
.file-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-main a { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.files li .file-main + form, .files li form { margin-left: 0; }
.hist { border-top: 1px solid var(--line-soft); }
.hist:first-child { border-top: 0; }
.hist summary { display: flex; gap: 14px; align-items: center; padding: 10px 20px; cursor: pointer; list-style: none; }
.hist summary::-webkit-details-marker { display: none; }
.hist[open] summary { background: #f7f9f6; }
.hist-body { padding: 14px 20px 20px; overflow-x: auto; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help-grid h4 { margin: 0 0 8px; }
.help-grid code { background: #f1f3ef; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.tpl-meta { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto auto; gap: 12px; align-items: end; }
.deleted-secs > summary { cursor: pointer; list-style: none; padding-bottom: 14px; }
@media (max-width: 1200px) {
  .insp-layout { grid-template-columns: 1fr; }
  .insp-side { position: static; }
  .tpl-meta { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .pick { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ PPM */
.ppm-wrap { overflow: auto; max-height: calc(100vh - 260px); border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.ppm { border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.ppm th, .ppm td { border-right: 1px solid #e3e7e1; border-bottom: 1px solid #e3e7e1; padding: 0 4px; height: 26px; white-space: nowrap; }
.ppm thead th { position: sticky; z-index: 3; background: #f4f6f3; font-weight: 600; text-align: center; }
.ppm thead tr.ppm-months th { top: 0; height: 24px; }
.ppm thead tr.ppm-weeks th { top: 24px; font-size: 10.5px; color: var(--muted); }
.ppm thead th.m0 { background: #eef1ec; } .ppm thead th.m1 { background: #f7f8f6; }
.ppm th.now, .ppm td.now { background: #fff6dc !important; }
.ppm .ppm-fix { position: sticky; left: 0; z-index: 2; background: #fff; }
.ppm thead .ppm-fix { z-index: 4; background: #f4f6f3; }
.ppm .ppm-name { min-width: 220px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; text-align: left; box-shadow: 1px 0 0 #d6dbd3; }
.ppm td:nth-child(n+2):nth-child(-n+6) { color: var(--muted); max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.ppm tr.ppm-group td { background: #eef1ec; font-weight: 700; font-size: 12px; height: 30px; }
.ppm tr.ppm-group .ppm-fix { background: #eef1ec; }
.ppm td.ppm-w { width: 24px; min-width: 24px; }
.ppm td[data-w] { cursor: pointer; }
.ppm td.ppm-w[data-w]:hover { background: var(--primary-soft); }
.ppm td.ppm-e { padding: 2px 1px; }
.ppm td.ppm-e span { display: block; border-radius: 3px; padding: 0 4px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 600; min-width: 18px; }
.ppm-edit { border: 0; background: none; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.ppm-edit:hover { color: var(--primary); text-decoration: underline; }
.ppm-legend { display: inline-flex; gap: 4px; align-items: center; margin-left: auto; }
.sw { display: inline-block; width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.ppm-legend .sw { width: 14px; height: 14px; cursor: default; }
.ppm-colors .sw.on { outline: 2px solid var(--text); outline-offset: 1px; }
@media print {
  @page { size: A3 landscape; margin: 6mm; }
  .sidebar, .topbar, .page-head .actions, .filters, .flash { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .ppm-wrap { max-height: none; overflow: visible; border: 0; }
  .ppm { font-size: 8px; }
  .ppm td.ppm-e span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ------------------------------------------------------------------ uprawnienia / kontakty */
.perm-mod { border-left: 3px solid var(--mc); padding: 2px 0 4px 12px; }
.perm-mod-h { display: flex; gap: 8px; align-items: center; font-weight: 700; margin-bottom: 6px; }
.perm-mod .perm-line { align-items: flex-start; padding: 3px 0; }
.perm-mod .perm-line input { margin-top: 3px; }
.perm-mod code { font-size: 11px; }
.role-line { display: flex; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.role-line:last-of-type { border-bottom: 0; }
.role-line input { margin-top: 3px; }
.contact { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.contact:last-child { border-bottom: 0; }
.portal-insp { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.portal-insp:last-child { border-bottom: 0; }
.portal-insp h3 { font-size: 15px; margin-bottom: 6px; }
.chips-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chips-filter a { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 13px; text-decoration: none; }
.chips-filter a.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips-filter a.on .dot { box-shadow: 0 0 0 2px #fff; }
.impersonation { background: var(--warn-soft); border-bottom: 1px solid #ecd6a8; padding: 8px 28px; font-size: 13px; display: flex; gap: 12px; align-items: center; }
@media (max-width: 860px) { .portal-insp { grid-template-columns: 1fr; } }
