/* =============================================================================
   U10 Config Portal
   ============================================================================= */

:root {
    --bg: #0b0d17;
    --panel: #12152a;
    --panel-2: #181c36;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #e6e8f2;
    --muted: #98a0b8;
    --accent: #8b5cf6;
    --accent-2: #a78bfa;
    --accent-soft: rgba(139, 92, 246, 0.14);
    --good: #10b981;
    --warn: #f59e0b;
    --bad: #f43f5e;
    --radius: 14px;
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, 0.12), transparent 60%), var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
    min-height: 100vh;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 26px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
p { margin: 4px 0 0; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.strong { font-weight: 600; color: #fff; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* --- Buttons ---------------------------------------------------------------- */

.btn {
    appearance: none;
    border: 1px solid var(--line-strong);
    background: var(--panel-2);
    color: var(--text);
    font: 600 14px var(--font);
    padding: 9px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #7c4ff0; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* --- Inputs ----------------------------------------------------------------- */

input, select {
    font: 15px var(--font);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    padding: 8px 10px;
    width: 100%;
    min-width: 0;
}
input[type=number] { font-variant-numeric: tabular-nums; }
input.invalid, select.invalid, .has-error input, .has-error select, td.has-error input { border-color: var(--bad); background: rgba(244, 63, 94, 0.08); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.help { font-size: 12px; color: var(--muted); }
.form-error { color: #fda4af; font-size: 14px; margin: 0; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line-strong); border-radius: 26px; cursor: pointer; transition: background .15s; }
.slider::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch-inline input { width: auto; }

.range { display: flex; align-items: center; gap: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); border: 1px solid rgba(139, 92, 246, .35); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; }
.chip-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.chip-x:hover { color: #fff; }
.chip-input { border: 0; background: transparent; padding: 3px 4px; width: 90px; flex: 1; }
.chip-input:focus-visible { outline: none; }

/* --- Sign-in ---------------------------------------------------------------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.login-card .field span { font-size: 13px; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.brand h1 { font-size: 22px; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), #ec4899); font-weight: 700; color: #fff; letter-spacing: .5px; flex: none; }
.brand-small { margin: 0 0 18px; }
.brand-small .brand-mark { width: 38px; height: 38px; font-size: 13px; }
.brand-small > div { display: flex; flex-direction: column; min-width: 0; }
.brand-small .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Layout ----------------------------------------------------------------- */

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; color: var(--muted); font: 500 14px var(--font); padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #fff; }
.nav-icon { width: 20px; text-align: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); margin-left: auto; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.content { padding: 32px clamp(16px, 4vw, 48px) 120px; min-width: 0; }
.content-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.content-head > div:first-child { max-width: 760px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.status-pill.is-custom { color: #c4b5fd; border-color: rgba(139, 92, 246, .4); }

.section-body { display: flex; flex-direction: column; gap: 18px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.highlight { background: linear-gradient(135deg, rgba(139, 92, 246, .16), rgba(236, 72, 153, .06)), var(--panel); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h3 { margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 20px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

/* --- PLAY NOW tables -------------------------------------------------------- */

.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; }
.table-card { display: flex; flex-direction: column; gap: 16px; }
.table-card.is-locked { opacity: .7; }
.table-head { display: flex; align-items: center; gap: 10px; }
.stage { font-size: 12px; font-weight: 600; color: #c4b5fd; background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.table-name { font-size: 18px; font-weight: 700; background: transparent; border-color: transparent; padding: 4px 6px; }
.table-name:hover, .table-name:focus { border-color: var(--line-strong); background: var(--bg); }

.preview { background: var(--bg); border-radius: 10px; padding: 8px 12px; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.mini td, .mini th { padding: 4px 6px; font-size: 13px; }
.mini td.strong { color: var(--good); }
.table-scroll { overflow-x: auto; }

/* --- Levels ----------------------------------------------------------------- */

.levels td input { max-width: 130px; }
.levels-scroll { max-height: 560px; overflow: auto; }
.levels-scroll table { min-width: 700px; }
.levels-scroll td input { min-width: 84px; }
.card-head:has(.inline) { flex-wrap: wrap; gap: 8px 16px; }
.levels-scroll thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.levels tr.milestone td { background: var(--accent-soft); }
.levels tr.bad-row td { background: rgba(244, 63, 94, .12); }
.curve-form { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; padding: 14px; background: var(--bg); border-radius: 10px; }
.curve-key { font-size: 13px; font-weight: 600; color: var(--muted); }
.curve-row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.curve-row .inline input[type=number] { width: 90px; }
.curve-row input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.curve-actions { margin: 14px 0 0; }
.curve-actions p { margin: 0; }
.curve-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.curve-stat { display: flex; flex-direction: column; gap: 2px; background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.curve-stat-value { font-size: 22px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.tone-good { color: var(--good); }
.tone-warn { color: var(--warn); }
.tone-bad { color: var(--bad); }
.curve-chart { width: 100%; height: auto; display: block; }
.curve-chart .grid { stroke: var(--line); }
.curve-chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.curve-chart .unlock { stroke: var(--good); stroke-opacity: .5; stroke-dasharray: 2 4; }
.curve-chart .unlock-label { fill: #6ee7b7; }
.curve-chart .line-levels { fill: none; stroke: var(--accent-2); stroke-width: 2.5; stroke-linejoin: round; }
.curve-chart .line-fill { fill: none; stroke: #ec4899; stroke-width: 2; stroke-dasharray: 6 5; }
.curve-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.swatch { display: inline-block; width: 16px; height: 3px; border-radius: 2px; background: var(--accent-2); margin-right: 6px; vertical-align: middle; }
.swatch-dash { background: repeating-linear-gradient(90deg, #ec4899 0 5px, transparent 5px 9px); }
.swatch-unlock { background: var(--good); }
.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar-gap { flex: 1; }
.inline { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; color: var(--muted); }
.inline input { width: 100px; }

/* --- Overview --------------------------------------------------------------- */

.stats { display: flex; flex-wrap: wrap; gap: 28px; }
.stat { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: rgba(16, 185, 129, .15); color: #6ee7b7; }
.tag-warn { background: rgba(245, 158, 11, .15); color: #fcd34d; }
.audit { list-style: none; margin: 0; padding: 0; }
.audit li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.audit li:last-child { border-bottom: 0; }

/* --- Save bar, toast, dialog ------------------------------------------------ */

.savebar { position: fixed; left: 250px; right: 0; bottom: 0; padding: 14px clamp(16px, 4vw, 48px); background: rgba(18, 21, 42, .96); border-top: 1px solid rgba(139, 92, 246, .4); backdrop-filter: blur(8px); z-index: 20; }
.savebar-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.savebar-actions { margin-left: auto; display: flex; gap: 8px; }

.toast { position: fixed; top: 20px; right: 20px; max-width: min(420px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-strong); box-shadow: 0 12px 40px rgba(0, 0, 0, .4); z-index: 50; }
.toast-ok { border-color: rgba(16, 185, 129, .5); }
.toast-error { border-color: rgba(244, 63, 94, .6); }

.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog h3 { margin-bottom: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* --- Narrow screens --------------------------------------------------------- */

@media (max-width: 860px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; padding: 14px 16px; min-width: 0; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
    .preview { overflow-x: auto; }
    .nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
    .nav-item { white-space: nowrap; width: auto; }
    .sidebar-foot { flex-direction: row; align-items: center; justify-content: space-between; }
    .savebar { left: 0; }
    .tables { grid-template-columns: 1fr; }
    .content { padding: 20px 16px 140px; }
}

/* App builds */
.builds td { vertical-align: middle; }
.builds .tag { margin-left: 8px; }
.build-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.build-actions a.btn { text-decoration: none; }

/* Freeze reports */
.tag-bad { background: rgba(244, 63, 94, .15); color: #fda4af; }
.report-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.reports td { vertical-align: top; }
.reports tr.is-open td { background: var(--accent-soft); }
.report-summary { min-width: 220px; }
.report { margin-top: 16px; }
.report-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.report-head h3 { margin: 0; font-size: 17px; }
.report h4 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.report-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 14px 0 0; }
.report-facts dt { color: var(--muted); }
.report-facts dd { margin: 0; overflow-wrap: anywhere; }
.report-state { display: flex; flex-wrap: wrap; gap: 6px; }
.state-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.report pre { background: #070912; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; overflow: auto; font-size: 12px; line-height: 1.5; }
.report-crumbs { max-height: 460px; }
.report-errors { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.report-errors pre { margin-top: 6px; }
.nav-item .count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); }

/* Legal documents, credits and problem reports */
.grid-wide { grid-template-columns: 1fr; }
.text-input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: inherit; font: inherit; }
.text-block { display: flex; flex-direction: column; gap: 6px; }
.text-area { width: 100%; min-height: 120px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: inherit; font: inherit; line-height: 1.5; resize: vertical; box-sizing: border-box; }
.text-area.mono { font-family: ui-monospace, Consolas, monospace; }
.credits-editor { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.credit-name { max-width: 320px; font-weight: 600; }
/* Card faces */
.cosmetic-prices { margin-top: 14px; }
.cosmetic-pack { margin-top: 14px; }
.cosmetic-pack summary { cursor: pointer; color: var(--accent-2); margin-bottom: 10px; }
.cosmetic-prices.has-error .skin-tiers { outline: 1px solid var(--bad); }
.cosmetic-prices .card-head { flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.skin-tiers td input { max-width: 110px; min-width: 76px; }
.cosmetic-cards { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.skin-grid-scroll { overflow-x: auto; padding-bottom: 4px; }
.skin-grid { display: flex; flex-direction: column; gap: 4px; min-width: 640px; }
.skin-row { display: grid; grid-template-columns: 28px repeat(13, minmax(0, 1fr)); gap: 4px; }
.skin-row-label { display: grid; place-items: center; font-size: 18px; color: var(--muted); }
.skin-row-label.is-red, .skin-cell.is-red .skin-name { color: #fb7185; }
.skin-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: inherit; font: inherit; cursor: pointer; min-width: 0; }
.skin-cell:hover { border-color: var(--accent-2); }
.skin-cell.is-open { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.skin-cell.is-off { opacity: .5; }
.skin-cell.has-error { border-color: var(--bad); background: rgba(244, 63, 94, .12); }
.skin-name { font-weight: 600; font-size: 13px; }
.skin-price { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.skin-marks { position: absolute; bottom: 2px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.skin-mark { font-size: 9px; line-height: 1; padding: 1px 3px; border-radius: 4px; font-weight: 700; }
.mark-price { background: var(--accent-soft); color: var(--accent-2); }
.mark-offer { background: rgba(34, 197, 94, .18); color: #86efac; }
.mark-sale { background: rgba(251, 191, 36, .18); color: #fbbf24; }
.skin-editor { border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px; background: rgba(255, 255, 255, .02); }
.skin-editor.has-error { border-color: var(--bad); }
.skin-editor .card-head { flex-wrap: wrap; gap: 8px; }
.skin-editor h4 { margin: 0; }
.problems { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.problem-text { white-space: pre-wrap; margin: 6px 0 10px; }
/* Player reports */
.report-filter { max-width: 180px; }
.report-player .toolbar { margin-top: 6px; flex-wrap: wrap; }
.report-player.is-open { border-left: 3px solid var(--bad); }
.report-status { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line-strong); }
.report-status.status-open { color: #fff; background: var(--bad); border-color: var(--bad); }
.report-details { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.report-entry { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .03); }

/* Weekly challenges */
.challenges { display: flex; flex-direction: column; gap: 14px; }
.week-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.week-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 112px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.week-chip:hover { border-color: var(--accent-2); }
.week-chip.is-past { opacity: .55; }
.week-chip.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.week-chip.is-set .tag { color: #86efac; }
.week-chip.is-selected { background: var(--accent-soft); border-color: var(--accent-2); }
.week-input { max-width: 260px; }
.challenge-card.has-error { border-color: #f43f5e; }
.switch-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.switch-row input[type=checkbox] { width: auto; flex: none; }

.challenge-card.cat-event { border-left: 4px solid #a78bfa; }
.challenge-card.cat-weekly { border-left: 4px solid #fbbf24; }
.match-conditions { margin-top: 12px; }
.match-conditions summary { cursor: pointer; color: var(--accent-2); margin-bottom: 10px; }
.template-select { max-width: 280px; }

/* Trophies & seasons */
.toast-warn { border-color: rgba(245, 158, 11, .6); }
.trophies { display: flex; flex-direction: column; gap: 16px; }
.season-form { border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.season-row { display: flex; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.season-pic { width: 240px; height: 80px; border-radius: 10px; overflow: hidden; background: var(--panel-2); display: flex; align-items: center; justify-content: center; flex: none; }
.season-pic img { width: 100%; height: 100%; object-fit: cover; }
.season-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.season-info .toolbar { margin: 4px 0 0; gap: 8px; }
.trophies td .text-input, .trophies td input[type=number] { min-width: 80px; }
.trophies td select { min-width: 130px; }
