/* ==========================================================================
   AssetWave — motyw aplikacji
   --------------------------------------------------------------------------
   Ten sam język wizualny co strona produktowa (lpassetwave):
   kreda (tło), grafit (tekst), żółty marker (akcent: wybrane / ważne).
   Tryb ciemny jest czarno-biały.

   Wszystkie kolory w aplikacji pochodzą z tokenów poniżej — strony NIE
   powinny wpisywać kolorów na sztywno. Motyw przełącza klasa `dark`
   na <html> (ustawiana przez assets/js/aw-theme.js przed renderem).
   ========================================================================== */

:root {
  color-scheme: light;

  /* powierzchnie */
  --bg:          #F1F2EE;
  --surface:     #FAFBF8;
  --surface-2:   #ECEEE8;
  --surface-3:   #E1E4DC;
  --overlay:     rgb(20 22 21 / 0.42);

  /* tekst */
  --ink:   #1C1F1D;
  --ink-2: #4E5550;
  --ink-3: #7C837D;

  /* linie */
  --rule:        #D9DDD4;
  --rule-strong: #B9BFB6;

  /* marka: przyciski główne, nagłówki tabel */
  --brand:      #1C1F1D;
  --brand-2:    #000000;
  --on-brand:   #F6F7F3;
  --brand-ink:  #1C1F1D;          /* „akcentowy” tekst/linki */
  --tint:       rgb(28 31 29 / 0.05);
  --tint-2:     rgb(28 31 29 / 0.09);

  /* żółty marker */
  --accent:      #FFD23F;
  --accent-deep: #E8B800;
  --on-accent:   #1C1F1D;
  --ring:        rgb(232 184 0 / 0.55);

  /* statusy */
  --ok:        #2E7D4F;  --ok-soft:     #E3F1E8;
  --warn:      #A86A00;  --warn-soft:   #FBF0D6;
  --danger:    #B42318;  --danger-soft: #FBE4E1;
  --info:      #2F5D8C;  --info-soft:   #E2ECF6;
  --on-status: #FFFFFF;

  /* typografia i rytm */
  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgb(20 22 21 / 0.06), 0 1px 0 rgb(20 22 21 / 0.02);
  --shadow-2: 0 10px 30px -8px rgb(20 22 21 / 0.18), 0 2px 6px rgb(20 22 21 / 0.06);
  --shadow-3: 0 24px 60px -12px rgb(20 22 21 / 0.28);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --topbar-h: 64px;
  --max: 1440px;
}

html.dark {
  color-scheme: dark;

  --bg:          #0A0A0A;
  --surface:     #121212;
  --surface-2:   #1A1A1A;
  --surface-3:   #242424;
  --overlay:     rgb(0 0 0 / 0.62);

  --ink:   #F2F2F2;
  --ink-2: #B4B4B4;
  --ink-3: #7E7E7E;

  --rule:        #262626;
  --rule-strong: #3A3A3A;

  --brand:      #F2F2F2;
  --brand-2:    #FFFFFF;
  --on-brand:   #0A0A0A;
  --brand-ink:  #FFFFFF;
  --tint:       rgb(255 255 255 / 0.05);
  --tint-2:     rgb(255 255 255 / 0.09);

  --accent:      #FFFFFF;
  --accent-deep: #D9D9D9;
  --on-accent:   #0A0A0A;
  --ring:        rgb(255 255 255 / 0.45);

  --ok:        #7BD69B;  --ok-soft:     #11251A;
  --warn:      #F2C14E;  --warn-soft:   #2A2210;
  --danger:    #FF8A80;  --danger-soft: #2E1412;
  --info:      #9CC2EC;  --info-soft:   #13202E;
  --on-status: #0A0A0A;

  --shadow-1: 0 0 0 1px rgb(255 255 255 / 0.02);
  --shadow-2: 0 12px 34px -10px rgb(0 0 0 / 0.8), 0 0 0 1px rgb(255 255 255 / 0.04);
  --shadow-3: 0 28px 70px -14px rgb(0 0 0 / 0.9), 0 0 0 1px rgb(255 255 255 / 0.05);
}

/* ---------- baza ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0 !important; padding: 0 !important; overflow-x: hidden; }
body {
  background: var(--bg) !important;
  color: var(--ink) !important;
  font-family: var(--font) !important;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s, color .25s;
}
h1, h2, h3, h4 { color: inherit; letter-spacing: -0.02em; font-weight: 650; }
a { color: var(--brand-ink); }
::selection { background: var(--accent); color: var(--on-accent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
input, select, textarea, button { font-family: inherit; color: inherit; max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--rule); }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- układ strony ---------- */
.main-wrap, .wrap, .page-wrap, .aw-page {
  max-width: var(--max);
  margin: 0 auto !important;
  padding: 28px clamp(16px, 3vw, 40px) 64px !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.aw-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 24px; }
.aw-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  margin-bottom: 8px;
}
.aw-eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.aw-title { margin: 0; font-size: clamp(26px, 1.4rem + 1vw, 36px); font-weight: 680; line-height: 1.08; letter-spacing: -0.035em; }
.aw-lead { margin: 8px 0 0; color: var(--ink-2); font-size: 15.5px; max-width: 62ch; }
.aw-pagehead__text { min-width: 0; }
.aw-pagehead__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* akcje w nagłówku niezależnie od lokalnego .btn danej strony */
.aw-pagehead .aw-pagehead__actions .btn {
  height: 40px; padding: 0 16px; font-size: 14px; font-weight: 600; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; box-shadow: none;
}
.aw-pagehead .aw-pagehead__actions .btn-primary { background: var(--brand); border: 1px solid var(--brand); color: var(--on-brand); }
.aw-pagehead .aw-pagehead__actions .btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.aw-pagehead .aw-pagehead__actions .btn-secondary { background: var(--surface); border: 1px solid var(--rule-strong); color: var(--ink); }
.aw-pagehead .aw-pagehead__actions .btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.aw-pagehead .aw-pagehead__actions .btn-warn { background: var(--warn-soft); border: 1px solid transparent; color: var(--warn); }
.aw-pagehead h1.aw-title, .aw-ui .aw-pagehead h1.aw-title { color: var(--ink); font-size: clamp(26px, 1.4rem + 1vw, 36px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.08; margin: 0; padding: 0; border: 0; background: none; display: block; }
.aw-pagehead .aw-count { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; margin-left: 10px; vertical-align: middle; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0; background: var(--danger-soft); color: var(--danger); }
@media (max-width: 640px) { .aw-pagehead { margin-bottom: 18px; } .aw-pagehead__actions { width: 100%; } }

/* ---------- karty ---------- */
.card, .aw-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
  transition: background-color .25s, border-color .25s, box-shadow .25s;
}
.card h2, .card h3, .aw-card h2, .aw-card h3 { color: var(--ink); margin-top: 0; }
.section-label {
  font-weight: 600; color: var(--ink-3); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  margin: 22px 0 10px; display: flex; align-items: center; gap: 8px;
}

/* ---------- tabele ---------- */
.table-wrap, .tw, .table-container {
  background: var(--surface);
  border: 1px solid var(--rule) !important;
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}
table { width: 100%; border-collapse: collapse; }
table th, table td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
}
table th { font-weight: 600; position: sticky; top: 0; z-index: 2; }
table thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule-strong);
}
table thead th a, table thead th button:not(.btn) { color: inherit !important; }
table tbody tr:nth-child(odd) { background: transparent; }
table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table tbody td { background: inherit; }
table tbody tr { transition: background-color .12s; }
table tbody tr:hover td { background: var(--tint); }
table tbody tr:last-child td { border-bottom: 0; }

/* ---------- formularze ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="month"],
input[type="number"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea {
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s, background-color .25s;
}
input:hover:not(:focus):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--ink-3); }
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="time"]:focus, input[type="month"]:focus,
input[type="number"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="url"]:focus,
select:focus, textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
select { cursor: pointer; }
label { color: var(--ink-2); }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); }

/* ---------- przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 18px; height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600; font-family: var(--font); font-size: 14px; letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap;
  transition: background-color .18s, color .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); box-shadow: 0 6px 18px -6px rgb(0 0 0 / .35); }
.btn-primary::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  margin-right: -14px; transform: scale(0); transition: transform .3s var(--ease-spring), margin .3s var(--ease-out);
}
.btn-primary:hover::after { transform: scale(1); margin-right: 0; }
html.dark .btn-primary::after { background: var(--on-brand); }
.btn-secondary { background: var(--surface); border-color: var(--rule-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--tint-2); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 55%, var(--rule)); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
html.dark .btn-danger:hover { color: #0A0A0A; }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
html.dark .btn-success { color: #0A0A0A; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 15px; }

/* starsze przyciski w tabelach / modalach / formularzach */
.table-container button:not(.btn):not(.close),
.filter-container .filter-group button:not(.btn),
.modal button:not(.btn):not(.close):not(.aw-toast-close),
.form-container button:not(.btn),
.table-wrap button:not(.btn):not(.close) {
  font-weight: 600;
  background: var(--brand);
  color: var(--on-brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ---------- plakietki ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge-ok, .badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn, .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger, .badge.danger, .badge.err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info, .badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }

.rb { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.role-1 { background: var(--info-soft); color: var(--info); }
.role-2 { background: var(--warn-soft); color: var(--warn); }
.role-3 { background: var(--ok-soft); color: var(--ok); }

/* ---------- kafle statystyk ---------- */
.sg, .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.sc, .stat-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  padding: 16px 18px; text-align: left; transition: transform .18s var(--ease-out), box-shadow .18s, border-color .18s;
}
.sc:hover, .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--rule-strong); }
.sc .n, .stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sc .l, .stat-label { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- modale ---------- */
.modal-mask { position: fixed; inset: 0; z-index: 9000; display: none; align-items: center; justify-content: center; background: var(--overlay); backdrop-filter: blur(4px); }
.modal-mask.open { display: flex; }
.modal-box, .modal-content {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 24px;
  max-width: 760px; width: 95%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-3); animation: awModalIn .22s var(--ease-out);
}
@keyframes awModalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
.modal-title { margin: 0; font-size: 17px; font-weight: 650; color: var(--ink); }
.close {
  color: var(--ink-2); width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--tint); font-size: 22px; line-height: 1; user-select: none; border: none;
}
.close:hover { background: var(--tint-2); color: var(--ink); }

/* ---------- siatki formularzy ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.fg, .form-row-item { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.fg label, .form-row-item label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.fg input, .fg select, .fg textarea { width: 100%; height: 42px; padding: 0 12px; }
.fg textarea { height: 96px; padding: 10px 12px; }

/* ---------- paginacja ---------- */
.pagination-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 0 4px; }
.pagination-info { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.pagination-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-btn, .page-num {
  height: 36px; min-width: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--rule-strong); background: var(--surface);
  padding: 0 11px; font-weight: 600; cursor: pointer; color: var(--ink); transition: all .15s;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-num.active { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.page-num:hover:not(.active), .page-btn:hover:not(:disabled) { background: var(--surface-2); }

/* ---------- filtry ---------- */
.filter-bar, .filter-wrap {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }

/* ---------- puste stany ---------- */
.aw-empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.aw-empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ==========================================================================
   TOPBAR
   ========================================================================== */
header.topbar {
  position: sticky; top: 0; z-index: 2500;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 clamp(14px, 2.4vw, 32px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.brand, .topbar > .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand__mark { width: 28px; height: 28px; flex-shrink: 0; }
.brand__mark rect { fill: var(--brand); }
.brand__mark path { stroke: var(--accent); stroke-dasharray: 30; }
html.dark .brand__mark path { stroke: var(--on-brand); }
.brand:hover .brand__mark path { animation: aw-wave-draw .9s var(--ease-out); }
@keyframes aw-wave-draw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
.brand__name { font-weight: 700; font-size: 17px; letter-spacing: -0.03em; }
.brand__org { font-size: 12px; color: var(--ink-3); font-weight: 500; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--rule-strong); white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1360px) { .brand__org { display: none; } }

.topbar .menu-toggle {
  justify-self: end; border: 1px solid var(--rule-strong); background: var(--surface); cursor: pointer;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: none; align-items: center; justify-content: center; color: var(--ink);
}
.hamburger { position: relative; width: 18px; height: 12px; display: block; }
.hamburger span { position: absolute; left: 0; width: 100%; height: 1.75px; border-radius: 2px; background: currentColor; transition: transform .28s var(--ease-out), opacity .2s, top .28s var(--ease-out); }
.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 5px; }
.hamburger span:nth-child(3) { top: 10px; }
.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(1) { top: 5px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(3) { top: 5px; transform: rotate(-45deg); }

.navbar-inline { display: flex; align-items: center; justify-content: center; gap: 2px; margin: 0; padding: 0; }
.navbar-inline > li { list-style: none; position: relative; }
.navbar-inline > li > a, .navbar-inline > li > button {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); text-decoration: none;
  font-size: 14px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.navbar-inline > li > a:hover, .navbar-inline > li > button:hover,
.navbar-inline > li:hover > button, .navbar-inline > li:focus-within > button { color: var(--ink); background: var(--tint); }
.navbar-inline > li > a.active, .navbar-inline > li > button.active { color: var(--ink); }
.navbar-inline > li > a.active::after, .navbar-inline > li > button.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--accent);
}
.navbar-inline .chev { width: 10px; height: 10px; opacity: .55; transition: transform .2s; }
.navbar-inline > li:hover .chev, .navbar-inline > li:focus-within .chev { transform: rotate(180deg); }

.submenu {
  position: absolute; top: calc(100% + 6px); left: 50%; min-width: 280px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); padding: 6px; z-index: 2600;
  opacity: 0; visibility: hidden; transform: translate(-50%, 4px);
  transition: opacity .16s, visibility .16s, transform .2s var(--ease-out);
}
.submenu--wide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 4px; min-width: 560px; }
.submenu::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.submenu a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--ink-2);
  text-decoration: none; border-radius: var(--radius-sm); white-space: nowrap; font-size: 13.5px;
}
.submenu a::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--rule-strong); flex-shrink: 0; transition: background-color .15s, transform .2s var(--ease-spring); }
.submenu a:hover { background: var(--tint); color: var(--ink); }
.submenu a:hover::before { background: var(--ink-3); }
.submenu a.active { color: var(--ink); font-weight: 600; }
.submenu a.active::before { background: var(--accent); transform: scale(1.4); }
.submenu .submenu-label { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
@media (min-width: 1101px) {
  .navbar-inline > li:hover > .submenu, .navbar-inline > li:focus-within > .submenu { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
}

.profile-wrap { position: relative; display: flex; align-items: center; gap: 6px; justify-self: end; }
.aw-icon-btn {
  background: transparent; border: none; cursor: pointer; color: var(--ink-2);
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  transition: background-color .15s, color .15s;
}
.aw-icon-btn:hover { background: var(--tint-2); color: var(--ink); }
.aw-scope-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--rule);
  font-size: 12px; font-weight: 600; border-radius: 999px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.profile {
  width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: var(--on-brand);
  display: flex; align-items: center; justify-content: center; font-weight: 650; font-size: 13.5px;
  cursor: pointer; user-select: none; overflow: hidden; padding: 0; border: 0; margin-left: 4px;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--rule-strong);
  transition: box-shadow .2s;
}
.profile:hover, .profile-wrap.open .profile { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.profile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-menu {
  position: absolute; top: calc(100% + 10px); right: 0; width: 300px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); padding: 6px; z-index: 4500;
  opacity: 0; visibility: hidden; transform: translateY(4px);
  transition: opacity .16s, visibility .16s, transform .2s var(--ease-out);
}
.profile-wrap.open .profile-menu { opacity: 1; visibility: visible; transform: none; }
.profile-menu__head { display: flex; gap: 12px; align-items: center; padding: 12px 12px 14px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.profile-menu__head strong { display: block; font-size: 14px; color: var(--ink); }
.profile-menu__head span { display: block; font-size: 12px; color: var(--ink-3); }
.profile-menu a, .profile-menu .pm-row {
  display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--ink-2);
  text-decoration: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px;
}
.profile-menu a:hover { background: var(--tint); color: var(--ink); }
.profile-menu .pm-sep { height: 1px; background: var(--rule); margin: 6px 4px; }
#logout-timer { font-variant-numeric: tabular-nums; color: var(--ink-3); cursor: default; }

/* przełącznik motywu (segment) */
.aw-theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin: 4px 6px 6px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--rule); }
.aw-theme-switch button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px;
  border: 0; border-radius: 5px; background: transparent; color: var(--ink-3); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.aw-theme-switch button:hover { color: var(--ink); }
.aw-theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--rule); }

/* szuflada mobilna */
#navDrawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(380px, 90vw);
  background: var(--surface); border-left: 1px solid var(--rule); box-shadow: var(--shadow-3);
  transform: translateX(100%); transition: transform .34s var(--ease-out), visibility .34s;
  z-index: 4000; padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; visibility: hidden;
}
#navDrawer.open { transform: translateX(0); visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
.drawer-head strong { font-size: 15px; color: var(--ink); }
.drawer-close { border: 1px solid var(--rule); background: var(--surface-2); cursor: pointer; width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--ink); }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 0; padding: 0; }
.drawer-nav li { list-style: none; }
.drawer-nav a, .drawer-nav button {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px 12px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 550; text-align: left; cursor: pointer;
}
.drawer-nav a:hover, .drawer-nav button:hover { background: var(--tint); }
.drawer-nav a.active { background: var(--tint-2); }
.drawer-nav > li > button[data-sub] { justify-content: space-between; }
.drawer-nav > li > button[data-sub]::after { content: ""; width: 7px; height: 7px; border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor; transform: rotate(45deg); transition: transform .2s; opacity: .5; }
.drawer-nav > li > button[data-sub].sub-open::after { transform: rotate(-135deg); }
.drawer-sub { max-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 1px; padding-left: 10px; transition: max-height .3s var(--ease-out), margin .3s; }
.drawer-sub.open { max-height: 900px; margin: 2px 0 8px; }
.drawer-sub a { font-size: 14px; font-weight: 500; color: var(--ink-2); padding: 9px 12px; }
.drawer-sub a::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--rule-strong); flex-shrink: 0; }
.drawer-sub a.active { color: var(--ink); }
.drawer-sub a.active::before { background: var(--accent); }
.drawer-mask { position: fixed; inset: 0; background: var(--overlay); z-index: 3000; animation: awFade .2s; }
@keyframes awFade { from { opacity: 0; } }

@media (max-width: 1100px) {
  .navbar-inline { display: none !important; }
  .topbar { grid-template-columns: auto 1fr auto auto; }
  .topbar .menu-toggle { display: inline-flex; grid-column: 4; }
  .topbar > .profile-wrap { grid-column: 3; }
  .brand__org { display: none; }
}
@media (max-width: 560px) { .aw-scope-chip { display: none; } .brand__name { font-size: 16px; } }

/* pasek podglądu jako inny użytkownik */
.impersonate-bar {
  position: sticky; top: 0; z-index: 10000;
  background: var(--accent); color: var(--on-accent);
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px;
}
.impersonate-bar a { display: inline-flex; align-items: center; gap: 6px; background: var(--on-accent); color: var(--accent); text-decoration: none; padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; }
html.dark .impersonate-bar { background: #fff; color: #000; }
html.dark .impersonate-bar a { background: #000; color: #fff; }

/* ---------- wyszukiwarka globalna ---------- */
.aw-gsearch { position: relative; display: flex; align-items: center; }
.aw-gs-toggle { display: none; }
.aw-gs-box { position: relative; }
.aw-gs-box .aw-gs-ic-search { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.aw-gs-box input {
  width: 240px; max-width: 30vw; height: 38px; padding: 0 44px 0 34px !important;
  border: 1px solid var(--rule) !important; border-radius: var(--radius-sm) !important;
  background: var(--surface-2) !important; color: var(--ink) !important; font-size: 13.5px !important; transition: width .2s var(--ease-out), box-shadow .15s, background-color .15s !important;
}
.aw-gs-box input:focus { width: 340px; background: var(--surface) !important; border-color: var(--ink) !important; box-shadow: 0 0 0 3px var(--ring) !important; }
.aw-gs-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); border: 1px solid var(--rule-strong); border-radius: 5px; padding: 1px 6px; font-family: var(--font); pointer-events: none; background: var(--surface); }
.aw-gs-box input:focus ~ .aw-gs-kbd { opacity: 0; }
.aw-gs-results {
  position: absolute; top: calc(100% + 8px); right: 0; width: 440px; max-width: 92vw; max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: 6px; display: none; z-index: 4200;
}
.aw-gs-results.on { display: block; }
.aw-gs-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: var(--radius-sm); text-decoration: none; color: inherit; }
.aw-gs-item:hover, .aw-gs-item.sel { background: var(--tint-2); }
.aw-gs-ic { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.aw-gs-tx { min-width: 0; }
.aw-gs-tx b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.aw-gs-tx span { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aw-gs-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; flex-shrink: 0; margin-left: auto; padding-top: 2px; }
.aw-gs-empty { padding: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }
@media (max-width: 900px) {
  .aw-gs-box { position: fixed; top: calc(var(--topbar-h) + 6px); left: 10px; right: 10px; display: none; }
  .aw-gs-box.on { display: block; }
  .aw-gs-box input, .aw-gs-box input:focus { width: 100%; max-width: none; }
  .aw-gs-kbd { display: none; }
  .aw-gs-results { width: auto; left: 0; right: 0; }
  .aw-gs-toggle { display: inline-flex; }
}

/* ---------- toast ---------- */
#awToastWrap { position: fixed; top: calc(var(--topbar-h) + 14px); right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; max-width: 380px; width: calc(100vw - 36px); }
.aw-toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-2); font-size: 13.5px; line-height: 1.45; pointer-events: auto; position: relative; overflow: hidden;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule);
  opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .3s var(--ease-out);
}
.aw-toast-in { opacity: 1; transform: none; }
.aw-toast-out { opacity: 0; transform: translateX(20px); }
.aw-toast-icon { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; }
.aw-toast-icon svg { width: 13px; height: 13px; stroke-width: 2.4; }
.aw-toast-success .aw-toast-icon { background: var(--ok); }
.aw-toast-warning .aw-toast-icon { background: var(--warn); }
.aw-toast-error .aw-toast-icon { background: var(--danger); }
.aw-toast-info .aw-toast-icon { background: var(--ink); color: var(--bg); }
html.dark .aw-toast-icon { color: #0A0A0A; }
.aw-toast-msg { flex: 1; }
.aw-toast-close { background: transparent; border: none; cursor: pointer; color: var(--ink-3); padding: 0 2px; line-height: 1; flex-shrink: 0; }
.aw-toast-close:hover { color: var(--ink); }
@keyframes aw-bar-drain { from { width: 100%; } to { width: 0%; } }
.aw-toast-bar { position: absolute; bottom: 0; left: 0; height: 2px; width: 0%; animation: aw-bar-drain var(--aw-dur, 9s) linear forwards; background: var(--rule-strong); }
.aw-toast-success .aw-toast-bar { background: var(--ok); }
.aw-toast-warning .aw-toast-bar { background: var(--warn); }
.aw-toast-error .aw-toast-bar { background: var(--danger); }
.aw-toast-info .aw-toast-bar { background: var(--accent); }

/* ---------- potwierdzenie ---------- */
#awConfirmBd { display: none; position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); z-index: 99999; align-items: center; justify-content: center; }
#awConfirmBd.open { display: flex; }
#awConfirmBox { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 26px 26px 20px; max-width: 420px; width: 92%; box-shadow: var(--shadow-3); animation: awModalIn .2s var(--ease-out); }
#awConfirmIcon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; background: var(--surface-2) !important; color: var(--ink); }
#awConfirmIcon.danger { background: var(--danger-soft) !important; color: var(--danger); }
#awConfirmMsg { font-size: 16px; font-weight: 600; color: var(--ink); text-align: center; margin-bottom: 6px; line-height: 1.45; }
#awConfirmSub { font-size: 13px; color: var(--ink-3); text-align: center; margin-bottom: 20px; line-height: 1.5; }
#awConfirmBtns { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.aw-cm-btn { height: 40px; padding: 0 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background-color .15s, transform .1s; }
.aw-cm-btn:active { transform: scale(.97); }
.aw-cm-cancel { background: var(--surface); border-color: var(--rule-strong); color: var(--ink); }
.aw-cm-cancel:hover { background: var(--surface-2); }
.aw-cm-ok { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.aw-cm-ok.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
html.dark .aw-cm-ok.danger { color: #0A0A0A; }

/* ---------- dzwonek ---------- */
.bell-wrap { position: relative; }
.bell-badge { position: absolute; top: 4px; right: 3px; background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px; display: flex; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 0 0 2px var(--bg); }
.bell-panel {
  position: absolute; top: calc(100% + 10px); right: -8px; width: 360px; max-width: calc(100vw - 20px);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .16s, visibility .16s, transform .2s var(--ease-out);
  z-index: 4500; overflow: hidden;
}
.bell-panel.open { opacity: 1; visibility: visible; transform: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 12px; border-bottom: 1px solid var(--rule); font-weight: 650; font-size: 14px; color: var(--ink); }
.bell-head button { background: transparent; border: none; cursor: pointer; font-size: 12px; color: var(--ink-3); padding: 4px 8px; border-radius: 6px; }
.bell-head button:hover { background: var(--tint-2); color: var(--ink); }
.aw-push-row { padding: 10px 14px; border-bottom: 1px solid var(--rule); font-size: 12.5px; }
.aw-push-row button { border: 1px solid var(--rule-strong); background: var(--surface-2); color: var(--ink); border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font: inherit; font-weight: 600; }
.aw-push-row span { display: block; color: var(--ink-3); margin-top: 6px; }
.bell-head button:disabled { opacity: .45; cursor: default; background: transparent; }
.bell-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 4px 0; }
.bell-empty { padding: 30px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bell-empty svg { color: var(--ink-4, var(--ink-3)); margin-bottom: 4px; }
.bell-empty span { color: var(--ink-2); font-weight: 600; }
.bell-empty small { font-size: 12.5px; }
.bell-item { position: relative; display: flex; align-items: flex-start; gap: 11px; padding: 11px 16px; transition: background .15s; color: inherit; text-decoration: none; }
a.bell-item { cursor: pointer; }
.bell-item:hover { background: var(--tint); }
.bell-item + .bell-item { border-top: 1px solid var(--rule); }
.bell-item-icon { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--rule); color: var(--ink-2); }
.bell-item-icon svg { width: 15px; height: 15px; }
.bell-item.unread .bell-item-icon { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bell-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bell-item-title { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.35; word-break: break-word; }
.bell-item:not(.unread) .bell-item-title { font-weight: 500; color: var(--ink-2); }
.bell-item-msg { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bell-item-time { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.bell-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); flex-shrink: 0; margin-top: 6px; }
.bell-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--rule); background: var(--surface-2); font-size: 12.5px; }
.bell-foot a { color: var(--ink-2); text-decoration: none; font-weight: 600; }
.bell-foot a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- baner planu / komunikaty ---------- */
.aw-notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--surface); color: var(--ink); font-size: 13.5px; }
.aw-notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.aw-notice.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.aw-notice.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* ---------- druk ---------- */
@media print {
  .topbar, #navDrawer, .drawer-mask, #awToastWrap, .impersonate-bar { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
