:root {
    --c-void:          #0a0a0a;
    --c-bg:            #0c0c0c;
    --c-surface-0:     #0e0e0e;
    --c-surface-1:     #121212;
    --c-surface-2:     #151515;
    --c-surface-3:     #181818;
    --c-surface-4:     #1c1c1c;

    --c-border:        #262626;
    --c-border-light:  #353535;

    --c-stone-warm:    #5a5550;
    --c-gold-dim:      #5a5040;
    --c-gold:          #9a8a68;
    --c-gold-glow:     #c4b28a;
    --c-bone:          #d4cec4;

    --c-text:          #c0b8a8;
    --c-text-dim:      #9a9286;
    --c-text-faint:    #7c756b;

    --c-urgent:        #c4694f;
    --c-ok:            #6f9d74;
    --c-warn:          #b89a55;
    --c-mana:          #7d9cb6;

    --rgb-black:       0, 0, 0;
    --rgb-texture:     20, 20, 20;
    --rgb-gold:        154, 138, 104;
    --rgb-bone:        212, 206, 196;
    --rgb-ash:         138, 138, 138;
    --rgb-urgent:      196, 105, 79;
    --rgb-ok:          111, 157, 116;
    --rgb-warn:        184, 154, 85;
    --rgb-mana:        125, 156, 182;

    --font-display: 'Cinzel', 'Times New Roman', Georgia, serif;
    --font-body:    'Crimson Text', Georgia, 'Times New Roman', serif;
    --font-ui:      'Barlow Condensed', 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;

    --fs-xs:   0.75rem;
    --fs-sm:   0.875rem;
    --fs-md:   0.9625rem;
    --fs-lg:   1.25rem;
    --fs-xl:   1.75rem;
    --fs-kpi:  2.25rem;

    --ls-tight:  0.06em;
    --ls-normal: 0.16em;
    --ls-title:  0.26em;

    --radius:      6px;
    --radius-cell: 3px;
    --sidebar-w:   15.5rem;

    --c-discord:       #5865F2;
    --c-discord-hover: #4752C4;
}

.tone-ok     { --t-rgb: 111, 157, 116; --t-text: #8fbb93; }
.tone-urgent { --t-rgb: 196, 105, 79;  --t-text: #da8a72; }
.tone-gold   { --t-rgb: 176, 156, 116; --t-text: #cdb98f; }
.tone-warn   { --t-rgb: 184, 154, 85;  --t-text: #cfb06a; }
.tone-mana   { --t-rgb: 125, 156, 182; --t-text: #9bb7cd; }
.tone-ash    { --t-rgb: 138, 138, 138; --t-text: #a8a29a; }
.tone-silver { --t-rgb: 180, 180, 180; --t-text: #cfcfcf; }
.tone-ember  { --t-rgb: 166, 128, 92;  --t-text: #c09670; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    font-size: var(--fs-md);
    background: var(--c-bg);
    color: var(--c-text);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

code {
    font-family: var(--font-ui);
    color: var(--c-gold-glow);
    background: rgba(var(--rgb-gold), 0.1);
    padding: 0 0.3em;
    border-radius: 2px;
}

.icon {
    width: 1.1em;
    height: 1.1em;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 1px solid var(--c-gold-glow);
    outline-offset: 2px;
}

/* LOGIN */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(var(--rgb-gold), 0.08) 0%, rgba(var(--rgb-black), 0) 60%),
        var(--c-bg);
}

.login-box {
    background: var(--c-surface-1);
    padding: 3rem;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--c-border);
    max-width: 25rem;
    width: 90%;
}

.login-box h1 {
    font-family: var(--font-display);
    color: var(--c-gold-glow);
    margin-bottom: 0.75rem;
    font-size: var(--fs-xl);
    letter-spacing: var(--ls-title);
    text-transform: uppercase;
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
}

.login-box p {
    color: var(--c-text-dim);
    margin-bottom: 2rem;
    font-size: var(--fs-md);
}

.discord-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--c-discord);
    color: #fff;
    text-decoration: none;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-cell);
    font-family: var(--font-display);
    letter-spacing: var(--ls-tight);
    transition: background 0.2s;
}

.discord-btn:hover { background: var(--c-discord-hover); }
.discord-btn svg { width: 1.5rem; height: 1.5rem; }

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--c-surface-0);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    font-family: var(--font-display);
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--c-gold-glow);
    letter-spacing: var(--ls-title);
    text-transform: uppercase;
    padding: 1.4rem 1.4rem 1.3rem;
    border-bottom: 1px solid var(--c-border);
}

.logo-mark { width: 1.6rem; height: 1.6rem; object-fit: contain; }

.sidebar ul { list-style: none; padding: 0.6rem 0.75rem; }

.sidebar li + li { margin-top: 2px; }

.sidebar a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--c-text-dim);
    text-decoration: none;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-cell);
    border-left: 2px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-size: var(--fs-md);
}

.sidebar a:hover {
    background: rgba(var(--rgb-gold), 0.06);
    color: var(--c-bone);
}

.sidebar li.active a {
    background: rgba(var(--rgb-gold), 0.12);
    border-left-color: var(--c-gold-glow);
    color: var(--c-gold-glow);
}

.nav-main { flex: 0 0 auto; }

.nav-group-label {
    padding: 1rem 1.55rem 0.15rem;
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-text-faint);
    border-top: 1px solid var(--c-border);
    margin-top: 0.35rem;
}

#dynamicNav ul,
#ownerNav ul { padding-top: 0.35rem; }

.user-info {
    margin-top: auto;
    padding: 1rem 1.4rem 1.2rem;
    border-top: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.user-name {
    font-family: var(--font-display);
    color: var(--c-bone);
    letter-spacing: 0.04em;
    font-size: var(--fs-sm);
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-gold);
    margin-bottom: 0.55rem;
}

.logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--c-text-faint);
    text-decoration: none;
    font-size: var(--fs-sm);
    transition: color 0.15s;
}

.logout:hover { color: var(--c-urgent); }

/* LAYOUT */
.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2.25rem 3rem;
    max-width: calc(var(--sidebar-w) + 100rem);
}

.page { display: none; }
.page.active { display: block; animation: page-in 0.18s ease-out; }

@keyframes page-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 0.8rem;
    margin-bottom: 1.4rem;
}

h1 {
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    color: var(--c-bone);
    letter-spacing: var(--ls-normal);
    text-transform: uppercase;
    font-weight: 600;
    line-height: 1.1;
}

.page-tools { display: flex; align-items: center; gap: 0.75rem; }

.page-intro {
    color: var(--c-text-dim);
    margin-bottom: 1rem;
    max-width: 60rem;
}

.stamp {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* CARDS */
.card {
    background: var(--c-surface-1);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    min-width: 0;
}

.card h3 {
    font-family: var(--font-display);
    color: var(--c-gold);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    font-weight: 600;
    margin-bottom: 0.85rem;
}

.card h3 small {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    letter-spacing: var(--ls-tight);
    margin-left: 0.4rem;
    font-weight: 500;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.kpi { position: relative; overflow: hidden; }

.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    background: linear-gradient(180deg, rgba(var(--rgb-gold), 0.9), rgba(var(--rgb-gold), 0));
}

.kpi-urgent::before {
    background: linear-gradient(180deg, rgba(var(--rgb-urgent), 0.95), rgba(var(--rgb-urgent), 0));
}

.kpi h3 { margin-bottom: 0.4rem; }

.kpi-value {
    font-family: var(--font-ui);
    font-size: var(--fs-kpi);
    font-weight: 500;
    color: var(--c-bone);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-urgent .kpi-value { color: #da8a72; }

.kpi-sub {
    margin-top: 0.35rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    min-height: 1.2em;
}

.delta-up   { color: #8fbb93; }
.delta-down { color: #da8a72; }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.rank-list { list-style: none; }

.rank-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.25rem 1rem;
    padding: 0.42rem 0;
    border-bottom: 1px solid rgba(var(--rgb-ash), 0.1);
}

.rank-list li:last-child { border-bottom: none; }

.rank-count {
    font-family: var(--font-ui);
    color: var(--c-bone);
    font-variant-numeric: tabular-nums;
}

.rank-bar {
    grid-column: 1 / -1;
    height: 3px;
    background: rgba(var(--rgb-ash), 0.12);
    border-radius: 2px;
    overflow: hidden;
}

.rank-bar span {
    display: block;
    height: 100%;
    background: rgba(var(--t-rgb, var(--rgb-gold)), 0.75);
}

.kv-list { list-style: none; }

.kv-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.42rem 0;
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
    border-bottom: 1px solid rgba(var(--rgb-ash), 0.1);
}

.kv-list li:last-child { border-bottom: none; }

.kv-list li span {
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    color: var(--c-bone);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
}

.kv-list li span.ok { color: #8fbb93; }
.kv-list li span.warn { color: #cfb06a; }

/* CHARTS */
.chart-card { margin-bottom: 1rem; }

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.card-head h3 { margin-bottom: 0.25rem; }

.chart-max {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
}

.chart {
    position: relative;
    height: 11rem;
    border-bottom: 1px solid var(--c-border-light);
}

.chart-grid { position: absolute; inset: 0; pointer-events: none; }

.chart-grid span {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed rgba(var(--rgb-ash), 0.14);
}

.chart-grid span[data-grid="max"] { top: 0; }
.chart-grid span[data-grid="mid"] { top: 50%; }

.chart-grid span::after {
    content: attr(data-label);
    position: absolute;
    right: 0;
    top: -0.5rem;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    font-variant-numeric: tabular-nums;
}

.chart-bars {
    position: absolute;
    inset: 0 2.75rem 0 0;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.chart-col {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
    cursor: default;
}

.chart-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 2px 2px 0 0;
    background: linear-gradient(180deg, rgba(var(--rgb-gold), 0.95) 0%, rgba(var(--rgb-gold), 0.38) 100%);
    transition: background 0.12s, filter 0.12s;
}

.chart-bar.crash {
    background: linear-gradient(180deg, rgba(var(--rgb-urgent), 0.95) 0%, rgba(var(--rgb-urgent), 0.35) 100%);
}

.chart-bar.empty { background: rgba(var(--rgb-ash), 0.16); }

.chart-bar.partial {
    background: repeating-linear-gradient(135deg,
        rgba(var(--rgb-gold), 0.55) 0 4px,
        rgba(var(--rgb-gold), 0.3) 4px 8px);
}

.chart-bar.crash.partial {
    background: repeating-linear-gradient(135deg,
        rgba(var(--rgb-urgent), 0.6) 0 4px,
        rgba(var(--rgb-urgent), 0.32) 4px 8px);
}

.chart-col:hover .chart-bar,
.chart-col.hover .chart-bar {
    background: rgba(var(--rgb-bone), 0.85);
}

.chart-col:hover .chart-bar.crash,
.chart-col.hover .chart-bar.crash {
    background: #e39a82;
}

.chart-axis {
    position: relative;
    height: 1.5rem;
    margin: 0.35rem 2.75rem 0 0;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    font-variant-numeric: tabular-nums;
}

.chart-axis span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

.chart-axis span.today { color: var(--c-gold-glow); }

.chart-note {
    margin-top: 0.4rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    margin-top: 0.6rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
}

.legend-item { display: inline-flex; align-items: center; gap: 0.45rem; }

.legend-item b {
    color: var(--c-bone);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: rgb(var(--t-rgb, var(--rgb-ash)));
    flex: 0 0 auto;
}

.chart-tip {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    min-width: 9rem;
    padding: 0.55rem 0.75rem;
    background: var(--c-surface-4);
    border: 1px solid var(--c-border-light);
    border-top: 2px solid var(--c-gold);
    border-radius: var(--radius-cell);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text);
    line-height: 1.35;
}

.chart-tip.crash { border-top-color: var(--c-urgent); }

.tip-title {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-text-faint);
}

.tip-value {
    font-size: 1.35rem;
    color: var(--c-bone);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.tip-rows { margin-top: 0.3rem; display: grid; gap: 0.1rem; }

.tip-row { display: flex; align-items: center; gap: 0.45rem; }
.tip-row b { margin-left: auto; padding-left: 1rem; color: var(--c-bone); font-weight: 500; }

.card-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
}

.card-nav span { min-width: 8rem; text-align: center; }

/* BUTTONS AND FIELDS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 2.4rem;
    padding: 0 1.1rem;
    border-radius: var(--radius-cell);
    border: 1px solid var(--c-border-light);
    background: var(--c-surface-2);
    color: var(--c-text);
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: var(--ls-normal);
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn:hover:not(:disabled) { border-color: rgba(var(--rgb-gold), 0.6); color: var(--c-bone); }

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

.btn-primary {
    background: rgba(var(--rgb-gold), 0.16);
    border-color: rgba(var(--rgb-gold), 0.55);
    color: var(--c-gold-glow);
}

.btn-primary:hover:not(:disabled) { background: rgba(var(--rgb-gold), 0.28); }

.btn-ghost { background: transparent; border-color: var(--c-border); color: var(--c-text-dim); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: var(--radius-cell);
    border: 1px solid var(--c-border-light);
    background: var(--c-surface-2);
    color: var(--c-text-dim);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.icon-btn .icon { width: 1.15rem; height: 1.15rem; }

.icon-btn:hover:not(:disabled) {
    color: var(--c-gold-glow);
    border-color: rgba(var(--rgb-gold), 0.6);
    background: rgba(var(--rgb-gold), 0.08);
}

.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.icon-btn.small { width: 1.9rem; height: 1.9rem; }
.icon-btn.small .icon { width: 1rem; height: 1rem; }

.icon-btn.loading .icon { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch-track {
    position: relative;
    width: 2.1rem;
    height: 1.15rem;
    border-radius: 1rem;
    background: var(--c-surface-3);
    border: 1px solid var(--c-border-light);
    transition: background 0.15s, border-color 0.15s;
}

.switch-thumb {
    position: absolute;
    top: 50%;
    left: 0.15rem;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--c-text-faint);
    transform: translateY(-50%);
    transition: left 0.15s, background 0.15s;
}

.switch input:checked + .switch-track {
    background: rgba(var(--rgb-ok), 0.22);
    border-color: rgba(var(--rgb-ok), 0.7);
}

.switch input:checked + .switch-track .switch-thumb { left: 1.15rem; background: #8fbb93; }

.switch input:focus-visible + .switch-track { outline: 1px solid var(--c-gold-glow); outline-offset: 2px; }

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-text-faint);
}

.live-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--c-text-faint);
    opacity: 0.5;
}

.switch input:checked ~ .switch-label { color: #8fbb93; }

.switch input:checked ~ .switch-label .live-dot {
    background: #8fbb93;
    opacity: 1;
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toolbar-filters,
.toolbar-live {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.toolbar-live { align-items: center; padding-bottom: 0.1rem; gap: 0.85rem; margin-left: auto; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }

.field-label {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-text-faint);
}

.field input,
.field select {
    height: 2.4rem;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-light);
    color: var(--c-text);
    padding: 0 0.75rem;
    border-radius: var(--radius-cell);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    min-width: 9rem;
}

.field select { min-width: 13rem; max-width: 20rem; cursor: pointer; }

.field input::placeholder { color: var(--c-text-faint); }

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--c-gold);
    color: var(--c-bone);
}

.field select option,
.field select optgroup { background: var(--c-surface-1); color: var(--c-text); }

.field input[type="date"] { color-scheme: dark; min-width: 9.5rem; }

.field input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.field-search { position: relative; align-self: flex-end; }

.field-search .icon {
    position: absolute;
    left: 0.7rem;
    bottom: 0.65rem;
    color: var(--c-text-faint);
    pointer-events: none;
}

.field-search input { padding-left: 2.2rem; min-width: 18rem; }

/* TABS */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.1rem;
    padding: 0 0.8rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-cell);
    background: var(--c-surface-1);
    color: var(--c-text-dim);
    font-family: var(--font-body);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}

.tab:hover { border-color: rgba(var(--rgb-gold), 0.45); color: var(--c-bone); }

.tab.active {
    background: rgba(var(--rgb-gold), 0.14);
    border-color: rgba(var(--rgb-gold), 0.7);
    color: var(--c-gold-glow);
}

.tab-count {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    font-variant-numeric: tabular-nums;
    padding: 0.05rem 0.4rem;
    border-radius: 2px;
    background: rgba(var(--rgb-ash), 0.12);
    color: var(--c-text-faint);
}

.tab-count.zero { opacity: 0.45; }

.tab.active .tab-count { background: rgba(var(--rgb-gold), 0.2); color: var(--c-gold-glow); }

.tab-all { font-family: var(--font-display); font-size: var(--fs-xs); font-weight: 600; letter-spacing: var(--ls-normal); text-transform: uppercase; }

/* TABLES */
.table-wrap {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface-1);
    overflow-x: auto;
}

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

th, td { padding: 0.55rem 0.9rem; text-align: left; vertical-align: top; }

th {
    background: var(--c-surface-3);
    border-bottom: 1px solid var(--c-border-light);
    font-family: var(--font-display);
    color: var(--c-gold);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

td {
    border-bottom: 1px solid rgba(var(--rgb-ash), 0.1);
    font-size: var(--fs-md);
    color: var(--c-text);
}

tbody tr:last-child td { border-bottom: none; }

.empty-cell {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--c-text-faint);
    font-style: italic;
}

.col-time { width: 8.5rem; }
.col-type { width: 1%; }
.col-player { width: 12rem; }

.log-row { cursor: pointer; transition: background 0.12s; }
.log-row:hover { background: rgba(var(--rgb-gold), 0.05); }
.log-row.open { background: rgba(var(--rgb-gold), 0.08); }
.log-row.open td { border-bottom-color: transparent; }

.log-row.fresh { animation: fresh 2.4s ease-out; }

@keyframes fresh {
    0% { background: rgba(var(--rgb-gold), 0.22); }
    100% { background: transparent; }
}

.cell-time {
    font-family: var(--font-ui);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}

.cell-time .t-hour { display: block; color: var(--c-bone); font-size: var(--fs-md); }
.cell-time .t-day { display: block; color: var(--c-text-faint); font-size: var(--fs-xs); }

.cell-player { line-height: 1.2; }

.player-link {
    color: var(--c-bone);
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    padding: 0;
    text-align: left;
    border-bottom: 1px dotted transparent;
}

.player-link:hover { color: var(--c-gold-glow); border-bottom-color: currentColor; }

.player-cid {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    letter-spacing: 0.04em;
    margin-top: 0.1rem;
}

.cell-details { max-width: 0; width: 100%; }

.chips {
    display: flex;
    gap: 0.35rem;
    overflow: hidden;
    white-space: nowrap;
    mask-image: linear-gradient(90deg, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    flex: 0 0 auto;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-cell);
    background: rgba(var(--rgb-ash), 0.08);
    border: 1px solid rgba(var(--rgb-ash), 0.12);
    font-size: var(--fs-sm);
    line-height: 1.45;
}

.chip-k {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-tight);
    color: var(--c-text-faint);
}

.chip-v {
    font-family: var(--font-ui);
    color: var(--c-bone);
    font-variant-numeric: tabular-nums;
}

.v-yes { color: #8fbb93; }
.v-no { color: #da8a72; }

.chip-msg { background: transparent; border-color: transparent; color: var(--c-text-dim); font-style: italic; }

.detail-row td { padding: 0 0.9rem 1rem; background: rgba(var(--rgb-gold), 0.08); }

.detail-panel {
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    background: var(--c-surface-0);
    padding: 0.9rem 1rem;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.4rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    padding-bottom: 0.65rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--c-border);
}

.detail-meta b { color: var(--c-text); font-weight: 500; margin-left: 0.3rem; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 0.55rem 1.5rem;
}

.detail-item { min-width: 0; }

.detail-item.wide { grid-column: 1 / -1; }

.detail-k {
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    color: var(--c-text-faint);
}

.detail-v {
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    color: var(--c-bone);
    word-break: break-word;
    white-space: pre-wrap;
}

.detail-v.code {
    font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
    font-size: var(--fs-xs);
    color: var(--c-text);
    background: rgba(var(--rgb-ash), 0.06);
    padding: 0.4rem 0.55rem;
    border-radius: 2px;
    max-height: 16rem;
    overflow: auto;
}

.detail-actions { margin-top: 0.8rem; display: flex; gap: 0.5rem; }

.detail-actions .btn { height: 2rem; padding: 0 0.8rem; }

.db-table td { font-family: var(--font-ui); font-size: var(--fs-sm); }

.db-table td.long {
    max-width: 34rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.db-table td.long.expanded { white-space: pre-wrap; word-break: break-word; }

/* BADGES */
.badge {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: var(--radius-cell);
    border: 1px solid rgba(var(--t-rgb, var(--rgb-ash)), 0.38);
    background: rgba(var(--t-rgb, var(--rgb-ash)), 0.13);
    color: var(--t-text, #a8a29a);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.4;
}

/* PAGINATION */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.page-info {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
    font-variant-numeric: tabular-nums;
    min-width: 12rem;
    text-align: center;
}

.result-head {
    font-family: var(--font-display);
    color: var(--c-gold-glow);
    font-size: var(--fs-sm);
    letter-spacing: var(--ls-tight);
    margin-bottom: 0.75rem;
}

/* PERMISSIONS */
.perm-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.4rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
    margin-bottom: 0.9rem;
}

.perm-legend span { display: inline-flex; align-items: center; gap: 0.45rem; }

.cell-mark {
    display: inline-block;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 2px;
    border: 1px solid var(--c-border-light);
}

.cell-mark.direct { background: var(--c-gold-glow); border-color: var(--c-gold-glow); }
.cell-mark.wildcard { background: rgba(var(--rgb-gold), 0.25); border-color: rgba(var(--rgb-gold), 0.6); }
.cell-mark.all { background: rgba(var(--rgb-mana), 0.35); border-color: rgba(var(--rgb-mana), 0.8); }

.perm-table td, .perm-table th { text-align: center; vertical-align: middle; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }

.perm-table th small {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
    letter-spacing: var(--ls-tight);
    font-weight: 500;
}

.perm-group td {
    background: var(--c-surface-3);
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    letter-spacing: var(--ls-normal);
    text-transform: uppercase;
    color: var(--c-gold);
    text-align: left !important;
    padding-top: 0.7rem;
}

.perm-name { color: var(--c-bone); }

.perm-key {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
}

.perm-tag {
    display: inline-block;
    margin-left: 0.4rem;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-warn);
    border: 1px solid rgba(var(--rgb-warn), 0.4);
    border-radius: 2px;
    padding: 0 0.3rem;
}

.perm-scope {
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
    cursor: help;
}

.perm-unmapped { margin-top: 1rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* SESSION WARNING */
.session-warning {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
    background: var(--c-surface-3);
    border: 1px solid rgba(var(--rgb-warn), 0.55);
    border-left: 3px solid var(--c-warn);
    border-radius: var(--radius);
    color: var(--c-text);
    font-size: var(--fs-sm);
    max-width: 28rem;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 0.55rem; height: 0.55rem; }
::-webkit-scrollbar-track { background: var(--c-surface-0); }
::-webkit-scrollbar-thumb { background: var(--c-border-light); border-radius: var(--radius-cell); }
::-webkit-scrollbar-thumb:hover { background: var(--c-gold-dim); }

/* RESPONSIVE */
@media (max-width: 80rem) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 60rem) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .col-player { width: 9rem; }
}

@media (max-width: 48rem) {
    body { flex-direction: column; }
    .sidebar { position: relative; width: 100%; height: auto; }
    .user-info { margin-top: 0; }
    .content { margin-left: 0; padding: 1.25rem 1rem 2rem; }
    .kpi-grid { grid-template-columns: minmax(0, 1fr); }
    .field-search input { min-width: 0; width: 100%; }
    .toolbar-filters, .field, .field-search { width: 100%; }
    .field select { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

@font-face {
    font-family: 'Font Awesome 7 Free';
    font-style: normal;
    font-weight: 900;
    font-display: block;
    src: url('../vendor/fonts/fa-solid-900.otf') format('opentype');
}

/* PAGER */
.pagination { flex-wrap: wrap; gap: 0.5rem; }
.pager-btn { width: 2.4rem; padding: 0; }
.pager-btn .icon { width: 1.05rem; height: 1.05rem; }

.page-jump {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-dim);
    margin: 0 0.35rem;
}

.page-jump input {
    width: 4.5rem;
    height: 2.4rem;
    text-align: center;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    color: var(--c-bone);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    -moz-appearance: textfield;
}

.page-jump input::-webkit-outer-spin-button,
.page-jump input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.page-jump input:focus { outline: none; border-color: var(--c-gold); }

.pagination .page-info { min-width: 0; margin-left: 0.5rem; color: var(--c-text-faint); }

.field input[type="datetime-local"] { color-scheme: dark; min-width: 12.5rem; }
.field input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* SCROLLABLE TABLES (wide database views, player sheets) */
.table-scroll {
    max-height: calc(100vh - 15rem);
    overflow: auto;
    overscroll-behavior: contain;
}

.table-scroll table { width: max-content; min-width: 100%; }
.table-scroll th, .table-scroll td { white-space: nowrap; }

.table-scroll th:first-child,
.table-scroll td:first-child,
.sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--c-surface-1);
    border-right: 1px solid var(--c-border);
}

.table-scroll thead th:first-child { z-index: 3; background: var(--c-surface-3); }
.table-scroll tr.open td:first-child { background: #1b1a17; }
.table-scroll .detail-row td:first-child { position: static; border-right: none; background: rgba(var(--rgb-gold), 0.08); }

.table-scroll .detail-row td { white-space: normal; }
.table-scroll .detail-panel { position: sticky; left: 0.9rem; max-width: min(90rem, calc(100vw - var(--sidebar-w) - 6rem)); }

.db-table td.long { white-space: nowrap; }

.cell-items { min-width: 20rem; white-space: normal !important; }

.item-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.item-list .chip { align-items: center; }

/* PLAYER SHEETS */
.profile-table td { font-family: var(--font-ui); font-size: var(--fs-md); vertical-align: middle; }
.profile-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--c-bone); }
.profile-table th { text-align: left; }
.profile-table .mono { letter-spacing: 0.04em; color: var(--c-text); }
.profile-table .cell-wide { min-width: 16rem; white-space: normal; }
.profile-table .cell-time { color: var(--c-text-dim); font-size: var(--fs-sm); }

.profile-name { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--c-bone); }

.online-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #8fbb93;
    flex: 0 0 auto;
}

/* PERMISSIONS EDITOR */
.perm-savebar {
    position: sticky;
    top: 0.75rem;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    background: var(--c-surface-3);
    border: 1px solid rgba(var(--rgb-warn), 0.55);
    border-left: 3px solid var(--c-warn);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    color: var(--c-text);
}

.perm-savebar span { margin-right: auto; }

.perm-role { min-width: 7rem; }
.perm-role > span { display: block; }

.perm-all {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.35rem;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    letter-spacing: var(--ls-tight);
    color: var(--c-text-dim);
    cursor: pointer;
    text-transform: none;
}

.perm-all input { accent-color: var(--c-gold); cursor: pointer; }
.perm-all input:disabled { cursor: not-allowed; }

.perm-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-cell);
    background: transparent;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.perm-toggle:hover:not(:disabled) { border-color: rgba(var(--rgb-gold), 0.5); background: rgba(var(--rgb-gold), 0.08); }
.perm-toggle:disabled { cursor: default; }
.perm-toggle.changed { border-color: var(--c-warn); background: rgba(var(--rgb-warn), 0.12); }
.perm-toggle .cell-mark.none { background: transparent; border-color: var(--c-border-light); }

/* MAP */
.page-map.active { display: flex; flex-direction: column; height: calc(100vh - 4.75rem); }

.map-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);
    gap: 1rem;
}

.map-side {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.map-panel {
    background: var(--c-surface-1);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;
}

#mapPlayersPanel { flex: 1 1 60%; }
#mapLayersPanel { flex: 0 1 auto; max-height: 40%; overflow-y: auto; }

.map-panel h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-display);
    color: var(--c-gold);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    font-weight: 600;
}

.map-panel .field-search input { min-width: 0; width: 100%; }

.map-player-list { list-style: none; overflow-y: auto; min-height: 0; flex: 1; margin: 0 -0.4rem; }

.map-player {
    padding: 0.45rem 0.4rem;
    border-radius: var(--radius-cell);
    cursor: pointer;
    border-left: 2px solid transparent;
}

.map-player:hover { background: rgba(var(--rgb-gold), 0.06); }
.map-player.active { background: rgba(var(--rgb-gold), 0.12); border-left-color: var(--c-gold-glow); }
.map-player.dead .map-player-name { color: #da8a72; }
.map-player-name { display: block; font-family: var(--font-ui); color: var(--c-bone); font-size: var(--fs-md); }

.map-layers { display: flex; flex-direction: column; gap: 0.15rem; }

.map-layer {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0.2rem;
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    color: var(--c-text);
    cursor: pointer;
    border-radius: var(--radius-cell);
}

.map-layer:hover { background: rgba(var(--rgb-gold), 0.06); }
.map-layer input { accent-color: var(--c-gold); cursor: pointer; }
.map-layer-name { flex: 1; }

.map-stage {
    position: relative;
    min-height: 0;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.map-canvas { position: absolute; inset: 0; background: #0a0a0a; }

.leaflet-container { background: #0a0a0a; font-family: var(--font-ui); }
.leaflet-bar a,
.leaflet-bar a:hover { background: var(--c-surface-3); color: var(--c-text); border-bottom-color: var(--c-border-light); }
.leaflet-bar { border: 1px solid var(--c-border-light) !important; }
.leaflet-bar a:hover { color: var(--c-gold-glow); }

.map-tip.leaflet-tooltip {
    background: var(--c-surface-4);
    border: 1px solid var(--c-border-light);
    border-top: 2px solid var(--c-gold);
    border-radius: var(--radius-cell);
    color: var(--c-text);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    line-height: 1.35;
}

.map-tip.leaflet-tooltip b { color: var(--c-bone); font-weight: 500; font-size: var(--fs-md); }
.map-tip.leaflet-tooltip span { color: var(--c-text-faint); }
.map-tip.leaflet-tooltip .tip-dead { color: #da8a72; }
.leaflet-tooltip-top.map-tip::before { border-top-color: var(--c-border-light); }

.map-pin-wrap { background: none; border: none; }

.map-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(12, 12, 12, 0.85);
    border: 1.5px solid var(--pin);
    color: var(--pin);
}

.map-pin i {
    font-family: 'Font Awesome 7 Free';
    font-weight: 900;
    font-style: normal;
    font-size: 12px;
    line-height: 1;
}

.map-player-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #8fbb93;
    border: 2px solid #0c0c0c;
}

.map-player-pin.dead { background: #da8a72; }
.map-player-pin.selected { background: #e8b04a; width: 26px; height: 26px; margin: -2px; }

.map-player-pin .arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 8px solid #0c0c0c;
    transform-origin: 50% 70%;
}

.map-notice {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    padding: 0.55rem 0.9rem;
    background: var(--c-surface-3);
    border: 1px solid rgba(var(--rgb-warn), 0.55);
    border-left: 3px solid var(--c-warn);
    border-radius: var(--radius-cell);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text);
    max-width: 80%;
}

.map-track {
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    z-index: 500;
    max-width: 34rem;
    padding: 0.8rem 1rem;
    background: rgba(18, 18, 18, 0.96);
    border: 1px solid var(--c-border-light);
    border-top: 2px solid #e8b04a;
    border-radius: var(--radius);
}

.map-track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.map-track-name { font-family: var(--font-display); color: var(--c-bone); letter-spacing: var(--ls-tight); }
.map-track-sub { font-family: var(--font-ui); font-size: var(--fs-sm); color: var(--c-text-faint); }

.map-track input[type="range"] { width: 100%; margin: 0.6rem 0 0.2rem; accent-color: #e8b04a; }

.map-track-time {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    font-variant-numeric: tabular-nums;
}

.map-track-time b { color: #e8b04a; font-weight: 500; }

@media (max-width: 60rem) {
    .page-map.active { height: auto; }
    .map-layout { grid-template-columns: minmax(0, 1fr); }
    .map-stage { height: 70vh; }
}

.level-bar {
    display: block;
    width: 3.5rem;
    height: 3px;
    margin: 0.3rem 0 0 auto;
    background: rgba(var(--rgb-ash), 0.18);
    border-radius: 2px;
    overflow: hidden;
}

.level-bar span { display: block; height: 100%; background: var(--c-gold-glow); }

.map-tip.leaflet-tooltip b.tip-val { font-size: var(--fs-sm); }

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.sort-btn:hover { color: var(--c-gold-glow); }

.sort-arrow {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    color: var(--c-text-faint);
    opacity: 0.55;
}

.sort-arrow.active { color: var(--c-gold-glow); opacity: 1; }

/* ITEMS */
.item-table td { font-family: var(--font-ui); font-size: var(--fs-md); vertical-align: middle; }
.item-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--c-bone); }
.item-table td.num.muted { color: var(--c-text-faint); }
.item-table .col-thumb { width: 3.4rem; padding-right: 0.2rem; }
.item-table tr.orphan .profile-name { color: #cfb06a; }

.item-desc-cell { min-width: 18rem; max-width: 30rem; white-space: normal !important; color: var(--c-text-dim); font-size: var(--fs-sm) !important; }

.item-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: var(--radius-cell);
    background: rgba(var(--rgb-ash), 0.08);
    border: 1px solid var(--c-border);
    overflow: hidden;
}

.item-thumb img { width: 100%; height: 100%; object-fit: contain; }
.item-thumb.big { width: 8rem; height: 8rem; }

.item-thumb.missing::after {
    content: "?";
    font-family: var(--font-display);
    color: var(--c-text-faint);
}

.item-detail { display: flex; gap: 1.25rem; align-items: flex-start; }
.item-detail-body { flex: 1; min-width: 0; }
.item-desc { margin-bottom: 0.8rem; color: var(--c-text); font-size: var(--fs-md); }

.item-holder-list { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }

.item-holder {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid rgba(var(--rgb-ash), 0.18);
    border-radius: var(--radius-cell);
    background: rgba(var(--rgb-ash), 0.06);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text);
    cursor: pointer;
}

.item-holder:hover:not(:disabled) { border-color: rgba(var(--rgb-gold), 0.55); color: var(--c-bone); }
.item-holder:disabled { cursor: default; }
.item-holder b { color: var(--c-gold-glow); font-weight: 500; }

.item-holder-kind {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-tight);
    color: var(--c-text-faint);
}

/* ALERTS, ECONOMY, STAFF */
.kpi-ok::before { background: linear-gradient(180deg, rgba(var(--rgb-ok), 0.95), rgba(var(--rgb-ok), 0)); }
.kpi-ok .kpi-value { color: #8fbb93; }
.kpi-warn::before { background: linear-gradient(180deg, rgba(var(--rgb-warn), 0.95), rgba(var(--rgb-warn), 0)); }
.kpi-warn .kpi-value { color: #cfb06a; }
.kpi-value.neg { color: #da8a72; }
.kpi-value.pos { color: #8fbb93; }

.alert-card { border-top: 2px solid rgba(var(--rgb-urgent), 0.7); }
.alert-card.calm { border-top-color: rgba(var(--rgb-ok), 0.6); }
.alert-types { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.85rem; }
.alert-types:empty { display: none; }
.alert-chip { cursor: pointer; font-family: var(--font-ui); }
.alert-chip b { color: var(--c-bone); font-weight: 600; margin-left: 0.35rem; }
.alert-chip:hover { filter: brightness(1.2); }

.field-inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.field-inline select { min-width: 8rem; height: 2.2rem; }

.page-note {
    margin: -0.4rem 0 0.9rem;
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
}

.card .sub-h { margin-top: 1.2rem; }

.mini-table td { font-family: var(--font-ui); font-size: var(--fs-sm); padding: 0.42rem 0.75rem; }
.mini-table th { padding: 0.45rem 0.75rem; }
.mini-table td.num, .mini-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table td.num { color: var(--c-bone); }
.mini-table td.in { color: #8fbb93; }
.mini-table td.out { color: #da8a72; }
.mini-table td.muted { color: var(--c-text-faint); }
.mini-table .kind {
    display: inline-block;
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-tight);
    color: rgb(var(--t-rgb, var(--rgb-ash)));
}
.mini-table tr.linkable { cursor: pointer; }
.mini-table tr.linkable:hover td { background: rgba(var(--rgb-gold), 0.05); }

.eco-col { gap: 2px; }
.eco-col .chart-bar { flex: 1 1 0; width: auto; }
.chart-bar.eco-in { background: linear-gradient(180deg, rgba(var(--rgb-ok), 0.95) 0%, rgba(var(--rgb-ok), 0.35) 100%); }
.chart-bar.eco-out { background: linear-gradient(180deg, rgba(var(--rgb-urgent), 0.95) 0%, rgba(var(--rgb-urgent), 0.35) 100%); }
.chart-bar.eco-admin { background: linear-gradient(180deg, rgba(var(--rgb-warn), 0.95) 0%, rgba(var(--rgb-warn), 0.35) 100%); }
.chart-col.hover .chart-bar.eco-in, .chart-col:hover .chart-bar.eco-in { background: #a9d0ad; }
.chart-col.hover .chart-bar.eco-out, .chart-col:hover .chart-bar.eco-out { background: #e39a82; }
.chart-col.hover .chart-bar.eco-admin, .chart-col:hover .chart-bar.eco-admin { background: #ddc48a; }

.staff-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.staff-table td.num button {
    font: inherit;
    color: var(--c-bone);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: var(--radius-cell);
}
.staff-table td.num button:hover { background: rgba(var(--rgb-gold), 0.12); color: var(--c-gold-glow); }
.staff-table td.zero { color: var(--c-text-faint); opacity: 0.5; }
.staff-table th .badge { font-family: var(--font-ui); letter-spacing: var(--ls-tight); text-transform: none; }
.staff-table td.total { color: var(--c-gold-glow); font-weight: 600; }
.icon-btn.done { color: #8fbb93; border-color: rgba(var(--rgb-ok), 0.6); }
.section-title {
    margin: 2rem 0 0.6rem;
    font-family: var(--font-display);
    font-size: var(--fs-sm);
    color: var(--c-gold);
    text-transform: uppercase;
    letter-spacing: var(--ls-normal);
    font-weight: 600;
}
.profile-table td.money-total { color: var(--c-gold-glow); }

/* INVENTORIES */
.inv-layout {
    display: grid;
    grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}
.inv-list .toolbar { margin-bottom: 0.6rem; }
.inv-list .field-search input { min-width: 0; width: 100%; }
.inv-list .toolbar-filters { flex-wrap: wrap; }
.inv-table tr.open td { background: rgba(var(--rgb-gold), 0.1); }
.check { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-ui); font-size: var(--fs-sm); color: var(--c-text-dim); cursor: pointer; }

.inv-view { position: sticky; top: 1rem; min-height: 20rem; }
.inv-view.loading { opacity: 0.55; }
.inv-empty { font-family: var(--font-ui); color: var(--c-text-faint); font-style: italic; padding: 1rem 0; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.5rem; }
.inv-head .detail-actions { margin-top: 0; }
.inv-title { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-display); font-size: var(--fs-lg); color: var(--c-bone); font-weight: 600; letter-spacing: var(--ls-tight); }
.inv-view > .detail-meta { margin-bottom: 0.9rem; }

.inv-grid {
    display: grid;
    gap: 3px;
    max-width: 44rem;
    padding: 6px;
    background: var(--c-surface-0);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
.inv-cell {
    aspect-ratio: 1;
    background: rgba(var(--rgb-ash), 0.06);
    border: 1px solid rgba(var(--rgb-ash), 0.1);
    border-radius: var(--radius-cell);
}
.inv-cell.extra { background: rgba(var(--rgb-warn), 0.05); }

.inv-item {
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-surface-3);
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    cursor: pointer;
    z-index: 1;
    transition: border-color 0.12s, background 0.12s;
}
.inv-item:hover { border-color: var(--c-gold); background: var(--c-surface-4); }
.inv-item.active { border-color: var(--c-gold-glow); background: rgba(var(--rgb-gold), 0.14); }
.inv-item.moved { border-style: dashed; border-color: rgba(var(--rgb-warn), 0.7); }
.inv-item.rarity-uncommon { border-color: rgba(var(--rgb-ok), 0.7); }
.inv-item.rarity-rare { border-color: rgba(var(--rgb-mana), 0.8); }
.inv-item.rarity-epic { border-color: #8f6fb8; }
.inv-item.rarity-legendary { border-color: #d08a3a; }

.inv-img { width: 78%; height: 78%; display: flex; align-items: center; justify-content: center; }
.inv-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.inv-img-fallback { font-family: var(--font-ui); font-size: var(--fs-sm); color: var(--c-text-faint); }

.inv-amount {
    position: absolute;
    right: 3px;
    bottom: 2px;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-bone);
    background: rgba(var(--rgb-black), 0.65);
    padding: 0 0.25rem;
    border-radius: 2px;
    line-height: 1.3;
}
.inv-quality { position: absolute; left: 3px; right: 3px; top: 3px; height: 3px; background: rgba(var(--rgb-ash), 0.25); border-radius: 2px; overflow: hidden; }
.inv-quality span { display: block; height: 100%; background: rgba(var(--rgb-ok), 0.9); }
.inv-quality span.low { background: rgba(var(--rgb-urgent), 0.9); }

.inv-note { margin-top: 0.5rem; font-family: var(--font-ui); font-size: var(--fs-sm); color: #cfb06a; }
.inv-grid-body {
    display: grid;
    grid-template-columns: minmax(0, 44rem) minmax(16rem, 1fr);
    gap: 1rem;
    align-items: start;
}
.inv-detail-slot { position: sticky; top: 1rem; min-width: 0; }
.inv-detail-hint {
    padding: 1rem;
    border: 1px dashed var(--c-border-light);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: var(--fs-sm);
    color: var(--c-text-faint);
    font-style: italic;
}
.inv-detail { padding: 0.8rem 1rem; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius); }
.inv-detail-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }
.inv-detail-head .inv-img { width: 3rem; height: 3rem; flex: 0 0 auto; }
.inv-detail-title { font-family: var(--font-ui); font-size: var(--fs-md); color: var(--c-bone); }
.inv-detail-desc { font-size: var(--fs-md); color: var(--c-text-dim); margin-bottom: 0.5rem; }
.inv-detail .chips { margin-top: 0.5rem; }

.inv-equipment { margin-top: 1.2rem; }
.inv-eq-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.4rem; }
.inv-eq { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--radius-cell); }
.inv-eq .inv-img { width: 2.2rem; height: 2.2rem; flex: 0 0 auto; }
.inv-eq-name { font-family: var(--font-ui); font-size: var(--fs-sm); color: var(--c-bone); }

@media (max-width: 70rem) {
    .inv-layout { grid-template-columns: minmax(0, 1fr); }
    .inv-view { position: static; }
}

@media (max-width: 80rem) {
    .inv-grid-body { grid-template-columns: minmax(0, 1fr); }
    .inv-detail-slot { position: static; }
}

/* ONLINE CHART */
.chart-bar.online { background: linear-gradient(180deg, rgba(var(--rgb-mana), 0.95) 0%, rgba(var(--rgb-mana), 0.35) 100%); }
.chart-col:hover .chart-bar.online, .chart-col.hover .chart-bar.online { background: #b6cde0; }
.hour-grid {
    display: grid;
    grid-template-columns: 2.4rem repeat(24, minmax(0, 1fr));
    gap: 2px;
    font-family: var(--font-ui);
    font-size: var(--fs-xs);
    color: var(--c-text-faint);
}
.hg-hour { text-align: left; }
.hg-day { align-self: center; }
.hg-cell { height: 1.1rem; border-radius: 2px; background: rgba(var(--rgb-mana), var(--a, 0.1)); }
.hg-cell.none { background: rgba(var(--rgb-ash), 0.06); }

/* SAVED SEARCHES */
.saved-wrap { display: inline-flex; align-items: center; gap: 0.4rem; }
.saved-wrap select {
    height: 2.2rem;
    max-width: 14rem;
    padding: 0 0.6rem;
    background: var(--c-surface-2);
    color: var(--c-text);
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    font-family: var(--font-ui);
}

/* STAFF EDITOR */
.btn-small { height: 1.8rem; padding: 0 0.7rem; margin-left: 0.6rem; font-size: var(--fs-xs); }
.staff-editor { margin-bottom: 1rem; }
.staff-editor code { font-family: ui-monospace, Consolas, monospace; color: var(--c-text); }
.staff-editor textarea, .note-form textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--c-surface-0);
    color: var(--c-bone);
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    font-family: ui-monospace, Consolas, monospace;
    font-size: var(--fs-sm);
    resize: vertical;
}

/* HEAT MAP */
.heat-controls { display: flex; gap: 0.4rem; }
.heat-controls select {
    flex: 1 1 auto;
    min-width: 0;
    height: 2.1rem;
    padding: 0 0.5rem;
    background: var(--c-surface-2);
    color: var(--c-text);
    border: 1px solid var(--c-border-light);
    border-radius: var(--radius-cell);
    font-family: var(--font-ui);
}
.heat-controls select#heatDays { flex: 0 0 6.5rem; }
.heat-note { margin-top: 0.4rem; font-family: var(--font-ui); font-size: var(--fs-xs); color: var(--c-text-faint); }

/* DUPLICATES */
.dupe-places { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.dupe-place { cursor: pointer; font-family: var(--font-ui); font-size: var(--fs-xs); color: var(--c-text); }
.dupe-place:hover { border-color: var(--c-gold); color: var(--c-gold-glow); }
.mini-table .mono { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-xs); letter-spacing: 0.02em; }

/* HISTORY */
.history-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 80rem) { .history-charts { grid-template-columns: minmax(0, 1fr); } }

/* DOSSIER */
.dossier-head { margin-bottom: 1rem; }
.dossier-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; align-items: start; margin-bottom: 1rem; }
.dossier-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dossier-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.6rem 1rem; }
.dossier-v { font-family: var(--font-ui); font-size: var(--fs-md); color: var(--c-bone); }
.dossier-v.in { color: #8fbb93; }
.dossier-sub { margin: 0.9rem 0 0.35rem; }
.dossier-inv .inv-grid-body { grid-template-columns: minmax(0, 1fr); }
.dossier-inv .inv-grid { max-width: none; margin-top: 0.5rem; }
.dossier-inv .detail-slot, .dossier-inv .inv-detail-slot { position: static; margin-top: 0.6rem; }
.dossier-inv > .btn { margin-top: 0.7rem; }
.alert-chip.is-alert { outline: 1px solid rgba(var(--rgb-urgent), 0.8); }
.note-list { display: flex; flex-direction: column; gap: 0.5rem; }
.note { padding: 0.55rem 0.75rem; background: var(--c-surface-2); border: 1px solid var(--c-border); border-left: 3px solid rgb(var(--t-rgb, var(--rgb-ash))); border-radius: var(--radius-cell); }
.note-head { display: flex; align-items: center; gap: 0.6rem; }
.note-head .player-cid { flex: 1 1 auto; margin: 0; }
.note-text { margin-top: 0.3rem; font-size: var(--fs-md); color: var(--c-text); white-space: pre-wrap; word-break: break-word; }
.note-form { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: 0.5rem; align-items: start; margin-top: 0.8rem; }
.note-form select { height: 2.3rem; padding: 0 0.5rem; background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border-light); border-radius: var(--radius-cell); font-family: var(--font-ui); }
.note-form textarea { font-family: var(--font-ui); font-size: var(--fs-md); }
@media (max-width: 80rem) {
    .dossier-grid { grid-template-columns: minmax(0, 1fr); }
    .note-form { grid-template-columns: minmax(0, 1fr); }
}

/* INVENTORY DIFF */
.inv-diff { margin-top: 1.2rem; max-width: 44rem; }
.inv-diff-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.inv-diff-head h3 { margin: 0; }
.inv-diff-head select { height: 2.1rem; padding: 0 0.5rem; background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border-light); border-radius: var(--radius-cell); font-family: var(--font-ui); }
