/* ========================================================================
   GPON Manager - Light Theme (Swagger UI inspired)
   ======================================================================== */

:root {
    /* Tła */
    --bg-base:        #fafafa;
    --bg-surface:     #ffffff;
    --bg-surface-2:   #f6f8fa;
    --bg-elev:        #ffffff;
    --bg-input:       #ffffff;

    /* Bordery */
    --border:         #e0e0e0;
    --border-strong:  #c8ccd1;
    --border-focus:   #4990e2;

    /* Tekst (typowe wartości Swagger UI) */
    --text-primary:   #3b4151;
    --text-secondary: #6c757d;
    --text-muted:     #9ca3af;
    --text-inverse:   #ffffff;
    --text-on-accent: #ffffff;

    /* Akcenty - swaggerowy niebieski */
    --accent:         #4990e2;
    --accent-hover:   #6ba4ea;
    --accent-strong:  #3683d6;
    --accent-deep:    #2563eb;
    --accent-bg:      rgba(73,144,226,0.08);

    /* Status */
    --ok:             #22c55e;
    --warn:           #f59e0b;
    --err:            #ef4444;
    --danger:         #ef4444;   /* alias dla --err - używany w wielu miejscach JS/inline */
    --info:           #3b82f6;

    /* Cienie subtelne na jasnym tle */
    --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:      0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:      0 8px 24px rgba(0,0,0,0.12);

    /* Backdrop ciemny przeźroczysty */
    --backdrop:       rgba(15,23,42,0.45);

    /* Subtelny gradient w stylu kart Swagger */
    --bg-gradient-a:  rgba(73,144,226,0.04);
    --bg-gradient-b:  rgba(73,144,226,0.02);

    /* Alerty */
    --alert-err-bg:   #fdecec;
    --alert-err-bd:   #f5c2c2;
    --alert-err-tx:   #b00020;
    --alert-ok-bg:    #e6f5ec;
    --alert-ok-bd:    #b8e0c6;
    --alert-ok-tx:    #1b6b3a;
    --alert-warn-bg:  #fff4e0;
    --alert-warn-bd:  #f0d09a;
    --alert-warn-tx:  #875100;
    --alert-info-bg:  #e7f0fb;
    --alert-info-bd:  #b8d2f0;
    --alert-info-tx:  #1d4d8a;

    /* Krzywizny i odstępy */
    --radius-sm:      4px;
    --radius:         6px;
    --radius-lg:      10px;

    /* Typografia */
    --font-sans:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                      Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:      "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
                      Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtelna tekstura na tle - daje "głębię" jak panele operatorskie */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 20% 0%, var(--bg-gradient-a), transparent 50%),
        radial-gradient(circle at 80% 100%, var(--bg-gradient-b), transparent 50%);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 120ms ease;
}
a:hover { color: var(--accent-hover); }

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

code, pre, .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

/* ========================================================================
   Layout główny
   ======================================================================== */

.app-shell {
    position: relative;
    /* z-index usunięty: nie tworzymy tu stacking contextu, żeby sidebar (dziecko)
       z position:fixed + z-index:1000 mógł nakrywać overlay (dziecko body, z-index:999).
       Stacking context na app-shell powodował, że sidebar był "uwięziony" wewnątrz
       i overlay go zakrywał. */
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
}

.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 10;
    overflow-y: auto;       /* gdy sidebar dłuższy niż viewport */
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 14px;
    border-bottom: 1px solid var(--border);
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-strong), var(--accent-deep));
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-on-accent);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* Wariant z wgranym obrazkiem - białe tło, img wypełnia */
.brand-logo.brand-logo-img {
    background: white;
    padding: 2px;
    overflow: hidden;
}
.brand-logo.brand-logo-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand-name {
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 15px;
}
.brand-name small {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 120ms ease;
    font-weight: 500;
}
.nav-item:hover {
    background: var(--bg-elev);
    color: var(--text-primary);
}
.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent);
}
.nav-item .icon {
    width: 16px;
    text-align: center;
    opacity: 0.9;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.main {
    padding: 28px 32px 48px;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.page-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* ========================================================================
   Logowanie - osobny layout
   ======================================================================== */

.login-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

/* Dwukolumnowy układ: lewo = formularz, prawo = panel informacyjny.
   Na desktopach pełna szerokość ~1100px, na mobile stack pionowy. */
.login-layout {
    width: 100%;
    max-width: 1100px;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 32px;
    align-items: start;
}

/* === Panel informacyjny po prawej === */
.login-info {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 30px;
    box-shadow: var(--shadow-lg);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    position: relative;
    overflow: hidden;
}
.login-info::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.login-info__title {
    margin: 0 0 14px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}
/* Dynamicznie ładowana treść z /api/landing-info - style dla generycznego HTML-a */
.login-info__body p {
    margin: 0 0 14px 0;
    font-size: 14px;
    color: var(--text-secondary);
}
.login-info__body p:last-child {
    margin-bottom: 0;
}
.login-info__body ul,
.login-info__body ol {
    list-style: none;
    padding: 0;
    margin: 0 0 16px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.login-info__body li {
    position: relative;
    padding-left: 22px;
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.55;
}
.login-info__body li::before {
    content: "›";
    position: absolute;
    left: 0;
    top: -1px;
    color: var(--accent);
    font-weight: 700;
    font-size: 18px;
    line-height: 1;
}
.login-info__body strong,
.login-info__body b {
    color: var(--text-primary);
    font-weight: 600;
}
.login-info__body em,
.login-info__body i {
    color: var(--text-muted);
    font-style: italic;
}
.login-info__body a {
    color: var(--accent);
    text-decoration: none;
}
.login-info__body a:hover {
    text-decoration: underline;
}
.login-info__body code {
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

/* Mobile: stack jeden pod drugim, panel info na dole */
@media (max-width: 900px) {
    .login-layout {
        grid-template-columns: 1fr;
        max-width: 480px;
        gap: 20px;
    }
    .login-info {
        padding: 24px 20px;
    }
    .login-info__title {
        font-size: 18px;
    }
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px 28px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

/* Cienki akcent górny - jak na konsolach pro */
.login-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.login-brand .brand-logo {
    width: 48px;
    height: 48px;
    font-size: 18px;
}
.login-brand h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.login-brand p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ========================================================================
   Formularze
   ======================================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.form-control,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 9px 12px;
    transition: all 140ms ease;
    outline: none;
}
.form-control:focus,
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    background: var(--bg-surface-2);
}
.form-section h3 {
    margin: 0 0 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ========================================================================
   Przyciski
   ======================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 500;
    transition: all 140ms ease;
    background: var(--bg-elev);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn:hover:not(:disabled) {
    background: var(--bg-surface-2);
    border-color: var(--accent);
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent-strong);
    color: var(--text-on-accent);
    border-color: var(--accent-strong);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
}
.btn-danger {
    background: transparent;
    color: var(--err);
    border-color: rgba(239,68,68,0.4);
}
.btn-danger:hover:not(:disabled) {
    background: rgba(239,68,68,0.10);
    border-color: var(--err);
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-elev);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px 14px; }

/* ========================================================================
   Tabele
   ======================================================================== */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.card-body { padding: 18px; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.table tbody tr {
    transition: background 100ms ease;
}
.table tbody tr:hover {
    background: var(--bg-surface-2);
}
.table tbody tr:last-child td { border-bottom: none; }
.table .cell-mono { font-family: var(--font-mono); color: var(--text-secondary); }
.table .cell-actions {
    text-align: right;
    white-space: nowrap;
}

/* ========================================================================
   Badges, statusy
   ======================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.badge-vendor {
    text-transform: uppercase;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
}
.badge-ok    { color: var(--ok);    border-color: rgba(34,197,94,0.4);   background: rgba(34,197,94,0.10); }
.badge-warn  { color: var(--warn);  border-color: rgba(245,158,11,0.4);  background: rgba(245,158,11,0.10); }
.badge-err   { color: var(--err);   border-color: rgba(239,68,68,0.4);   background: rgba(239,68,68,0.10); }
.badge-info  { color: var(--accent); border-color: rgba(56,189,248,0.4); background: rgba(56,189,248,0.10); }

.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 0 currentColor;
}
.status-dot.ok    { background: var(--ok);   box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-dot.warn  { background: var(--warn); box-shadow: 0 0 8px rgba(245,158,11,0.5); }
.status-dot.err   { background: var(--err);  box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ========================================================================
   Modal
   ======================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ========================================================================
   Alerty / toast
   ======================================================================== */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-err  { background: var(--alert-err-bg);  border-color: var(--alert-err-bd);  color: var(--alert-err-tx); }
.alert-ok   { background: var(--alert-ok-bg);   border-color: var(--alert-ok-bd);   color: var(--alert-ok-tx); }
.alert-warn { background: var(--alert-warn-bg); border-color: var(--alert-warn-bd); color: var(--alert-warn-tx); }
.alert-info { background: var(--alert-info-bg); border-color: var(--alert-info-bd); color: var(--alert-info-tx); }

/* ========================================================================
   Karty statystyk (dashboard / detail)
   ======================================================================== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: "";
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    opacity: 0.6;
}
.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.stat-value {
    font-size: 26px;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}
.stat-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========================================================================
   Loader
   ======================================================================== */

.loader {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
    background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-surface-2) 50%, var(--bg-elev) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s linear infinite;
    border-radius: var(--radius-sm);
    color: transparent;
}
@keyframes skeleton {
    to { background-position: -200% 0; }
}

/* ========================================================================
   Pomocnicze
   ======================================================================== */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.toolbar .grow { flex: 1; }
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 32px; opacity: 0.5; margin-bottom: 10px; }

.breadcrumbs {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs .sep { margin: 0 6px; opacity: 0.6; }

.tag {
    display: inline-block;
    padding: 2px 7px;
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-right: 4px;
}

/* ========================================================================
   Zakładki (tabs) — używane na karcie "Profile i konfiguracja"
   ======================================================================== */

.tabs-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 8px 14px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: background 100ms, color 100ms;
    white-space: nowrap;
    margin-bottom: -1px;
}

.tab-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-surface);
    border-color: var(--border);
    border-bottom: 1px solid var(--bg-surface);
    color: var(--accent);
    font-weight: 600;
}

.tab-panel { display: block; }
.tab-panel.hidden { display: none; }

/* Karta z collapsable header - uniwersalny mechanizm */
.card-header-collapsible {
    cursor: pointer;
    user-select: none;
}
.card-header-collapsible:hover h2 { color: var(--accent); }
.card-header-collapsible .collapse-icon {
    display: inline-block;
    width: 14px;
    transition: transform 150ms;
    color: var(--text-muted);
    font-size: 12px;
    margin-right: 4px;
}

/* Po collapse - ukryj wszystko poza headerem */
.card.collapsed > .card-body,
.card.collapsed > div:not(.card-header):not(.card-header-collapsible) {
    display: none;
}
.card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* ========================================================================
   Responsive — breakpointy: tablet (≤1024px), mobile (≤768px), small (≤480px)
   ======================================================================== */

/* Hamburger button - widoczny tylko na mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;        /* wyższy niż wszystko - musi być klikalny */
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    line-height: 1;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;   /* eliminuje 300ms delay na mobile */
    user-select: none;
    transition: left 200ms ease;  /* płynnie podąża za sidebar */
}
.sidebar-toggle:active {
    background: var(--bg-input);
    transform: scale(0.95);
}

/* Gdy sidebar otwarty - hamburger znika (close jest wewnątrz menu) */
body.sidebar-open .sidebar-toggle {
    display: none;
}

/* Close button wewnątrz sidebar - widoczny tylko gdy sidebar w trybie off-canvas */
.sidebar-close {
    display: none;       /* domyślnie ukryty (desktop nie potrzebuje) */
    margin-left: auto;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 36px; height: 36px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-primary);
    line-height: 1;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}
.sidebar-close:active {
    background: var(--bg-input);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}
.sidebar-overlay.open { display: block; }

/* Wszystkie tabele scrollable horizontally w wąskim viewport */
.card-body {
    overflow-x: auto;
}

/* Tablet (≤1024px) - mniej paddingu w main */
@media (max-width: 1024px) {
    .main { padding: 22px 20px 36px; }
    .app-shell { grid-template-columns: 200px 1fr; }
}

/* Mobile (≤768px) - sidebar off-canvas, single column, compact UI */
@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar-toggle { display: block; }
    .sidebar-close { display: flex; align-items: center; justify-content: center; }   /* widoczny tylko na mobile */

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        z-index: 1000;          /* tuż pod hamburger (1001), nad overlay (999) */
        transform: translateX(-100%);
        transition: transform 200ms ease;
        flex-direction: column;
        padding: 16px;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-footer { display: flex; }  /* Pokazuj footer na off-canvas */

    .nav { flex-direction: column; flex: initial; }

    .main {
        padding: 56px 14px 28px;   /* +56px góra dla hamburger */
        max-width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .page-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }

    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    .card-header h2 { font-size: 15px; }
    .card-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }

    /* Tabele - scroll w kontenerze; cells mniejsze padding */
    .table { font-size: 12px; min-width: 600px; }
    .table th, .table td { padding: 8px 8px; }

    .table-wrapper, .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modale - prawie pełen ekran */
    .modal-backdrop { padding: 8px; }
    .modal { max-width: 100%; max-height: 96vh; }
    .modal-body { padding: 14px; }
    .modal-header { padding: 12px 14px; }
    .modal-footer { padding: 10px 14px; flex-wrap: wrap; }

    /* Formularze - kolumna */
    .form-row { grid-template-columns: 1fr !important; gap: 10px !important; }

    /* Inline grids w modal autoryzacji ONT - dwukolumnowe na mobile */
    .modal-body div[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* Specjalne - modal-body w fieldset z 5 polami: jeden wiersz na mobile */
    .modal-body fieldset > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Profile VLAN tabela / formularz - kolumny  */
    #vlanProfilesContent fieldset > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
    }
    #vlanProfilesContent #iptvFieldsRow div[style*="grid-template-columns"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Filtry, page actions - flex wrap */
    .filters, .page-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .filters > * { flex: 1 1 auto; }

    /* Login - pełna szerokość */
    .login-shell { padding: 12px; }
    .login-card { max-width: 100%; padding: 24px 18px; }

    /* Buttony - większy tap target */
    .btn { min-height: 36px; padding: 8px 14px; }
    .btn-sm { min-height: 30px; padding: 5px 10px; }

    /* Ukryj sidebar-footer wersja overlay (pokazujemy go w środku sidebar) */
}

/* Small mobile (≤480px) - jeszcze ciaśniej */
@media (max-width: 480px) {
    .main { padding: 56px 10px 24px; }
    .card-body { padding: 12px; }
    .card-header { padding: 12px 14px; }
    .card-header h2 { font-size: 14px; }

    /* Audit table - ukryj kolumnę szczegółów na bardzo małym */
    table.table .audit-details-col { display: none; }

    /* Modal autoryzacji - inline grid 4-kolumnowy → 1 kolumna */
    .modal-body div[style*="grid-template-columns: 1fr 1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* Print-friendly (bonus) */
@media print {
    .sidebar, .sidebar-toggle, .sidebar-overlay, .modal-backdrop { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    .main { padding: 0; max-width: 100%; }
}


/* ========================================================================
   Editor (WYSIWYG dla strony logowania)
   ======================================================================== */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}
.editor-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.editor-btn:hover {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-primary);
}
.editor-btn:active {
    background: var(--accent);
    color: white;
}
.editor-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}
.editor-area {
    min-height: 240px;
    max-height: 500px;
    overflow-y: auto;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}
.editor-area:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}
.editor-area p { margin: 0 0 10px 0; }
.editor-area ul, .editor-area ol { margin: 0 0 10px 20px; padding-left: 18px; }
.editor-area li { margin-bottom: 4px; }
.editor-area h3 { font-size: 16px; margin: 12px 0 8px 0; }
.editor-area strong { font-weight: 600; }
.editor-area em { font-style: italic; }
.editor-source {
    width: 100%;
    min-height: 240px;
    max-height: 500px;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    resize: vertical;
    outline: none;
}
.editor-source:focus {
    border-color: var(--accent);
}
