/* GamersInvest — esports HUD design system. One hand-written stylesheet, no build step.
   Type: Rajdhani (display, uppercase) + Inter (body). Icons: inline SVG via Icons.cs. */

:root {
    --bg: #06080c;
    --bg-sidebar: #080b11;
    --panel: #0c1017;
    --panel-2: #121826;
    --border: #1b2331;
    --border-bright: #2a3547;
    --text: #e9edf5;
    --text-muted: #7e8899;
    --accent: #17f083;
    --accent-2: #22d3ee;
    --accent-dim: rgba(23, 240, 131, 0.1);
    --accent-glow: rgba(23, 240, 131, 0.35);
    --up: #1ee787;
    --down: #ff4d6d;
    --gold: #ffc44d;
    --silver: #c3ccd9;
    --bronze: #d98e5a;
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Rajdhani", "Inter", sans-serif;
    --cut: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
}

/* Faint blueprint grid over the whole app — the HUD ground. */
body {
    background-image:
        radial-gradient(900px 480px at 85% -10%, rgba(34, 211, 238, 0.05), transparent 60%),
        radial-gradient(800px 420px at 0% 110%, rgba(23, 240, 131, 0.05), transparent 55%),
        repeating-linear-gradient(0deg, transparent 0 39px, rgba(126, 136, 153, 0.045) 39px 40px),
        repeating-linear-gradient(90deg, transparent 0 39px, rgba(126, 136, 153, 0.045) 39px 40px);
    background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.icon { vertical-align: -3px; flex-shrink: 0; }

::selection { background: var(--accent-glow); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a63; }

/* ---------- App shell ---------- */

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

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--bg-sidebar), #070a10);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand:hover { text-decoration: none; }

.brand-mark { display: block; filter: drop-shadow(0 0 6px var(--accent-glow)); }

.brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text);
}
.brand-name em { font-style: normal; color: var(--accent); }

.sidebar-nav { display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; flex: 1; }

.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    clip-path: var(--cut);
    transition: color 0.15s, background 0.15s;
}
.sidebar-nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active {
    background: linear-gradient(90deg, rgba(23, 240, 131, 0.16), rgba(23, 240, 131, 0.03));
    color: var(--accent);
}
.sidebar-nav a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}
.sidebar-nav a .icon { opacity: 0.9; }

.sidebar-user { border-top: 1px solid var(--border); padding: 14px 18px 18px; }

.user-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; color: var(--text); }
.user-row:hover { text-decoration: none; }
.user-row:hover .user-name { color: var(--accent); }
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(23, 240, 131, 0.35);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.user-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.04em; }

.user-stat { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.user-stat .label { color: var(--text-muted); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.08em; align-self: center; }
.user-stat .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.user-stat .value.accent { color: var(--accent); }

.logout-form { margin-top: 12px; }
.btn-logout { display: inline-flex; align-items: center; gap: 7px; width: 100%; justify-content: center; }

/* ---------- Topbar & content ---------- */

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(6, 8, 12, 0.82);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar h1::after {
    content: "";
    display: block;
    width: 34px;
    height: 2px;
    margin-top: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
}
.topbar-right { display: flex; gap: 8px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 13px;
    border: 1px solid var(--border);
    background: var(--panel);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    clip-path: var(--cut);
}
.chip-accent { border-color: rgba(23, 240, 131, 0.4); color: var(--accent); background: var(--accent-dim); }

.content { padding: 24px 28px 48px; }

.flash {
    margin: 14px 28px 0;
    padding: 11px 16px;
    font-weight: 550;
    border-left: 3px solid;
    clip-path: var(--cut);
}
.flash-success { background: rgba(30, 231, 135, 0.1); border-color: var(--up); color: var(--up); }
.flash-error { background: rgba(255, 77, 109, 0.1); border-color: var(--down); color: var(--down); }

/* ---------- Panels ---------- */

.panel {
    position: relative;
    background: linear-gradient(165deg, var(--panel-2), var(--panel) 45%);
    border: 1px solid var(--border);
    padding: 18px 20px;
    margin-bottom: 20px;
}
/* Corner bracket — the HUD signature. */
.panel::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    width: 18px;
    height: 18px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
    opacity: 0.75;
    pointer-events: none;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.panel-head h2 { font-size: 14.5px; font-weight: 700; color: var(--text); }
.panel-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; }
.panel-note { margin: 4px 0; }

.muted { color: var(--text-muted); }
.strong { font-weight: 650; }

/* ---------- Badges ---------- */

.cc-badge {
    display: inline-block;
    min-width: 24px;
    padding: 0 4px;
    border: 1px solid var(--border-bright);
    border-radius: 3px;
    background: var(--panel);
    color: var(--text-muted);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 15px;
    text-align: center;
    vertical-align: 1px;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 700;
    color: #0b0e14;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.rank-1 { background: linear-gradient(160deg, #ffd97a, var(--gold)); box-shadow: 0 0 10px rgba(255, 196, 77, 0.4); }
.rank-2 { background: linear-gradient(160deg, #e6ecf5, var(--silver)); }
.rank-3 { background: linear-gradient(160deg, #e8a877, var(--bronze)); }
.rank-plain { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.change { font-weight: 650; font-variant-numeric: tabular-nums; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change.flat { color: var(--text-muted); }

/* ---------- Tables ---------- */

.data-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th {
    text-align: left;
    font-family: var(--font-display);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-bright);
}
.data-table td { padding: 10px; border-bottom: 1px solid rgba(27, 35, 49, 0.6); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; }

.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--panel-2); }
.clickable-row:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.highlight-row td { background: var(--accent-dim); }

.team-cell { display: flex; align-items: center; gap: 12px; }
.team-cell-name { font-weight: 600; }
.team-cell-sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }

/* Hexagonal team tiles. */
.team-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 38px;
    flex-shrink: 0;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    background: linear-gradient(155deg, var(--logo-color, #566), color-mix(in srgb, var(--logo-color, #566) 45%, #000));
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}
.team-logo-lg { width: 54px; height: 58px; font-size: 15px; }

.sparkline polyline, .sparkline line { fill: none; stroke-width: 1.6; stroke: var(--text-muted); }
.sparkline.up polyline { stroke: var(--up); }
.sparkline.down polyline { stroke: var(--down); }

/* ---------- Dashboard layout ---------- */

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.dashboard-side { min-width: 0; }

.stat-row { display: flex; gap: 26px; }
.stat .label, .stat-card .label {
    display: block;
    font-family: var(--font-display);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--text-muted);
}
.stat .value, .stat-card .value {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    position: relative;
    background: linear-gradient(165deg, var(--panel-2), var(--panel) 45%);
    border: 1px solid var(--border);
    padding: 13px 18px;
}
.stat-card::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    width: 14px;
    height: 14px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
    opacity: 0.7;
}

.mover-list { list-style: none; margin: 0; padding: 0; }
.mover-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 6px;
    color: var(--text);
    border-bottom: 1px solid rgba(27, 35, 49, 0.55);
    font-weight: 600;
}
.mover-list li:last-child a { border-bottom: none; }
.mover-list li a:hover { text-decoration: none; background: var(--panel-2); }
.mover-symbol { display: inline-flex; align-items: center; gap: 7px; }
.mover-symbol .icon-arrow-up { color: var(--up); }
.mover-symbol .icon-arrow-down { color: var(--down); }

/* ---------- Match cards ---------- */

.match-card {
    position: relative;
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-bright);
    padding: 12px 14px;
    margin-bottom: 10px;
    background: linear-gradient(170deg, var(--panel-2), var(--panel) 60%);
}
.match-card.is-live {
    border-left-color: var(--down);
    box-shadow: inset 0 0 24px rgba(255, 77, 109, 0.05);
}

.match-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 9px; }
.event-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-bo {
    margin-left: auto;
    border: 1px solid var(--border-bright);
    padding: 0 6px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.event-tier {
    padding: 1px 8px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    flex-shrink: 0;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 100%, 6px 100%);
}
.tier-stier { background: rgba(255, 196, 77, 0.16); color: var(--gold); }
.tier-atier { background: rgba(34, 211, 238, 0.14); color: var(--accent-2); }
.tier-btier { background: rgba(126, 136, 153, 0.16); color: var(--text-muted); }
.tier-ctier { background: rgba(126, 136, 153, 0.09); color: var(--text-muted); }

.match-teams { display: flex; flex-direction: column; gap: 6px; }
.match-team {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    padding: 3px 5px;
}
.match-team:hover { background: var(--panel); text-decoration: none; }
.match-team .team-logo { width: 27px; height: 29px; font-size: 8.5px; }
.match-team .team-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.match-team.won .team-name { font-weight: 700; }
.match-team.lost { opacity: 0.5; }
.team-score { font-family: var(--font-display); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.match-team.won .team-score { color: var(--accent); }
.team-odds { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.match-when { margin-top: 9px; font-size: 12px; color: var(--text-muted); }

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--down);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.12em;
}
.live-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--down);
    box-shadow: 0 0 8px var(--down);
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

.match-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.match-card-grid .match-card { margin-bottom: 0; }
.matches-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ---------- Stock detail ---------- */

.stock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stock-identity { display: flex; align-items: center; gap: 16px; }
.stock-identity h2 { font-size: 23px; font-weight: 700; }
.stock-sub { color: var(--text-muted); font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stock-price-block { text-align: right; }
.stock-price {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 24px var(--accent-glow);
}

.stock-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stock-side { min-width: 0; }

.price-chart { width: 100%; min-height: 320px; }
.price-chart svg { display: block; width: 100%; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-area { fill: url(#chart-gradient); }
.chart-grid-line { stroke: rgba(126, 136, 153, 0.13); stroke-width: 1; }
.chart-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart-crosshair { stroke: rgba(233, 237, 245, 0.35); stroke-dasharray: 3 3; }
.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--panel-2);
    border: 1px solid var(--border-bright);
    padding: 6px 10px;
    font-size: 12.5px;
    transform: translate(-50%, -130%);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    clip-path: var(--cut);
}

/* ---------- Forms & buttons ---------- */

.trade-facts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.trade-facts > div { display: flex; justify-content: space-between; font-size: 13px; }
.trade-facts .label { color: var(--text-muted); }
.trade-facts .value { font-variant-numeric: tabular-nums; font-weight: 600; }

.trade-panel label {
    display: block;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.trade-panel input[type="number"] {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-bright);
    color: var(--text);
    padding: 10px 12px;
    font-size: 15px;
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
}
.trade-panel input[type="number"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.trade-estimate { min-height: 20px; margin: 8px 0 4px; font-size: 12.5px; }

.trade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

.btn-buy, .btn-sell, .btn-primary, .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    padding: 11px 18px;
    font-family: var(--font-display);
    font-size: 14.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    clip-path: var(--cut);
    transition: filter 0.15s, background 0.15s;
}
.btn-buy { background: linear-gradient(160deg, #2bf59a, #0ecf72); color: #04241a; }
.btn-buy:hover { filter: brightness(1.1); }
.btn-sell { background: rgba(255, 77, 109, 0.13); color: var(--down); box-shadow: inset 0 0 0 1px rgba(255, 77, 109, 0.5); }
.btn-sell:hover:not(:disabled) { background: rgba(255, 77, 109, 0.24); }
.btn-sell:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: linear-gradient(160deg, var(--accent), #0fcfa0); color: #04241a; }
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-block { width: 100%; }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px var(--border-bright);
    font-weight: 600;
}
.btn-ghost:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--text-muted); text-decoration: none; }

/* ---------- Impacts ---------- */

.impact-list { list-style: none; margin: 0; padding: 0; }
.impact-list li { padding: 9px 0; border-bottom: 1px solid rgba(27, 35, 49, 0.55); }
.impact-list li:last-child { border-bottom: none; }
.impact-line { display: flex; align-items: center; gap: 10px; }
.impact-opponent { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impact-result {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 24px;
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    flex-shrink: 0;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.impact-result.up { background: rgba(30, 231, 135, 0.16); color: var(--up); }
.impact-result.down { background: rgba(255, 77, 109, 0.16); color: var(--down); }
.impact-detail { font-size: 12px; margin-top: 3px; }

/* ---------- Leaderboard / admin ---------- */

.rank-cell { text-align: center !important; }

/* Investor names inherit the row colour so the leaderboard doesn't turn into a wall of accent
   links; the row itself is clickable, the anchor is there for middle-click and accessibility. */
.investor-link { color: var(--text); font-weight: 600; }
.investor-link:hover { color: var(--accent); text-decoration: none; }

.investor-cell { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Rank insignia & role chips ---------- */

.rank-ins { position: relative; display: inline-flex; cursor: default; vertical-align: -5px; }
.rank-ins svg { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--rank-color) 40%, transparent)); }

/* Tippy-style tooltip, pure CSS: the rank name rides in data-tip and pops above the badge. */
.rank-ins::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translate(-50%, 4px);
    padding: 5px 11px;
    background: var(--panel-2);
    border: 1px solid var(--border-bright);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--rank-color, var(--text));
    white-space: nowrap;
    clip-path: var(--cut);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 30;
}
.rank-ins::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--border-bright);
    transform: translateX(-50%) rotate(45deg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 29;
}
.rank-ins:hover::after { opacity: 1; transform: translate(-50%, 0); }
.rank-ins:hover::before { opacity: 1; }

.role-chip {
    padding: 1px 7px;
    font-family: var(--font-display);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 100%, 5px 100%);
}
.role-sysadmin { background: rgba(34, 211, 238, 0.14); color: var(--accent-2); }
.role-admin { background: rgba(255, 196, 77, 0.14); color: var(--gold); }

/* ---------- Profile ---------- */

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 56px;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid rgba(23, 240, 131, 0.35);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    flex-shrink: 0;
}
.profile-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: 0.03em; }
.profile-rank { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.profile-rank .label {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.side-badge {
    padding: 2px 9px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 100%, 6px 100%);
}
.side-buy { background: rgba(30, 231, 135, 0.15); color: var(--up); }
.side-sell { background: rgba(255, 77, 109, 0.15); color: var(--down); }

.admin-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.log-level {
    padding: 1px 8px;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.log-information { background: rgba(34, 211, 238, 0.13); color: var(--accent-2); }
.log-warning { background: rgba(255, 196, 77, 0.14); color: var(--gold); }
.log-error { background: rgba(255, 77, 109, 0.14); color: var(--down); }
.log-table pre { white-space: pre-wrap; font-size: 12px; color: var(--text-muted); }
.log-table details summary { cursor: pointer; color: var(--accent-2); font-size: 12px; }

.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border-bright); }
.admin-tabs a {
    padding: 8px 16px;
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-decoration: none;
}
.admin-tabs a.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.admin-tabs a:hover { color: var(--text); }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 18px; }

.admin-form label {
    display: block;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 13px 0 5px;
}
.admin-form input:not([type="checkbox"]) {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-bright);
    color: var(--text);
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--font);
    margin-top: 5px;
}
.admin-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.admin-form .btn-primary { margin-top: 16px; }
.admin-form .muted { font-size: 12.5px; }

.admin-search { display: flex; gap: 12px; align-items: center; }
.admin-search input[type="search"] {
    background: var(--bg);
    border: 1px solid var(--border-bright);
    color: var(--text);
    padding: 7px 12px;
    font-size: 13.5px;
    font-family: var(--font);
    min-width: 220px;
}
.admin-search input[type="search"]:focus { outline: none; border-color: var(--accent); }
.admin-search .checkbox-row { margin-top: 0 !important; }

.role-pill {
    display: inline-block;
    padding: 1px 8px;
    margin-right: 4px;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--panel-2);
    color: var(--text-muted);
    border: 1px solid var(--border-bright);
}
.role-pill.role-sysadmin { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.panel-danger::before { background: var(--down) !important; }
.btn-danger {
    background: rgba(255, 77, 109, 0.12);
    color: var(--down);
    border: 1px solid var(--down);
    padding: 9px 16px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}
.btn-danger:hover { background: rgba(255, 77, 109, 0.22); }

/* ---------- Auth pages ---------- */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-image:
        radial-gradient(1000px 520px at 15% -10%, rgba(23, 240, 131, 0.08), transparent 60%),
        radial-gradient(820px 520px at 95% 110%, rgba(34, 211, 238, 0.08), transparent 60%),
        repeating-linear-gradient(0deg, transparent 0 39px, rgba(126, 136, 153, 0.05) 39px 40px),
        repeating-linear-gradient(90deg, transparent 0 39px, rgba(126, 136, 153, 0.05) 39px 40px);
}

.auth-shell { width: 404px; max-width: calc(100vw - 40px); }

.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .brand-name { font-size: 24px; }
.auth-brand .brand-mark { width: 44px; height: 44px; }

.auth-card {
    position: relative;
    background: linear-gradient(165deg, var(--panel-2), var(--panel) 45%);
    border: 1px solid var(--border);
    padding: 28px;
}
.auth-card::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    width: 22px;
    height: 22px;
    border-top: 2px solid var(--accent);
    border-left: 2px solid var(--accent);
}
.auth-card::after {
    content: "";
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 22px;
    height: 22px;
    border-bottom: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
    opacity: 0.5;
}
.auth-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); margin: 0 0 18px; }

.auth-card label {
    display: block;
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 13px 0 5px;
}
.auth-card input:not([type="checkbox"]) {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-bright);
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font);
}
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.auth-card .btn-primary { margin-top: 20px; }

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 15px !important;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 500;
}
.checkbox-row input { accent-color: var(--accent); }

.validation-summary ul { margin: 0 0 10px; padding-left: 18px; color: var(--down); }
.validation-summary:empty { display: none; }
.field-error { display: block; color: var(--down); font-size: 12.5px; margin-top: 4px; }

.auth-switch { text-align: center; margin: 18px 0 0; color: var(--text-muted); }
.auth-footnote { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 18px; }

/* ---------- Motion ---------- */
/* The HUD comes alive: entrances, sweeps and glows in the same language as the maintenance
   screen. Everything that hides content before revealing it lives inside the no-preference
   block, so reduced-motion users get a fully visible, still page rather than a broken one. */

.main-column { position: relative; }

/* Navigation sweep: the deploy bar's gradient, shown while the browser fetches the next page.
   nav-progress.js toggles .active; the 0.12s delay keeps instant navigations flash-free. */
.nav-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 20;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}
.nav-progress.active { opacity: 1; }
.nav-progress::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
    left: -40%;
}
.nav-progress.active::before { animation: nav-sweep 1s ease-in-out 0.12s infinite; }
@keyframes nav-sweep { to { left: 105%; } }

.sidebar-nav a { transition: background 0.15s, color 0.15s, transform 0.15s; }
.clickable-row td { transition: background 0.12s; }
.btn-buy, .btn-sell, .btn-primary, .btn-ghost { transition: box-shadow 0.2s, filter 0.2s; }
.btn-primary:hover, .btn-buy:hover { box-shadow: 0 0 16px var(--accent-glow); }
.btn-sell:hover { box-shadow: 0 0 16px rgba(255, 77, 109, 0.35); }

@media (prefers-reduced-motion: no-preference) {
    .sidebar-nav a:hover { transform: translateX(3px); }

    /* Page entrance: content blocks rise in with a small stagger, then the topbar rule sweeps. */
    .content > * { animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
    .content > *:nth-child(2) { animation-delay: 0.06s; }
    .content > *:nth-child(3) { animation-delay: 0.12s; }
    .content > *:nth-child(4) { animation-delay: 0.18s; }
    .content > *:nth-child(n+5) { animation-delay: 0.24s; }
    @keyframes rise { from { opacity: 0; transform: translateY(10px); } }

    .topbar h1::after { animation: rule-in 0.6s 0.2s ease both; }
    @keyframes rule-in { from { width: 0; opacity: 0; } }

    .flash { animation: flash-in 0.35s ease both; }
    @keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }

    /* Sparklines draw themselves left to right; pathLength=100 is set in ViewHelpers.Sparkline
       so one dash length fits every line regardless of its real geometry. */
    .sparkline polyline, .sparkline line {
        stroke-dasharray: 100;
        stroke-dashoffset: 100;
        animation: draw-line 0.9s ease-out 0.15s forwards;
    }
    @keyframes draw-line { to { stroke-dashoffset: 0; } }

    /* The detail chart draws in too, its area fill fading up once the line is mostly there. */
    .chart-line {
        stroke-dasharray: 100;
        stroke-dashoffset: 100;
        animation: draw-line 1.1s ease-out 0.1s forwards;
    }
    .chart-area { animation: fade-in 0.7s ease 0.6s both; }
    @keyframes fade-in { from { opacity: 0; } }

    /* Live matches breathe: the inset red glow swells and settles like a heartbeat. */
    .match-card.is-live { animation: live-breathe 2.6s ease-in-out infinite; }
    @keyframes live-breathe {
        0%, 100% { box-shadow: inset 0 0 24px rgba(255, 77, 109, 0.05); }
        50% { box-shadow: inset 0 0 36px rgba(255, 77, 109, 0.13); }
    }

    /* The brand mark idles with the same pulse as the maintenance loader, just quieter. */
    .sidebar-brand .brand-mark { animation: mark-pulse 3.2s ease-in-out infinite; }
    @keyframes mark-pulse {
        0%, 100% { filter: drop-shadow(0 0 6px var(--accent-glow)); }
        50% { filter: drop-shadow(0 0 13px var(--accent-glow)); }
    }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .dashboard-grid, .stock-grid, .matches-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 8px; }
    .sidebar-user { border-top: none; margin-left: auto; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
}
