* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #0f172a;
    color: #e5e7eb;
    font-family: Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 250px;
    background: #020617;
    border-right: 1px solid #1e293b;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.brand {
    font-size: 22px;
    font-weight: 800;
}

.user {
    color: #94a3b8;
    font-size: 14px;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

nav a,
.logout,
.lang a,
.btn-small,
button {
    background: #1e293b;
    border: 1px solid #334155;
    color: #e5e7eb;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
}

nav a:hover,
.logout:hover,
.lang a:hover,
.btn-small:hover,
button:hover {
    background: #334155;
}

.lang {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.logout {
    text-align: center;
}

.content {
    flex: 1;
    padding: 28px;
}

.login-content {
    width: 100%;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card,
.card {
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.login-card {
    width: 360px;
}

.login-lang {
    margin-bottom: 15px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    margin: 0 0 15px 0;
}

.stat-card {
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 18px;
    padding: 15px 24px;
}

.stat-card span {
    color: #94a3b8;
    display: block;
}

.stat-card strong {
    font-size: 32px;
}

.filters {
    margin-bottom: 18px;
    display: flex;
    gap: 12px;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}

th {
    color: #94a3b8;
    font-weight: 600;
}

td small {
    display: block;
    color: #94a3b8;
    margin-top: 4px;
}

label {
    display: block;
    margin-top: 14px;
    margin-bottom: 7px;
    color: #cbd5e1;
}

input,
select,
textarea {
    width: 100%;
    background: #020617;
    color: #e5e7eb;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
}

textarea {
    resize: vertical;
}

button {
    margin-top: 16px;
    width: auto;
}

.alert {
    background: #7f1d1d;
    border: 1px solid #ef4444;
    color: #fee2e2;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 15px;
}

.form-card {
    max-width: 850px;
}

.hidden {
    display: none;
}

.autocomplete-box {
    position: relative;
    display: flex;
    gap: 8px;
}

.autocomplete-box input {
    flex: 1;
}

.suggestions {
    position: absolute;
    top: 46px;
    left: 0;
    right: 110px;
    background: #020617;
    border: 1px solid #334155;
    border-radius: 12px;
    z-index: 50;
    overflow: hidden;
    display: none;
}

.suggestions div {
    padding: 10px;
    cursor: pointer;
}

.suggestions div:hover {
    background: #1e293b;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tag {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 8px 10px;
    border-radius: 999px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.tag button {
    margin: 0;
    padding: 0 6px;
    border-radius: 50%;
    background: #7f1d1d;
}

.percent-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bar {
    width: 160px;
    height: 10px;
    background: #020617;
    border-radius: 999px;
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    background: #22c55e;
}

.screen-preview {
    max-width: 420px;
    max-height: 260px;
    border-radius: 14px;
    border: 1px solid #334155;
    display: block;
}

.meta {
    display: grid;
    gap: 6px;
    color: #cbd5e1;
    background: #020617;
    border: 1px solid #1e293b;
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 16px;
}

@media (max-width: 800px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    table {
        font-size: 13px;
    }
}


.history-card {
    margin-top: 22px;
}

.history-card h2 {
    margin-top: 0;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    background: #020617;
    border: 1px solid #1e293b;
    border-radius: 14px;
    padding: 14px;
}

.history-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #e5e7eb;
}

.history-head span {
    color: #94a3b8;
    font-size: 13px;
}

.history-type {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #1e293b;
    color: #cbd5e1;
    font-size: 12px;
}

.history-item pre {
    white-space: pre-wrap;
    margin: 10px 0 0 0;
    color: #cbd5e1;
    font-family: Arial, sans-serif;
    line-height: 1.45;
}


.freeze-form {
    margin: 0;
}

.switch {
    margin: 0;
    display: inline-block;
    position: relative;
    width: 46px;
    height: 24px;
}

.switch input {
    display: none;
}

.switch span {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #334155;
    border-radius: 999px;
    transition: .2s;
    border: 1px solid #475569;
}

.switch span:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 2px;
    background: #e5e7eb;
    border-radius: 50%;
    transition: .2s;
}

.switch input:checked + span {
    background: #2563eb;
    border-color: #3b82f6;
}

.switch input:checked + span:before {
    transform: translateX(21px);
}

.frozen-row {
    background: rgba(37, 99, 235, 0.08);
}

.badge-freeze {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #1d4ed8;
    color: #dbeafe;
    font-size: 12px;
}

.freeze-tag {
    background: #1d4ed8;
    border-color: #3b82f6;
}

td small {
    display: block;
    color: #94a3b8;
    margin-top: 4px;
}


.filters > div {
    min-width: 220px;
}

.filters label {
    margin-top: 0;
}


.player-link {
    color: #dbeafe;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.player-link:hover {
    color: #93c5fd;
}

.player-subline {
    color: #94a3b8;
    margin-top: 6px;
}

.badge-ok {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #14532d;
    color: #dcfce7;
    font-size: 12px;
}

.player-events-card {
    margin-top: 22px;
}


.bar.percent-red span {
    background: #ef4444;
}

.bar.percent-yellow span {
    background: #f59e0b;
}

.bar.percent-green span {
    background: #22c55e;
}

.compact-percent {
    min-width: 150px;
}

.compact-percent .bar {
    width: 110px;
}

table th,
table td {
    vertical-align: middle;
}


/* Dashboard compact activity columns */
.dashboard-percent {
    min-width: 210px;
}

.dashboard-percent .bar {
    width: 160px;
}

/* Strong color overrides for activity bars */
.bar.percent-red span,
.percent-line .bar.percent-red span {
    background: #ef4444 !important;
}

.bar.percent-yellow span,
.percent-line .bar.percent-yellow span {
    background: #f59e0b !important;
}

.bar.percent-green span,
.percent-line .bar.percent-green span {
    background: #22c55e !important;
}

table th,
table td {
    vertical-align: middle;
}


.column-toggle-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mini-switch {
    margin: 0;
    display: inline-block;
    position: relative;
    width: 34px;
    height: 18px;
    flex: 0 0 auto;
}

.mini-switch input {
    display: none;
}

.mini-switch span {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #334155;
    border-radius: 999px;
    transition: .2s;
    border: 1px solid #475569;
}

.mini-switch span:before {
    content: "";
    position: absolute;
    height: 12px;
    width: 12px;
    left: 2px;
    top: 2px;
    background: #e5e7eb;
    border-radius: 50%;
    transition: .2s;
}

.mini-switch input:checked + span {
    background: #2563eb;
    border-color: #3b82f6;
}

.mini-switch input:checked + span:before {
    transform: translateX(16px);
}

.column-hidden {
    display: none !important;
}

.dashboard-percent {
    min-width: 210px;
}

.dashboard-percent .bar {
    width: 160px;
}

/* fallback; inline style in template has priority */
.bar span[style*="#ef4444"] {
    background: #ef4444 !important;
}

.bar span[style*="#f59e0b"] {
    background: #f59e0b !important;
}

.bar span[style*="#22c55e"] {
    background: #22c55e !important;
}


.dashboard-column-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 16px 0;
    color: #cbd5e1;
}

.column-toggle-control {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 999px;
    padding: 8px 10px;
    color: #e5e7eb;
}


.screens-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.screens-grid .screen-preview {
    max-width: 220px;
    max-height: 160px;
    object-fit: cover;
}


.breakdown-card {
    padding: 0;
    overflow: hidden;
}

.breakdown-scroll {
    overflow-x: auto;
    padding: 18px;
}

.breakdown-table {
    min-width: 1180px;
}

.breakdown-table th {
    text-align: center;
    white-space: nowrap;
}

.breakdown-table td {
    text-align: center;
    white-space: nowrap;
}

.breakdown-name {
    text-align: left !important;
    position: sticky;
    left: 0;
    background: #111827;
    z-index: 2;
}

.breakdown-table th:first-child {
    position: sticky;
    left: 0;
    background: #111827;
    z-index: 3;
}

.breakdown-cell {
    display: grid;
    gap: 4px;
    justify-items: center;
}

.breakdown-cell small {
    color: #94a3b8;
}

.breakdown-total {
    background: rgba(37, 99, 235, 0.08);
}

.percent-red {
    color: #ef4444;
}

.percent-yellow {
    color: #f59e0b;
}

.percent-green {
    color: #22c55e;
}


/* Breakdown player filter */
.breakdown-filter-form {
    align-items: flex-start;
}

.player-filter-box {
    min-width: 360px;
    max-width: 760px;
}

.player-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.player-filter-actions input[type="text"] {
    min-width: 240px;
}

.player-check-list {
    max-height: 230px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    padding: 10px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 14px;
}

.player-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 9px;
    border-radius: 10px;
    color: #e5e7eb;
    background: rgba(30, 41, 59, 0.55);
}

.player-check-item input {
    accent-color: #2563eb;
}

.breakdown-table th:first-child,
.breakdown-name {
    position: sticky;
    left: 0;
    background: #111827;
    z-index: 5;
}

.group-header {
    text-align: center !important;
    background: #0f1d35 !important;
    color: #dbeafe;
}

.breakdown-total,
.breakdown-total-head {
    background: rgba(14, 165, 233, 0.16) !important;
}

.breakdown-grand-total {
    background: rgba(34, 197, 94, 0.14) !important;
}

.total-pop b {
    font-size: 18px;
    text-shadow: 0 0 10px rgba(255,255,255,.12);
}

/* Player management */
.player-management-card {
    margin-top: 20px;
}

.player-add-row,
.player-row-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.player-row-form input {
    min-width: 220px;
}

.danger-button {
    background: #991b1b !important;
}

.muted-text {
    color: #94a3b8;
}


/* Breakdown sticky header fix */
.breakdown-table {
    border-collapse: separate;
    border-spacing: 0;
}

.breakdown-table thead tr:first-child th {
    position: sticky;
    top: 0;
    z-index: 8;
    background: #111827;
}

.breakdown-table thead tr:nth-child(2) th {
    position: sticky;
    top: 48px;
    z-index: 8;
    background: #111827;
}

.breakdown-table thead tr:first-child th.group-header,
.breakdown-table thead tr:first-child th.breakdown-total-head {
    z-index: 9;
}

.breakdown-table th[rowspan="2"] {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #111827;
}

.breakdown-table th:first-child,
.breakdown-name {
    position: sticky;
    left: 0;
    background: #111827;
}

.breakdown-table thead tr:first-child th:first-child {
    z-index: 12;
}

.breakdown-table thead tr:nth-child(2) th:first-child {
    z-index: 12;
}

.breakdown-name {
    z-index: 5;
}

.breakdown-scroll {
    max-height: 78vh;
    overflow: auto;
}



.discord-login-button {
    display: block;
    text-align: center;
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #5865F2;
    color: white;
    font-weight: 700;
    text-decoration: none;
}

.discord-login-button:hover {
    filter: brightness(1.08);
}



/* FINAL Breakdown header + filter fix */
.breakdown-scroll {
    max-height: 78vh !important;
    overflow: auto !important;
    position: relative !important;
}

.breakdown-table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.breakdown-table thead,
.breakdown-table thead tr,
.breakdown-table thead th {
    opacity: 1 !important;
}

.breakdown-table thead th {
    background-color: #101827 !important;
    background-image: none !important;
    opacity: 1 !important;
    box-shadow: 0 1px 0 #263244, 0 8px 12px rgba(0,0,0,.35) !important;
}

.breakdown-table thead tr:first-child th {
    position: sticky !important;
    top: 0 !important;
    z-index: 80 !important;
}

.breakdown-table thead tr:nth-child(2) th {
    position: sticky !important;
    top: 56px !important;
    z-index: 79 !important;
}

.breakdown-table thead th.group-header {
    background-color: #102139 !important;
    background-image: none !important;
    opacity: 1 !important;
    text-align: center !important;
}

.breakdown-table thead th.breakdown-total-head,
.breakdown-table thead tr:first-child th.breakdown-total-head,
.breakdown-table thead tr:nth-child(2) th.breakdown-total-head {
    background-color: #0b3a57 !important;
    background-image: none !important;
    opacity: 1 !important;
    color: #dbeafe !important;
    z-index: 90 !important;
}

.breakdown-table thead th:first-child {
    background-color: #101827 !important;
    z-index: 100 !important;
}

.breakdown-table th:first-child,
.breakdown-name {
    position: sticky !important;
    left: 0 !important;
    background-color: #101827 !important;
    background-image: none !important;
    opacity: 1 !important;
}

.breakdown-name {
    z-index: 30 !important;
}

.player-filter-title {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 8px !important;
}

.player-filter-title label {
    margin: 0 !important;
}

.player-filter-body.is-collapsed,
.player-filter-body.collapsed {
    display: none !important;
}



.access-add-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 180px auto;
    gap: 12px;
    align-items: end;
}

.inline-form {
    display: inline;
}

.badge-admin,
.badge-active,
.badge-inactive {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-admin {
    background: rgba(168, 85, 247, .2);
    color: #d8b4fe;
}

.badge-active {
    background: rgba(34, 197, 94, .16);
    color: #86efac;
}

.badge-inactive {
    background: rgba(239, 68, 68, .16);
    color: #fca5a5;
}

@media (max-width: 800px) {
    .access-add-form {
        grid-template-columns: 1fr;
    }
}


.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.btn-secondary {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 12px;
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: #273449;
}

@media (max-width: 700px) {
    .page-header-row {
        align-items: flex-start;
        flex-direction: column;
    }
}



.password-login-details {
    margin-top: 14px;
    border: 1px solid #253449;
    border-radius: 14px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, .55);
}

.password-login-details summary {
    cursor: pointer;
    color: #93c5fd;
    font-weight: 700;
    user-select: none;
}

.password-login-details[open] summary {
    margin-bottom: 12px;
}

.login-hint {
    display: none !important;
}



.btn-danger {
    background: rgba(239, 68, 68, .18) !important;
    border-color: rgba(239, 68, 68, .45) !important;
    color: #fecaca !important;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, .28) !important;
}


.archive-reset-form {
    display: grid;
    gap: 12px;
}

.alert-error {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, .45);
    background: rgba(239, 68, 68, .16);
    color: #fecaca;
    font-weight: 700;
}


.form-row {
    display: grid;
    gap: 6px;
}

.form-row label {
    display: block;
    font-weight: 800;
    color: #bfdbfe;
}

.archive-reset-card h2,
.archive-list-card h2 {
    margin-top: 0;
}

.reset-button {
    margin-top: 8px;
}

.block-note {
    display: block;
    margin-top: 4px;
}
