:root {
    --bg: #080808;
    --surface: #111112;
    --surface-soft: #171718;
    --line: #2b2b2d;
    --line-strong: #4a4a4e;
    --text: #f3f3f4;
    --muted: #8d8d92;
    --brand: #e31b23;
    --brand-dark: #ff2b33;
    --green: #36bf78;
    --amber: #d69d22;
    --shadow: 0 26px 80px rgba(0, 0, 0, .45);
}

body.tool-page {
    color: var(--text);
    background:
        radial-gradient(circle at 12% 2%, rgba(227, 27, 35, .08), transparent 30rem),
        #080808;
    font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

.tool-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 76px;
    padding: 12px clamp(16px, 4vw, 54px);
    border-bottom: 1px solid #303033;
    background: rgba(10, 10, 11, .96);
    backdrop-filter: blur(14px);
}

.tool-header::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), rgba(227, 27, 35, 0) 42%);
    content: "";
}

.brand { color: #fff; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 46px;
    height: 46px;
    border: 1px solid #57575b;
    border-radius: 0;
    background: #151516;
    color: #fff;
    letter-spacing: .04em;
}
.brand strong { font-size: 18px; }
.brand small { margin-top: 4px; color: var(--muted); }

.admin-link,
.secondary {
    border: 1px solid #525256;
    border-radius: 0;
    background: #121213;
    color: #d6d6d9;
}
.admin-link:hover,
.secondary:hover { border-color: #fff; background: #1a1a1b; color: #fff; }
.xml-user-bar { border-color: #363638; }
.xml-user-bar[hidden] { display: none; }
.xml-user-name { color: #fff; }
.xml-user-points {
    border: 1px solid #454549;
    border-radius: 0;
    background: #1b1b1c;
    color: #fff;
}

.xml-auth-shell {
    min-height: calc(100vh - 76px);
    background:
        linear-gradient(90deg, rgba(0, 0, 0, .92), rgba(0, 0, 0, .62)),
        radial-gradient(circle at 80% 40%, #19191c, #080808 62%);
}
.xml-auth-panel {
    border: 1px solid #343437;
    border-radius: 0;
    background: rgba(15, 15, 16, .96);
    box-shadow: var(--shadow);
}
.xml-auth-mark {
    border: 1px solid #5a5a5e;
    border-radius: 0;
    background: #171718;
    color: #fff;
}
.xml-auth-eyebrow { color: var(--brand); letter-spacing: .16em; }
.xml-auth-panel h1 { color: #fff; font-weight: 550; }
.xml-auth-copy { color: var(--muted); }
.xml-login-form label { color: #d5d5d8; font-weight: 600; }
.xml-login-form input,
.request-grid input,
.request-grid select,
.report-uploader input {
    border: 1px solid #47474b;
    border-radius: 0;
    background: #09090a;
    color: #fff;
    outline: 0;
}
.xml-login-form input:focus,
.request-grid input:focus,
.request-grid select:focus,
.report-uploader input:focus {
    border-color: #fff;
    box-shadow: inset 0 -2px var(--brand);
}
.xml-login-form button,
.tool-actions button:not(.secondary),
.report-uploader button,
.result-download {
    border-radius: 0;
    background: var(--brand);
    color: #fff;
}
.xml-login-form button:hover,
.tool-actions button:not(.secondary):hover,
.report-uploader button:hover,
.result-download:hover { background: var(--brand-dark); }
.xml-login-message {
    border-color: #703236;
    border-radius: 0;
    background: #211012;
    color: #ff9ca0;
}
.xml-back-link { color: #aaa; }
.xml-back-link:hover { color: #fff; }

.tool-shell { width: min(1560px, calc(100% - 40px)); margin: 24px auto; }
.tool-card {
    border: 1px solid #2d2d30;
    border-radius: 0;
    background: #0f0f10;
    box-shadow: var(--shadow);
}
.tabs { top: 76px; border-bottom: 1px solid #2b2b2d; background: #0f0f10; }
.tab {
    border: 1px solid #333336;
    border-radius: 0 !important;
    background: #171718;
    color: #909095;
    font-weight: 650;
}
.tab:hover { background: #1d1d1f; color: #fff; }
.tab.active {
    border-color: #5b5b60;
    border-bottom: 2px solid var(--brand);
    background: #101011;
    color: #fff;
}

.control-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 28px;
    padding: 26px 18px 20px;
}
.control-heading h1 { margin: 0; color: #fff; font-size: clamp(26px, 3vw, 38px); font-weight: 500; letter-spacing: -.03em; }
.control-eyebrow { margin: 0 0 9px; color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.control-heading > p { max-width: 570px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.token-panel {
    grid-template-columns: repeat(3, minmax(170px, 1fr)) minmax(180px, auto);
    gap: 0;
    margin: 0 18px;
    padding: 0;
    overflow: hidden;
    border: 1px solid #38383b;
    border-left: 3px solid #707075;
    border-radius: 0;
    background: #141415;
}
.token-panel > div {
    min-height: 78px;
    align-content: center;
    gap: 6px;
    padding: 14px 22px;
    border-right: 1px solid #333336;
}
.token-panel span { color: #85858a; font-size: 11px; }
.token-panel strong { color: #f5f5f6; font-size: 16px; font-variant-numeric: tabular-nums; }
.token-panel > button { min-width: 180px; margin: 14px 16px; border-color: var(--brand); background: var(--brand); color: #fff; }
.token-panel > button:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.token-panel > button:disabled { opacity: .62; cursor: wait; }
.token-panel.busy { border-color: #6d5724; border-left-color: var(--amber); background: #1b170e; }
.token-panel.ready { border-color: #27583c; border-left-color: var(--green); background: #101914; }
.token-panel.ready strong { color: #79dda6; }
.token-panel.expired,
.token-panel.failed { border-color: #6d2c30; border-left-color: #e24850; background: #1b1011; }

.brand-switch {
    gap: 10px;
    margin: 16px 18px 0;
    padding: 14px;
    border: 1px solid #2f2f32;
    border-radius: 0;
    background: #121213;
}
.brand-pill {
    min-width: 118px;
    min-height: 42px;
    border: 1px solid #48484c;
    border-radius: 0;
    background: #111112;
    color: #c7c7ca;
    font-weight: 650;
}
.brand-pill:hover { border-color: #8c8c91; background: #19191a; color: #fff; }
.brand-pill.active {
    border-color: var(--brand);
    background: #211315;
    color: #fff;
    box-shadow: inset 0 -2px var(--brand);
}

.tool-actions { margin: 14px 18px 28px; }
.tool-actions button { min-height: 46px; padding-right: 22px; padding-left: 22px; }
.form-section-title {
    margin: 0 18px 12px;
    padding-top: 24px;
    border-top: 1px solid #303033;
    color: #fff;
    font-size: 16px;
    font-weight: 550;
}
.request-grid {
    margin: 0 18px 20px;
    border: 1px solid #29292c;
    border-radius: 0;
    background: #131314;
}
.request-grid label { color: #d1d1d4; font-size: 15px; font-weight: 550; }

.report-uploader,
.result-panel { border: 1px solid #2d2d30; border-radius: 0; background: #131314; }
.report-summary { color: #c7c7ca; }
.report-table-wrap { border-color: #333336; border-radius: 0; }
.report-table { background: #111112; color: #d4d4d7; }
.report-table th { background: #1b1b1d; color: #fff; }
.report-table td { border-color: #29292c; }
.report-table tbody tr:hover { background: #1b1718; }
.empty-result { color: #7e7e83; }
.result-status { border-color: #27583c; border-radius: 0; background: #101914; color: #79dda6; }
.result-status.warn { border-color: #6d5724; background: #1b170e; color: #e5bd62; }
.result-status.running { border-color: #3e4f68; background: #111923; color: #8cb9ef; }
.result-table { background: #111112; color: #d7d7da; }
.result-table th { color: #8c8c91; }

@media (max-width: 900px) {
    .control-heading { align-items: flex-start; flex-direction: column; }
    .token-panel { grid-template-columns: 1fr 1fr; }
    .token-panel > button { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .tool-header { position: relative; min-height: 68px; }
    .tool-header-actions { width: auto; }
    .admin-link { display: none; }
    .tabs { top: 0; }
    .tool-shell { width: calc(100% - 18px); margin: 10px auto; }
    .control-heading { padding: 22px 8px 16px; }
    .token-panel,
    .brand-switch,
    .tool-actions,
    .request-grid,
    .form-section-title { margin-right: 8px; margin-left: 8px; }
    .token-panel { grid-template-columns: 1fr; }
    .token-panel > div { min-height: 66px; border-right: 0; border-bottom: 1px solid #333336; }
    .token-panel > button { grid-column: auto; }
    .brand-pill { min-width: calc(50% - 5px); }
    .tool-actions { flex-direction: column; }
    .tool-actions button { width: 100%; }
}
