:root {
    --bg: #0c0c0c;
    --surface: #161616;
    --surface-2: #1e1e1e;
    --border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --text-dim: #999999;
    --text-dimmer: #6b6b6b;
    --accent: #cd412b;
    --accent-dim: rgba(205, 65, 43, 0.14);
    --good: #22c55e;
    --bad: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* The same background image as the main site, just for fun - a real fixed
   layer (not background-attachment:fixed, which is broken on iOS Safari)
   sitting behind a near-opaque scrim so it reads as a faint texture rather
   than competing with the actual UI. */
#adminBgLayer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url("/images/background_pripyat_2752x1536.png");
    background-size: cover;
    background-position: center;
}
#adminBgLayer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(12, 12, 12, 0.95);
}

.hidden { display: none !important; }

i[data-lucide] { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }

/* --- Login --- */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 0%, #1a1a1a, var(--bg) 60%);
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
}

.login-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 0.25rem; }

.login-card h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.login-card h1 span { color: var(--accent); }

.field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.field input, .field textarea, .field select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.1rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-block { width: 100%; margin-top: 0.4rem; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.12); color: var(--bad); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-good { background: rgba(34, 197, 94, 0.12); color: var(--good); border: 1px solid rgba(34, 197, 94, 0.3); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

/* Compact square icon-only buttons for table row actions - keeps a row
   with several actions (ban, reset, edit...) from blowing out the row
   height/width the way full text buttons did. */
.icon-actions { display: flex; gap: 0.35rem; flex-wrap: nowrap; }
.icon-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.icon-btn:hover { opacity: 0.8; }
.icon-btn i { width: 15px; height: 15px; }
.icon-btn-danger { color: var(--bad); border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); }
.icon-btn-good { color: var(--good); border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.1); }

.error-text { color: var(--bad); font-size: 0.8rem; text-align: center; margin: 0; }

/* --- App shell --- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.9rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.4rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.sidebar-logo img { width: 30px; height: 30px; object-fit: contain; }
.sidebar-logo span { font-weight: 600; font-size: 0.95rem; }
.sidebar-logo b { color: var(--accent); }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding-top: 0.9rem;
    margin-top: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.sidebar-user { font-size: 0.75rem; color: var(--text-dimmer); padding: 0 0.4rem 0.3rem; }

/* Deliberately its own class instead of reusing .btn-ghost, which is
   sized for inline use (auto width, centered content) - inside the
   sidebar's flex column that stretched it full-width but kept its
   content centered instead of matching the nav items above it,
   which is what actually looked broken. This one mirrors .nav-item
   exactly (same padding/radius/alignment) so it reads as part of the
   same list instead of a mismatched button dropped below it. */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.6rem 0.7rem;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); color: var(--bad); }

.content { flex: 1; padding: 1.75rem 2.25rem; max-width: 1200px; }

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.content-header h1 { font-size: 1.4rem; margin: 0; }

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.9rem;
    font-size: 0.8rem;
}
.toast.success { border-color: rgba(34, 197, 94, 0.4); color: var(--good); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: var(--bad); }

/* --- Shared view building blocks --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card { display: flex; flex-direction: column; gap: 0.35rem; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--text-dimmer); }

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tables can have more columns than a narrow window/sidebar-shrunk
   viewport has room for - scope the scroll to the table itself instead of
   letting it overflow the card and get clipped by the page. */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { text-align: left; color: var(--text-dim); font-weight: 600; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-soft, var(--border)); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-online { background: rgba(34, 197, 94, 0.12); color: var(--good); }
.badge-offline { background: rgba(239, 68, 68, 0.12); color: var(--bad); }
.badge-banned { background: rgba(239, 68, 68, 0.12); color: var(--bad); }

.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }

.player-cell { display: flex; align-items: center; gap: 0.6rem; }
.player-cell .steamid { font-size: 0.7rem; color: var(--text-dimmer); }

.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}
.tab-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.perk-row, .duration-row {
    display: grid;
    gap: 0.5rem;
    align-items: center;
    padding: 0.6rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}
.perk-row { grid-template-columns: auto 1fr 1.4fr 2fr auto; }
.duration-row { grid-template-columns: auto 1fr 1fr auto; }

/* Up/down reorder controls for perks & VIP duration tiers - order matters
   for both (they render in this order on the actual storefront), so
   creating/deleting needed a way to move entries too, not just add/remove
   them at the end. */
.reorder-btns { display: flex; flex-direction: column; gap: 2px; }
.reorder-btns .icon-btn { width: 26px; height: 17px; }
.reorder-btns .icon-btn i { width: 12px; height: 12px; }

.form-row { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.form-row .field { flex: 1; min-width: 200px; }

.empty-state { color: var(--text-dimmer); font-size: 0.85rem; padding: 1.5rem; text-align: center; }

.search-bar { display: flex; gap: 0.6rem; margin-bottom: 1rem; }
.search-bar input { flex: 1; }

/* --- Modal (player stats editor) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
}
.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}
.modal-card h2 { margin: 0; font-size: 1.05rem; }
.modal-hint { font-size: 0.75rem; color: var(--text-dimmer); margin: -0.4rem 0 0; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.2rem; }

/* --- Account manager (Settings view) --- */
.account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.7rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}
.account-row .account-name { font-weight: 600; font-size: 0.85rem; }
.account-row .account-meta { font-size: 0.72rem; color: var(--text-dimmer); }
.account-row .account-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.5rem;
}

@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
    .sidebar-logo { border: none; margin: 0; padding: 0; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { flex-direction: row; align-items: center; border: none; margin-left: auto; }
    .logout-btn { width: auto; }
    .content { padding: 1.25rem; }
    .perk-row { grid-template-columns: auto 1fr; }
    .duration-row { grid-template-columns: auto 1fr 1fr; }
}
