:root {
    --bg: #07080c;
    --panel: rgba(17, 19, 27, 0.94);
    --card: rgba(23, 26, 36, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --gold: #d4a34c;
    --gold-bg: rgba(212, 163, 76, 0.14);
    --text: #f3f4f6;
    --muted: #9ca3af;
    --red: #ef4444;
    --green: #22c55e;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 20%, rgba(185, 28, 28, 0.2), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(212, 163, 76, 0.14), transparent 45%),
        var(--bg);
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* Auth & PIN 2FA */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px 24px;
    text-align: center;
}

.pin-card {
    background: radial-gradient(circle at top, rgba(168, 85, 247, 0.12), rgba(17, 19, 27, 0.96) 65%);
    border-color: rgba(168, 85, 247, 0.25);
}

.lock-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.pin-sub {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 4px 0 12px;
}

.pin-timer {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 18px;
}

.pin-boxes {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.pin-digit {
    height: 52px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 11px;
    color: var(--text);
}

.pin-digit:focus {
    outline: none;
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.22);
}

.btn-link-action {
    margin-top: 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    display: block;
    width: 100%;
}

.btn-link-muted {
    margin-top: 8px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    display: block;
    width: 100%;
}

.auth-card h1 {
    margin: 6px 0 10px;
    font-size: clamp(1.35rem, 4vw, 1.85rem);
    line-height: 1.2;
}

.crest, .crest-sm {
    margin: 0 auto 12px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    background: var(--gold-bg);
    color: var(--gold);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crest { width: 64px; height: 64px; font-size: 1.2rem; }
.crest-sm { width: 52px; height: 52px; font-size: 1rem; }

.auth-desc { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin: 0 0 18px; }

/* Guziki */
.btn-guzik {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 18px;
    margin-top: 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.94rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
}

.btn-guzik:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-discord-guzik {
    background: #5865F2;
    color: #fff;
    box-shadow: 0 8px 20px rgba(88, 101, 242, 0.3);
}

.btn-gold-guzik {
    background: linear-gradient(135deg, #b68432, #e4b866);
    color: #111;
    box-shadow: 0 8px 20px rgba(212, 163, 76, 0.22);
}

.btn-danger-guzik {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    color: #fff;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.btn-secondary-guzik {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border);
    color: var(--text);
}

.btn-sm-guzik {
    width: auto;
    margin-top: 0;
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Layout */
.layout { display: flex; min-height: 100vh; width: 100%; }

.sidebar {
    width: 245px;
    flex-shrink: 0;
    background: rgba(12, 14, 20, 0.96);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sb-top { text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.sb-brand { font-weight: 800; letter-spacing: 1px; font-size: 0.95rem; }
.sb-tag { font-size: 0.65rem; letter-spacing: 1.5px; color: var(--muted); margin-top: 2px; }

.sb-pill {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 700;
}

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); }
.dot.green { background: var(--green); }

.sb-nav { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }

.nav-btn {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.02);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
    transition: 0.15s;
}

.nav-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-btn.active { background: var(--gold-bg); border-color: rgba(212, 163, 76, 0.45); color: #f6d594; }

.sb-bottom { display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.sb-avatar { width: 36px; height: 36px; border-radius: 50%; }
.sb-name { font-size: 0.84rem; font-weight: 700; }
.sb-sub { font-size: 0.72rem; color: var(--muted); }

.content-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    min-height: 54px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 14, 20, 0.8);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

.topbar-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 8px;
}

.topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.nick-pill { font-size: 0.8rem; color: var(--muted); }

.main-container { max-width: 1120px; width: 100%; margin: 22px auto; padding: 0 18px; }

.progress-banner {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.banner-kicker { font-size: 0.68rem; letter-spacing: 1px; color: var(--gold); font-weight: 800; }
.banner-heading { font-weight: 700; font-size: 0.95rem; margin-top: 2px; }

.progress-track { width: 220px; height: 10px; background: #0c0d12; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: linear-gradient(90deg, #b68432, #22c55e); transition: width 0.3s ease; }

.profile-hero {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px 20px 24px;
    text-align: center;
}

.hero-avatar { width: 92px; height: 92px; border-radius: 50%; border: 2px solid rgba(212,163,76,0.65); object-fit: cover; }
.rank-pill { display: inline-block; margin-top: 10px; padding: 3px 11px; border-radius: 999px; background: var(--gold-bg); color: #f6d594; font-size: 0.72rem; font-weight: 700; }
.profile-hero h1 { margin: 10px 0 4px; font-size: clamp(1.4rem, 4vw, 1.9rem); }
.hero-sub { margin: 0 0 22px; color: var(--muted); font-size: 0.88rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kpi-box { background: rgba(11, 13, 19, 0.85); border: 1px solid var(--border); border-radius: 12px; padding: 15px; text-align: left; }
.kpi-label { font-size: 0.68rem; letter-spacing: 1px; color: var(--muted); }
.kpi-num { display: block; margin-top: 6px; font-size: 1.35rem; }

.actions-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.action-tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.12s ease;
}
.action-tile:hover { border-color: rgba(212, 163, 76, 0.55); transform: translateY(-1px); }
.action-tile span { font-size: 1.3rem; }
.action-tile small { display: block; color: var(--muted); font-size: 0.78rem; }

.glass-card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.card-sub { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .kpi-grid, .actions-grid, .two-col { grid-template-columns: 1fr; }
    .progress-banner { flex-direction: column; align-items: stretch; }
    .progress-track { width: 100%; }
}

label { display: block; margin: 14px 0 6px; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    background: #0c0d12;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    margin-bottom: 6px;
}

.preview-img { margin-top: 12px; max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.88rem; }
.empty-td { text-align: center; color: var(--muted); padding: 20px; }

.status-badge { padding: 4px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 700; text-transform: uppercase; }
.status-badge.oczekujące { background: rgba(234,179,8,0.2); color: #fde047; }
.status-badge.zaakceptowane { background: rgba(34,197,94,0.2); color: #86efac; }
.status-badge.odrzucone { background: rgba(239,68,68,0.2); color: #fca5a5; }

.rank-chip { background: var(--gold-bg); color: #f6d594; padding: 3px 8px; border-radius: 6px; font-size: 0.78rem; font-weight: 700; }
.inline-edit { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.btn-sm-gold { background: var(--gold); color: #111; border: none; border-radius: 7px; padding: 8px 12px; font-weight: 700; cursor: pointer; }

.invites-list, .logs-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.invite-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: #0c0d12;
    border: 1px solid var(--border);
    padding: 12px 14px;
    border-radius: 10px;
}
.invite-item.used { opacity: 0.6; }
.inv-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.inv-actions { display: flex; gap: 8px; align-items: center; }
.used-tag { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.btn-del { background: rgba(239,68,68,0.18); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 0.78rem; font-weight: 700; }

.log-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 9px;
    background: #0c0d12;
    border-left: 3px solid #3b82f6;
    font-size: 0.85rem;
}
.log-row.success { border-left-color: var(--green); }
.log-row.danger { border-left-color: var(--red); }
.log-row small { color: var(--muted); flex-shrink: 0; }

/* Taryfikator */
.tariff-layout {
    display: grid;
    grid-template-columns: 1.65fr 0.9fr;
    gap: 18px;
    align-items: start;
}

@media (max-width: 920px) {
    .tariff-layout {
        grid-template-columns: 1fr;
    }
}

.tariff-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tariff-toolbar input {
    flex: 1;
    min-width: 220px;
    margin-bottom: 0;
}

.tariff-toolbar-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tariff-section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}

.tariff-sec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tariff-sec-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sec-code {
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 800;
}

.sec-range {
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
}

.sec-code.s1, .sec-range.s1, .item-code.s1, .item-amount.s1 {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.sec-code.s2, .sec-range.s2, .item-code.s2, .item-amount.s2 {
    background: rgba(234, 179, 8, 0.16);
    color: #facc15;
    border: 1px solid rgba(234, 179, 8, 0.35);
}

.sec-code.s3, .sec-range.s3, .item-code.s3, .item-amount.s3 {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.tariff-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tariff-row {
    background: rgba(11, 13, 19, 0.85);
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 12px 14px;
}

.tariff-row.selected {
    border-color: rgba(212, 163, 76, 0.55);
}

.tariff-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.check-wrap {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    cursor: pointer;
    color: var(--text) !important;
    font-weight: 600;
}

.check-wrap input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: #6366f1;
    cursor: pointer;
}

.item-code {
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 800;
    flex-shrink: 0;
}

.item-amount {
    padding: 3px 9px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 800;
    flex-shrink: 0;
}

.tariff-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.tariff-slider-row small {
    color: var(--muted);
    font-size: 0.74rem;
}

.tariff-slider-row input[type="range"] {
    margin: 0;
    padding: 0;
    accent-color: #6366f1;
    cursor: pointer;
}

.tariff-summary {
    position: sticky;
    top: 20px;
}

.summary-box {
    margin-top: 14px;
    background: rgba(11, 13, 19, 0.85);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.86rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.sum-pill-num {
    background: rgba(255,255,255,0.07);
    color: var(--text);
    padding: 2px 9px;
    border-radius: 999px;
}

.weight-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.t-btn {
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 0.76rem;
    font-weight: 800;
    cursor: pointer;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    transition: 0.15s;
}

.t-btn:hover {
    color: var(--text);
    border-color: rgba(212, 163, 76, 0.45);
}

.t-btn.active {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.6);
    color: #fca5a5;
}

.summary-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

.summary-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 800;
}

.total-gold {
    font-size: 1.35rem;
    color: #818cf8;
}

.summary-code-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: var(--muted);
}

.toast-container { position: fixed; right: 20px; bottom: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: #181b24;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--gold); }
.toast.fade-out { opacity: 0; }