/* Panel administracji – rama (menu boczne + górny pasek). Etap A przebudowy panelu. */
.adm { --adm-side: 252px; --adm-side-w: 72px; display: grid; grid-template-columns: var(--adm-side) minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.adm.is-collapsed { grid-template-columns: var(--adm-side-w) minmax(0, 1fr); }

/* --- menu boczne (zawsze ciemne, jak na koncepcji) --- */
.adm-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px; background: linear-gradient(180deg, #0B1D2D, #071522); color: #D6E4F0; overflow: hidden; z-index: 60; }
.adm-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: #fff; text-decoration: none; min-width: 0; }
.adm-brand img { max-width: 150px; height: auto; }
.adm-brand__mark { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 10px; background: var(--blue); color: #fff; }
.adm-brand__text { display: grid; line-height: 1.15; min-width: 0; }
.adm-brand__text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-brand__text small { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #8FB0CB; }
.adm-nav { flex: 1 1 auto; overflow-y: auto; display: grid; align-content: start; gap: 2px; padding-right: 2px; scrollbar-width: thin; scrollbar-color: #1B3A55 transparent; }
.adm-link, .adm-group > summary { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #D6E4F0; text-decoration: none; font-weight: 600; font-size: 14.5px; cursor: pointer; list-style: none; border: 0; background: none; width: 100%; text-align: left; font-family: inherit; }
.adm-group > summary::-webkit-details-marker { display: none; }
.adm-link:hover, .adm-group > summary:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.adm-link svg, .adm-group > summary > svg { flex: 0 0 auto; color: #8FB0CB; }
.adm-link--top.is-active { background: var(--blue); color: #fff; }
.adm-link--top.is-active svg { color: #fff; }
.adm-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-chev { display: inline-flex; transition: transform .15s; color: #8FB0CB; }
.adm-group[open] > summary .adm-chev { transform: rotate(180deg); }
.adm-group[data-active] > summary { color: #fff; }
.adm-sub { display: grid; gap: 1px; margin: 2px 0 6px 20px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .12); }
.adm-sub .adm-link { padding: 7px 10px; font-weight: 500; font-size: 14px; color: #B9CEDF; }
.adm-sub .adm-link.is-active { background: var(--blue); color: #fff; font-weight: 700; }
.adm-badge { flex: 0 0 auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: #EF4444; color: #fff; font-size: 11.5px; font-weight: 800; line-height: 1.5; text-align: center; }
.adm-collapse { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-top: 1px solid rgba(255, 255, 255, .1); border-radius: 0; background: none; color: #8FB0CB; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.adm-collapse:hover { color: #fff; }

/* zwinięte menu: same ikony */
.adm.is-collapsed .adm-brand__text, .adm.is-collapsed .adm-label, .adm.is-collapsed .adm-chev, .adm.is-collapsed .adm-sub { display: none; }
.adm.is-collapsed .adm-brand img { display: none; }
.adm.is-collapsed .adm-link, .adm.is-collapsed .adm-group > summary, .adm.is-collapsed .adm-collapse { justify-content: center; padding-left: 0; padding-right: 0; }
.adm.is-collapsed .adm-group > summary { position: relative; }
.adm.is-collapsed .adm-group > summary .adm-badge { position: absolute; top: 2px; right: 8px; min-width: 16px; padding: 0 4px; font-size: 10px; }

/* --- górny pasek --- */
.adm-body { min-width: 0; display: flex; flex-direction: column; }
.adm-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.adm-search { flex: 1 1 auto; max-width: 560px; display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 42px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--muted); }
.adm-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.adm-search input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; }
.adm-search kbd { padding: 2px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font: 600 11px var(--font); color: var(--muted); }
.adm-top__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.adm-iconbtn { position: relative; display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--text); text-decoration: none; font: 700 12px var(--font); cursor: pointer; }
.adm-iconbtn:hover { background: var(--blue-soft); }
.adm-dot { position: absolute; top: 2px; right: 2px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: #EF4444; color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.adm-burger { display: none; }
.adm-user { position: relative; }
.adm-user > summary { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 12px; cursor: pointer; list-style: none; }
.adm-user > summary::-webkit-details-marker { display: none; }
.adm-user > summary:hover { background: var(--blue-soft); }
.adm-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 800; }
.adm-user__who { display: grid; line-height: 1.2; }
.adm-user__who small { color: var(--muted); font-size: 12px; }
.adm-user__menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; display: grid; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 12px 32px rgba(7, 21, 34, .18); }
.adm-user__menu a, .adm-user__menu button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); text-align: left; text-decoration: none; font: 600 14px var(--font); cursor: pointer; }
.adm-user__menu a:hover, .adm-user__menu button:hover { background: var(--blue-soft); }

/* --- treść: istniejące podstrony działają w nowej ramie --- */
.adm-main { padding: 22px 24px 48px; min-width: 0; }
.adm-main .section { padding: 0; }
.adm-main .container, .adm-main .container.narrow-wide { max-width: none; width: auto; margin: 0; padding-left: 0; padding-right: 0; }
.adm-main h1.h2 { margin: 0 0 14px; font-size: 28px; font-weight: 800; }
.adm-main .subnav { margin-top: 0; }
.adm-main > .alert { margin: 0 0 16px; }
.adm-overlay { display: none; }

@media (max-width: 960px) {
    .adm, .adm.is-collapsed { grid-template-columns: minmax(0, 1fr); }
    .adm-side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .adm.is-open .adm-side { transform: none; }
    .adm.is-open .adm-overlay { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3, 10, 18, .55); }
    .adm.is-collapsed .adm-brand__text, .adm.is-collapsed .adm-label, .adm.is-collapsed .adm-chev { display: revert; }
    .adm.is-collapsed .adm-sub { display: grid; }
    .adm.is-collapsed .adm-link, .adm.is-collapsed .adm-group > summary { justify-content: flex-start; padding: 9px 12px; }
    .adm-collapse { display: none; }
    .adm-burger { display: inline-grid; }
    .adm-top { padding: 8px 14px; gap: 8px; }
    .adm-search kbd, .adm-user__who { display: none; }
    .adm-main { padding: 16px 14px 40px; }
}

/* ---- Pulpit i nagłówki stron ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.page-head h1.h2, .adm-main .page-head h1.h2 { margin: 0; }

.dash-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 18px; }
.dash-action { display: inline-flex; align-items: center; gap: 10px; padding: 11px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 700; font-size: 14.5px; text-decoration: none; box-shadow: var(--shadow); }
.dash-action svg { color: var(--blue); flex: 0 0 auto; }
.dash-action:hover { border-color: var(--blue); background: var(--blue-soft); }
.dash-action--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.dash-action--primary svg { color: #fff; }
.dash-action--primary:hover { background: var(--blue); filter: brightness(1.08); }

.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.dash-kpi { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.dash-kpi:hover { border-color: var(--blue); }
.dash-kpi__num { font-size: 32px; font-weight: 800; line-height: 1.1; }
.dash-kpi__label { font-weight: 700; }
.dash-kpi__hint { color: var(--muted); font-size: 13px; }
.dash-kpi.is-attn { border-color: #F59E0B; background: var(--surface); background: color-mix(in srgb, #F59E0B 8%, var(--surface)); }
.dash-kpi.is-attn .dash-kpi__num { color: #B45309; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-card { padding: 18px 20px; }
.dash-card--wide { grid-column: 1 / -1; }
.dash-card__title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.dash-card__more { font-size: 13px; font-weight: 600; }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list > li { border-top: 1px solid var(--border); }
.dash-list > li:first-child { border-top: 0; }
.dash-list > li > a, .dash-list > li.dash-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; color: inherit; text-decoration: none; }
.dash-list > li > a:hover { background: var(--blue-soft); }
.dash-list__main { display: grid; min-width: 0; line-height: 1.35; }
.dash-list__main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-list__main .help { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-list__side { display: grid; justify-items: end; gap: 2px; flex: 0 0 auto; text-align: right; }
.dash-list > li.is-zero { opacity: .62; }
.dash-list > li.is-empty { padding: 10px 2px; }
.dash-count { min-width: 30px; padding: 2px 9px; border-radius: 999px; background: var(--border); color: var(--muted); font-weight: 800; text-align: center; }
.dash-count.is-on { background: #EF4444; color: #fff; }
.dash-list--status > li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; }
.dash-list--status .dash-list__main { flex: 1 1 auto; }
.dash-list--status .dash-list__main .help { white-space: normal; }
.dash-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: #9CA3AF; }
.dash-dot--ok { background: #22C55E; }
.dash-dot--warn { background: #F59E0B; }
.dash-dot--fail { background: #EF4444; }
.dash-foot { margin: 10px 0 0; }

@media (max-width: 1100px) {
    .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .dash-card--wide { grid-column: auto; }
}
@media (max-width: 520px) {
    .dash-kpis { grid-template-columns: minmax(0, 1fr); }
    .dash-action { flex: 1 1 calc(50% - 10px); justify-content: center; padding: 11px 10px; }
    .dash-list__main strong, .dash-list__main .help { white-space: normal; }
}

/* ===== Zamówienia: statystyki + lista i szczegóły obok siebie ===== */
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.om-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 16px; }
.om-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0; }
a.om-stat:hover { border-color: var(--blue); }
.om-stat.is-active { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }
.om-stat.is-attn { border-color: #d9930d; }
.om-stat__num { font-size: 24px; font-weight: 800; line-height: 1.15; }
.om-stat__num--money { font-size: 17px; }
.om-stat__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.om-stat__hint { font-size: 12px; color: var(--muted); }
.om-search { max-width: 560px; }
.om { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.om__list { min-width: 0; }
.om__pane { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; min-width: 0; padding-right: 2px; }
.om__pane .container, .om__pane .narrow-wide { max-width: none; }
.om__pane .card { margin-bottom: 12px; }
.om__back { display: none; margin-bottom: 10px; font-weight: 600; }
#om-pane-body.is-loading { opacity: .5; transition: opacity .15s; }
.om-row { cursor: pointer; }
.om-row:hover { background: color-mix(in srgb, var(--blue) 6%, transparent); }
.om-row.is-selected { background: color-mix(in srgb, var(--blue) 14%, transparent); }
.om-table td, .om-table th { vertical-align: top; }
.od-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.od-title { margin: 0; font-size: 22px; font-weight: 800; }
.od-head p { margin: 2px 0 0; }
.od-head__actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 960px) {
    .om { grid-template-columns: minmax(0, 1fr); }
    .om__pane { position: static; max-height: none; overflow: visible; }
    .om__pane .om__empty { display: none; }
    .om:not(.has-sel) .om__pane { display: none; }
    .om.has-sel .om__list { display: none; }
    .om__back { display: inline-block; }
}
.om__list .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.om__list .toolbar .search-row { flex-wrap: wrap; max-width: none; margin-bottom: 0; }
.pane-frag .narrow-wide { max-width: none; }
.om__pane form.card { margin-bottom: 12px; }

/* Statystyki odwiedzin */
.visit-num { font-size: 32px; line-height: 1.1; }
.visit-bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding: 6px 0; }
.visit-bars__col { flex: 1 1 0; min-width: 2px; height: 100%; display: flex; align-items: flex-end; }
.visit-bars__bar { display: block; width: 100%; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; }
.visit-bars__col:hover .visit-bars__bar { background: var(--blue-hover); }

/* Użytkownicy (panel admina): na węższym ekranie wiersz układa się w kartę zamiast ściskać trzy kolumny */
@media (max-width: 1500px) {
    .om-table--users thead { display: none; }
    .om-table--users, .om-table--users tbody { display: block; width: 100%; }
    .om-table--users tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; padding: 12px; border-bottom: 1px solid var(--border); }
    .om-table--users td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
    .om-table--users td:nth-child(3) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
    .om-table--users td[colspan] { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
    .om-table--users tr { grid-template-columns: minmax(0, 1fr); }
}

/* Pulpit: przełącznik automatycznego odświeżania w górnym pasku */
.adm-autorefresh { position: relative; }
.adm-autorefresh.is-off { opacity: .6; }
.adm-autorefresh.is-off .adm-autorefresh__off { position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; background: currentColor; transform: rotate(-45deg); border-radius: 2px; }

/* Odwiedziny: przyciski wyboru okresu */
.period-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }

/* Odwiedziny: tabele zawijają tekst zamiast przewijać się w bok */
.table--visits th, .table--visits td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; padding: 10px 8px; }
.table--visits td:nth-child(n+3) { white-space: nowrap; overflow-wrap: normal; }

/* Stan systemu: pasek zajętości dysku */
.meter { height: 8px; margin-top: 6px; border-radius: 999px; background: var(--border); overflow: hidden; max-width: 420px; }
.meter__fill { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.meter__fill.is-warn { background: #F59E0B; }
.meter__fill.is-fail { background: #EF4444; }
