:root {
    --bg: #0a0a0a;
    --panel: #121212;
    --panel-2: #1a1a1a;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --gold: #fbbf24;
    --accent: #b91c1c;
    --accent-soft: rgba(185, 28, 28, 0.18);
    --silver: #cbd5e1;
    --success: #22c55e;
    --danger: #ef4444;
    --border: rgba(148, 163, 184, 0.18);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(180deg, #0a0a0a 0%, #111111 100%);
    color: var(--text);
}

a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: rgba(8, 8, 8, 0.98);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand h1 {
    margin: 0.35rem 0 0;
    font-size: 1.6rem;
}

.brand p, .brand.compact p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.brand-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: #fecaca;
    font-size: 0.75rem;
}

.clan-logo {
    display: block;
    width: 88px;
    height: 88px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.sidebar-logo {
    width: 72px;
    height: 72px;
}

.auth-logo {
    width: 96px;
    height: 96px;
    margin: 0 auto 0.75rem;
}

.auth-brand {
    text-align: center;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav a {
    color: var(--text);
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    text-decoration: none;
}

.nav a.active, .nav a:hover,
.nav-modal-trigger.active, .nav-modal-trigger:hover {
    background: var(--accent-soft);
}

.nav-modal-trigger {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-chip {
    padding: 0.55rem 0.75rem;
    background: var(--panel);
    border-radius: 8px;
    font-size: 0.9rem;
}

.user-chip small {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.logout-link { color: #fca5a5; }

.content-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: -0.25rem 0 1rem;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 2px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), #991b1b);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    text-transform: uppercase;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 40;
    min-width: 220px;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.user-menu-head {
    padding: 0.65rem 0.75rem 0.55rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.user-menu-head strong {
    display: block;
    font-size: 0.95rem;
}

.user-menu-head small {
    display: block;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.78rem;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: var(--accent-soft);
    outline: none;
}

.user-menu-item-danger {
    color: #fca5a5;
}

.user-menu-logout {
    margin: 0;
}

.public-header-actions .user-menu {
    margin-left: 0.25rem;
}

.movement-party-block.hidden,
.movement-party-block[hidden] {
    display: none !important;
}

.content {
    padding: 1.5rem;
}

.page-header h2 {
    margin: 0 0 0.35rem;
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

.stats-grid, .grid-2, .info-grid {
    display: grid;
    gap: 1rem;
}

.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 1.5rem 0; }
.stats-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.charts-section .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.charts-grid { margin-bottom: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1rem; }

.stat-card, .panel, .info-grid article {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem;
}

.stat-label, .info-grid span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.stat-value {
    display: block;
    margin-top: 0.45rem;
    font-size: 1.8rem;
}

.stat-value.gold, .gold { color: var(--gold); }

.panel { margin-bottom: 1rem; }
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-head h3 { margin: 0; }

.form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.92rem;
}

input, select, textarea, button {
    font: inherit;
}

input, select, textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
}

textarea { resize: vertical; }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: #334155;
    color: white;
}

.btn-primary {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

.btn-danger {
    background: #991b1b;
    color: #fff;
}

.btn-danger:hover {
    background: #7f1d1d;
}

.stat-link {
    display: inline-block;
    margin-top: 0.55rem;
    color: #fca5a5;
    font-size: 0.95rem;
}

.btn-small {
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
}

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 0.55rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.empty { color: var(--muted); text-align: center; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
}

.badge-in { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.badge-out { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.badge-waiting { background: rgba(251, 191, 36, 0.18); color: #fde68a; }
.badge-completed { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.badge-cancelled { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }

.rank-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(148, 163, 184, 0.15);
    color: #e2e8f0;
}

.rank-marechal { background: rgba(185, 28, 28, 0.25); color: #fecaca; }
.rank-general { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
.rank-major { background: rgba(234, 88, 12, 0.2); color: #fdba74; }
.rank-capitao { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.rank-soldado { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.queue-list {
    display: grid;
    gap: 0.75rem;
}

.queue-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    padding: 0.85rem;
    background: var(--panel-2);
    border-radius: 12px;
}

.queue-position {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gold);
    min-width: 2rem;
}

.queue-player {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.queue-reward {
    margin-top: 0.35rem;
}

.queue-date {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.alert-success { background: rgba(34, 197, 94, 0.15); color: #bbf7d0; }
.alert-error { background: rgba(239, 68, 68, 0.15); color: #fecaca; }
.alert-info { background: rgba(59, 130, 246, 0.12); color: #bfdbfe; }

.stock-grid {
    display: grid;
    gap: 0.75rem;
}

.stock-card, .item-inline, .selected-item {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.stock-card, .selected-item {
    padding: 0.75rem;
    background: var(--panel-2);
    border-radius: 12px;
}

.stock-card img, .item-inline img, .selected-item img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #0f172a;
}

.stock-card strong, .selected-item strong { display: block; }
.stock-card span, .stock-card em, .selected-item span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.search-results {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.search-item {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    padding: 0.55rem;
    background: var(--panel-2);
    border-radius: 10px;
    cursor: pointer;
}

.search-item:hover { background: #1e293b; }
.search-item img { width: 36px; height: 36px; border-radius: 8px; }

.player-register-offer {
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-radius: 12px;
    background: var(--panel-2);
    border: 1px dashed var(--border);
    display: grid;
    gap: 0.65rem;
}

.player-register-offer p {
    margin: 0;
    font-size: 0.92rem;
}

.player-register-offer label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.92rem;
}

.form label small, .form-help, .muted-label {
    color: var(--muted);
    font-size: 0.82rem;
}

.form-row-inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 0.75rem;
    align-items: end;
}

.form-row-inline label {
    margin-bottom: 0;
}

.form-row-inline__id input {
    width: 100%;
}

.form-help {
    margin-top: 0.75rem;
}

.hidden { display: none; }

.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.logout-form {
    margin: 0;
}

.logout-form .logout-link {
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.85rem;
    align-items: end;
    margin-bottom: 1rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.pagination-info {
    color: var(--muted);
    font-size: 0.9rem;
}

.actions-cell {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.inline-form {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(100%, 420px);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.5rem;
}

.auth-card.wide { width: min(100%, 520px); }

.auth-footer-link {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.9rem;
}

.public-body {
    min-height: 100vh;
    background: #000;
}

html[data-theme="light"] .public-body {
    background: #f1f5f9;
}

html[data-theme="light"] {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(15, 23, 42, 0.12);
    --accent-soft: rgba(185, 28, 28, 0.12);
}

html[data-theme="light"] .public-header {
    background: rgba(255, 255, 255, 0.96);
    border-bottom-color: rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] .public-nav-link.active,
html[data-theme="light"] .public-nav-link:hover {
    background: rgba(185, 28, 28, 0.1);
}

html[data-theme="light"] .public-nav {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .brand-badge {
    color: #991b1b;
}

html[data-theme="light"] a {
    color: #b91c1c;
}

html[data-theme="light"] .queue-card-sidebar,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .panel {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.public-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 8, 8, 0.98);
    position: sticky;
    top: 0;
    z-index: 20;
}

.public-header-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.public-header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.public-header-tools .theme-toggle,
.public-header-tools .user-menu-trigger {
    width: 40px;
    height: 40px;
}

.theme-toggle {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--panel-2);
}

.theme-icon {
    width: 20px;
    height: 20px;
}

html:not([data-theme="light"]) .theme-icon-sun,
html[data-theme="light"] .theme-icon-moon {
    display: none;
}

.public-shell {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 1.25rem;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 0;
    align-items: start;
}

.public-sidebar {
    position: sticky;
    top: 6.5rem;
    max-height: calc(100vh - 7.5rem);
    overflow: auto;
    scrollbar-width: thin;
}

.public-main {
    min-width: 0;
}

.queue-sidebar-panel {
    margin-bottom: 0;
}

.queue-list-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.queue-card-sidebar {
    display: block;
    padding: 0.75rem;
}

.queue-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.queue-card-sidebar .queue-position {
    font-size: 1rem;
    min-width: auto;
}

.queue-card-sidebar .queue-date {
    font-size: 0.78rem;
}

.queue-card-sidebar .queue-player {
    margin-bottom: 0.35rem;
}

.queue-card-sidebar .queue-reward {
    margin-top: 0;
    font-size: 0.92rem;
}

.queue-note {
    display: block;
    margin-top: 0.35rem;
}

.public-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.public-brand .clan-logo {
    width: 72px;
    height: 72px;
    margin: 0;
}

.public-brand h1 {
    margin: 0.25rem 0 0;
}

.public-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}

.public-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 1rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.public-nav-link:hover,
.public-nav-link.active {
    background: var(--accent-soft);
    color: var(--text);
}

.public-nav-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.public-shell-full {
    grid-template-columns: minmax(0, 1fr);
    max-width: 1200px;
}

body.queue-modal-open {
    overflow: hidden;
}

.queue-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.queue-modal[hidden] {
    display: none;
}

.queue-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(16px) saturate(1.35);
    -webkit-backdrop-filter: blur(16px) saturate(1.35);
}

.queue-modal-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(720px, 100%);
    max-height: min(85vh, 860px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    background: rgba(30, 41, 59, 0.72);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.queue-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.25rem 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.queue-modal-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.queue-modal-subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.queue-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}

.queue-modal-close svg {
    width: 1.15rem;
    height: 1.15rem;
}

.queue-modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.queue-modal-body {
    padding: 1rem 1.25rem;
    overflow: auto;
}

.queue-modal-footer {
    padding: 0.85rem 1.25rem 1.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.queue-list-modal {
    display: grid;
    gap: 0.75rem;
}

.queue-card-modal {
    display: block;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .queue-modal-backdrop {
    background: rgba(248, 250, 252, 0.55);
}

html[data-theme="light"] .queue-modal-dialog {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow:
        0 24px 80px rgba(15, 23, 42, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

html[data-theme="light"] .queue-card-modal {
    background: rgba(241, 245, 249, 0.88);
    border-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .queue-modal-close {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.08);
}

.public-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    max-width: 1440px;
    margin: 0 auto;
}

@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .stats-grid, .grid-2, .info-grid, .stats-grid-4, .charts-section .stats-grid, .filter-bar { grid-template-columns: 1fr; }
    .public-header { flex-direction: column; align-items: stretch; gap: 1rem; }
    .public-header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .public-nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .public-header-tools {
        width: 100%;
        justify-content: center;
    }
    .public-shell {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    .public-sidebar {
        position: static;
        max-height: none;
        order: -1;
    }
}
