/*
  PortalHub — Dark, refined aesthetic
  
  Design system:
  - Near-black backgrounds with subtle warmth
  - Accent: muted teal/cyan
  - Clean sans-serif typography, generous spacing
  - Cards with subtle shadows for depth
  - Role-colored badges
*/

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400&display=swap');

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-input: #1c1c28;
    --border-subtle: #2a2a3a;
    --border-focus: #3d8b8b;
    --text-primary: #e4e4ec;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --accent: #4db8a4;
    --accent-hover: #5ccfb8;
    --accent-glow: rgba(77, 184, 164, 0.15);
    --error: #e05555;
    --success: #4db86a;
    --warning: #c9a84c;
    --info: #5588bb;
    --radius: 8px;
    --transition: 0.2s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(
        ellipse at 50% 0%,
        #14141f 0%,
        var(--bg-primary) 70%
    );
}

/* ---------- Auth Container ---------- */
.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 2rem 1.5rem;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 2.5rem 2rem;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.4),
        0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ---------- Logo / Brand ---------- */
.brand {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-name {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.brand-name span {
    color: var(--accent);
}

.brand-tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Form ---------- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.form-group input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    margin-top: 0.4rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.btn-subtle {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-subtle:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid rgba(224, 85, 85, 0.3);
}

.btn-danger:hover {
    background: rgba(224, 85, 85, 0.1);
    border-color: var(--error);
}

/* ---------- Flash Messages ---------- */
.flash-messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    border-left: 3px solid;
}

.flash-error {
    background: rgba(224, 85, 85, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.flash-success {
    background: rgba(77, 184, 106, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.flash-warning {
    background: rgba(201, 168, 76, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

.flash-info {
    background: rgba(85, 136, 187, 0.1);
    border-color: var(--info);
    color: var(--info);
}

/* ---------- Auth Footer ---------- */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.auth-footer a:hover {
    color: var(--accent-hover);
}

/* ---------- Navigation Bar ---------- */
.dashboard-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
}

.nav-brand {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-brand span {
    color: var(--accent);
}

.nav-badge {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warning) !important;
    border: 1px solid rgba(201, 168, 76, 0.3);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.nav-user {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.nav-link {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.nav-link:hover {
    color: var(--accent);
}

.btn-logout {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.btn-logout:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ---------- Role Badges ---------- */
.role-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.role-owner {
    color: #f0c040;
    background: rgba(240, 192, 64, 0.12);
    border: 1px solid rgba(240, 192, 64, 0.25);
}

.role-admin {
    color: #e07040;
    background: rgba(224, 112, 64, 0.12);
    border: 1px solid rgba(224, 112, 64, 0.25);
}

.role-poweruser {
    color: #a070e0;
    background: rgba(160, 112, 224, 0.12);
    border: 1px solid rgba(160, 112, 224, 0.25);
}

.role-operator {
    color: #e0a040;
    background: rgba(224, 160, 64, 0.12);
    border: 1px solid rgba(224, 160, 64, 0.25);
}

.role-user {
    color: var(--text-secondary);
    background: rgba(136, 136, 160, 0.1);
    border: 1px solid rgba(136, 136, 160, 0.2);
}

/* ---------- Dashboard ---------- */
.dashboard-wrapper {
    text-align: center;
    padding: 2rem;
    width: 100%;
}

.content-area {
    margin-top: 100px;
}

.smiley-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    cursor: pointer;
    font-size: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    user-select: none;
}

.smiley-btn:hover {
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
    transform: scale(1.05);
}

.smiley-btn:active {
    transform: scale(0.95);
}

.smiley-btn.clicked {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.click-hint {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- Admin Panel ---------- */
.admin-wrapper {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 2rem 2rem 2rem;
    /* Override body centering for admin — we want top-aligned */
    align-self: flex-start;
}

/* Wider layout for activity log page */
.admin-wrapper.wide {
    max-width: 1200px;
}

/* When admin page is loaded, body should align to top */
body:has(.admin-wrapper) {
    align-items: flex-start;
}

.admin-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.section-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ---------- Admin Tables ---------- */
.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.admin-table thead th {
    text-align: left;
    padding: 0.6rem 0.8rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-subtle);
}

.admin-table tbody tr {
    border-bottom: 1px solid rgba(42, 42, 58, 0.5);
    transition: background var(--transition);
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.admin-table tbody td {
    padding: 0.7rem 0.8rem;
    vertical-align: middle;
}

.td-email {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.td-date {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.td-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.role-select {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
    outline: none;
}

.role-select:focus {
    border-color: var(--border-focus);
}

.role-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ---------- Whitelist Add Form ---------- */
.whitelist-add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.wl-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 0.5rem 0.8rem;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.wl-input::placeholder {
    color: var(--text-muted);
}

.wl-input:focus {
    border-color: var(--border-focus);
}

/* ---------- Challenge Page ---------- */
.challenge-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 3rem 2rem;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.challenge-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.challenge-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.challenge-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.challenge-placeholder {
    padding: 2rem;
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius);
}

/* ---------- Hangman Game ---------- */
.hangman-card {
    max-width: 560px;
    padding: 2rem 2rem 2.5rem;
}

.hangman-drawing {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.hangman-svg {
    width: 160px;
    height: 180px;
    color: var(--text-secondary);
}

.hm-part {
    transition: opacity 0.3s ease;
}

/* Phrase display */
.hangman-phrase {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    min-height: 2.5rem;
}

.hm-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-subtle);
    text-transform: uppercase;
}

.hm-letter.revealed {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.hm-space {
    width: 1rem;
}

/* Wrong guess counter */
.hangman-wrong-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

/* On-screen keyboard */
.hangman-keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    max-width: 440px;
    margin: 0 auto 1.2rem;
}

.hm-key {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    transition: all var(--transition);
}

.hm-key:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.hm-key:disabled {
    cursor: default;
    opacity: 0.4;
}

.hm-key.correct {
    border-color: var(--accent);
    color: var(--accent);
    opacity: 0.7;
}

.hm-key.wrong {
    border-color: var(--error);
    color: var(--error);
    opacity: 0.4;
}

/* Game status messages */
.hangman-status {
    min-height: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hangman-status.show {
    opacity: 1;
}

.status-win {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
}

.status-lose {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--error);
}

/* ---------- Activity Log ---------- */
.log-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.filter-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    text-decoration: none;
    transition: all var(--transition);
}

.filter-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.filter-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

.event-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.event-login {
    color: var(--accent);
    background: rgba(77, 184, 164, 0.12);
}

.event-login_failed {
    color: var(--error);
    background: rgba(224, 85, 85, 0.12);
}

.event-register {
    color: var(--success);
    background: rgba(77, 184, 106, 0.12);
}

.event-role_change {
    color: var(--warning);
    background: rgba(201, 168, 76, 0.12);
}

.event-user_delete {
    color: var(--error);
    background: rgba(224, 85, 85, 0.12);
}

.event-whitelist_add {
    color: var(--info);
    background: rgba(85, 136, 187, 0.12);
}

.event-whitelist_remove {
    color: #b07050;
    background: rgba(176, 112, 80, 0.12);
}

.td-details {
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 200px;
}

.td-ip {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---------- Vault ---------- */
.vault-hint {
    text-align: center;
    margin-bottom: 1.2rem;
    padding: 0.8rem;
    background: rgba(77, 184, 164, 0.06);
    border: 1px solid rgba(77, 184, 164, 0.15);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.hint-label {
    color: var(--accent);
    font-weight: 600;
}

/* Full-page Saturn background — scrollable */
body.vault-body {
    background: #0a0a0a;
    background-image: url('https://upload.wikimedia.org/wikipedia/commons/8/82/Francisco_de_Goya%2C_Saturno_devorando_a_su_hijo_%281819-1823%29.jpg');
    background-size: 100% auto;
    background-position: center top;
    background-repeat: no-repeat;
    min-height: 100vh;
}

body.vault-body > * {
    position: relative;
    z-index: 1;
}

body.vault-body .dashboard-nav {
    background: rgba(10, 8, 5, 0.85);
    border-bottom: 1px solid rgba(160, 120, 60, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.vault-wrapper {
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    padding: 80px 2rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* No parchment — text floats on the dark painting */
.vault-content {
    background: none;
    border: none;
    border-radius: 0;
    padding: 2rem 1.5rem;
    box-shadow: none;
    position: relative;
    width: 100%;
}

/* Subtle text shadow for readability against painting */
.vault-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #e8dcc8;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: 0.06em;
    font-family: Georgia, 'Times New Roman', serif;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.7);
}

.vault-content p {
    color: #d8ccb4;
    font-size: 0.92rem;
    line-height: 1.8;
    margin-bottom: 1.3rem;
    font-family: Georgia, 'Times New Roman', serif;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.6);
}

.vault-content p:last-child {
    margin-bottom: 0;
}

.vault-italic {
    font-style: italic;
    color: #c8a86a !important;
}

.vault-riddle {
    margin: 1.8rem 0;
    padding: 1.2rem 1.5rem;
    border-left: 3px solid rgba(200, 168, 106, 0.5);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 3px 3px 0;
    font-style: italic;
    color: #d8ccb4;
    font-size: 0.9rem;
    line-height: 1.8;
    font-family: Georgia, 'Times New Roman', serif;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}

.vault-content em {
    color: #e8dcc8;
    font-style: italic;
}

.vault-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 0 0.5rem;
    width: 100%;
}

.vault-page-info {
    font-size: 0.8rem;
    color: rgba(216, 204, 180, 0.5);
}

.vault-nav .btn-subtle {
    color: rgba(216, 204, 180, 0.6);
    border-color: rgba(216, 204, 180, 0.2);
}

.vault-nav .btn-subtle:hover {
    color: #d8ccb4;
    border-color: rgba(216, 204, 180, 0.5);
}

/* ---------- ETF Dashboard ---------- */
.etf-wrapper {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 2rem 3rem 2rem;
}

.etf-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

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

.etf-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.2rem;
}

.etf-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.etf-card-value {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.etf-card-value.positive { color: #4db8a4; }
.etf-card-value.negative { color: #e05555; }

.etf-card-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.etf-controls {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.etf-control-group {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.2rem;
    flex: 1;
    min-width: 280px;
}

.etf-control-group h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.etf-manual-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.etf-manual-form input {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    background: var(--bg-main);
    color: var(--text-primary);
    width: 130px;
}

.etf-manual-form input[type="date"] {
    width: 140px;
}

.etf-chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.etf-chart-container h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.etf-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100px;
    padding: 0 0.5rem;
}

.etf-bar-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-width: 3px;
    cursor: pointer;
}

.etf-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 1px 1px 0 0;
    transition: opacity 0.2s;
}

.bar-positive { background: #4db8a4; }
.bar-negative { background: #e05555; }

.etf-bar-wrap:hover .etf-bar { opacity: 0.7; }

.etf-chart-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.8rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.legend-positive { color: #4db8a4; }
.legend-negative { color: #e05555; }

.etf-table-wrap {
    overflow-x: auto;
}

.etf-table-wrap .admin-table td.positive { color: #4db8a4; }
.etf-table-wrap .admin-table td.negative { color: #e05555; }

.source-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.source-sosovalue {
    background: rgba(77, 184, 164, 0.1);
    color: #4db8a4;
}

.source-manual {
    background: rgba(180, 180, 180, 0.1);
    color: var(--text-muted);
}

/* ---------- Traffic Light Page ---------- */
body:has(.tl-wrapper) {
    align-items: flex-start;
}

.tl-wrapper {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 80px 2rem 3rem 2rem;
}

.tl-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.tl-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.tl-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* The traffic light housing */
.tl-housing {
    background: #111118;
    border: 2px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 120px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tl-light {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #1a1a24;
    border: 2px solid #2a2a3a;
    transition: all 0.3s ease;
    position: relative;
}

.tl-light.clickable {
    cursor: pointer;
}

.tl-light.clickable:hover {
    border-color: #444;
    transform: scale(1.05);
}

.tl-light.red-on {
    background: #ff2020;
    border-color: #ff4040;
    box-shadow: 0 0 20px rgba(255, 32, 32, 0.5), 0 0 50px rgba(255, 32, 32, 0.2);
}

.tl-light.yellow-on {
    background: #ffcc00;
    border-color: #ffdd33;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.5), 0 0 50px rgba(255, 204, 0, 0.2);
}

.tl-light.green-on {
    background: #00dd44;
    border-color: #22ee66;
    box-shadow: 0 0 20px rgba(0, 221, 68, 0.5), 0 0 50px rgba(0, 221, 68, 0.2);
}

/* Right side panel */
.tl-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tl-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.2rem;
}

.tl-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.8rem;
}

/* Master buttons */
.tl-master-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tl-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tl-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tl-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.tl-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tl-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Pattern buttons */
.tl-patterns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Button status indicator */
.tl-button-status {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.tl-button-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #444;
    transition: all 0.2s ease;
}

.tl-button-indicator.pressed {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(77, 184, 164, 0.5);
}

.tl-button-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Connection status */
.tl-connection {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
}

.tl-conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
    transition: all 0.3s ease;
}

.tl-conn-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px rgba(77, 184, 106, 0.4);
}

.tl-conn-dot.failed {
    background: var(--error);
}

.tl-conn-label {
    color: var(--text-muted);
}

.tl-conn-label.connected {
    color: var(--success);
}

.tl-conn-label.failed {
    color: var(--error);
}

/* Read-only notice */
.tl-readonly-notice {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    background: rgba(85, 136, 187, 0.08);
    border: 1px solid rgba(85, 136, 187, 0.2);
    font-size: 0.8rem;
    color: var(--info);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .nav-right {
        gap: 0.6rem;
    }

    .nav-user {
        display: none;
    }

    .admin-wrapper {
        padding: 70px 1rem 1rem 1rem;
    }

    .td-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .tl-layout {
        flex-direction: column;
        align-items: center;
    }

    .tl-housing {
        flex-direction: row;
        min-width: unset;
        padding: 1rem 1.5rem;
    }

    .tl-light {
        width: 56px;
        height: 56px;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }

    .dashboard-nav {
        padding: 0 1rem;
    }
}
