* { box-sizing: border-box; }

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3f9;
    --line: #d8e1ec;
    --line-strong: #b8c7d8;
    --text: #16202c;
    --muted: #5e6b7b;
    --brand: #1769e8;
    --brand-dark: #0f4ca6;
    --green: #168a51;
    --amber: #b36b00;
    --shadow: 0 18px 42px rgba(29, 47, 78, .11);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.public-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 68px;
    padding: 12px clamp(18px, 4vw, 48px);
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #172438;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong { font-size: 18px; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 2px; }

.top-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}

.public-main {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
}

.download-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 500px);
    gap: clamp(24px, 5vw, 64px);
    align-items: center;
    min-height: calc(100vh - 140px);
    padding: clamp(28px, 6vw, 72px) 0;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p { overflow-wrap: anywhere; }

h1 {
    max-width: 760px;
    margin: 0;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.1;
    letter-spacing: 0;
}

h2 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

h3 {
    margin: 10px 0 8px;
    font-size: 18px;
}

.lead {
    max-width: 660px;
    margin: 18px 0 0;
    color: #334155;
    font-size: 18px;
    line-height: 1.75;
}

.note {
    max-width: 720px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.release-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.release-row span {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: #344256;
    padding: 7px 12px;
    font-size: 13px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.primary,
.secondary,
button,
.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: var(--brand);
    color: #fff;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.primary:hover,
button:hover,
.link-btn:hover {
    background: var(--brand-dark);
    color: #fff;
}

.secondary {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    color: #273549;
}

.secondary:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

.disabled {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    border-radius: 7px;
    background: #dfe6ef;
    color: #667486;
    padding: 10px 18px;
    font-weight: 700;
}

.product-visual {
    min-height: 430px;
}

.mock-window {
    overflow: hidden;
    border: 1px solid #c6d2df;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.mock-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.mock-title span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d5dde7;
}

.mock-title strong {
    margin-left: 6px;
    color: #39475a;
    font-size: 13px;
}

.mock-toolbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--line);
}

.mock-toolbar b {
    padding: 12px;
    color: #3c4c61;
    font-size: 13px;
    text-align: center;
    border-right: 1px solid var(--line);
}

.mock-toolbar b:last-child { border-right: 0; }

.mock-form {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.mock-form label {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fbfdff;
}

.mock-form small {
    color: var(--muted);
    font-size: 12px;
}

.mock-form span {
    color: #111827;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
}

.mock-result {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 18px 18px;
    border: 1px solid #a9d7bf;
    border-radius: 6px;
    background: #eef9f2;
    color: #176a32;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
}

.metric-strip div {
    background: var(--surface);
    padding: 18px;
}

.metric-strip span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric-strip strong {
    display: block;
    margin-top: 6px;
    font-size: 17px;
}

.section-block {
    padding: 52px 0 0;
}

.section-head {
    margin-bottom: 18px;
}

.brand-grid,
.steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.brand-card,
.steps div,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.brand-card {
    padding: 22px;
    font-size: 18px;
    font-weight: 800;
}

.steps div {
    padding: 20px;
}

.steps span {
    color: var(--amber);
    font-weight: 800;
    font-size: 13px;
}

.steps p {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.public-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: min(1180px, calc(100% - 36px));
    margin: 52px auto 0;
    padding: 24px 0 32px;
    color: #68788f;
    border-top: 1px solid var(--line);
}

.admin {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px;
}

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.admin h1 {
    margin: 0;
    font-size: 30px;
}

.panel {
    margin-bottom: 18px;
    padding: 18px;
}

.panel p {
    color: var(--muted);
    line-height: 1.7;
}

form {
    display: grid;
    gap: 12px;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 6px;
    font-size: 14px;
    color: #3c4858;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #c9d3df;
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 14px;
    background: #fff;
}

textarea { resize: vertical; }
.wide { grid-column: 1 / -1; }

.ok,
.err {
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

.ok { background: #e8f8ed; color: #176a32; }
.err { background: #ffebeb; color: #a02020; }

.log-table { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    border-bottom: 1px solid #e1e7ef;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.backend-info {
    margin-bottom: 10px;
}

.backend-info summary {
    cursor: pointer;
    color: #0f376f;
    font-weight: 700;
    margin-bottom: 6px;
}

.backend-info pre {
    background: #f7fbff;
    border: 1px solid #d9e6f5;
    border-radius: 7px;
    padding: 10px;
}

@media (max-width: 880px) {
    .public-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .top-actions {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .download-hero,
    .metric-strip,
    .brand-grid,
    .steps,
    .grid-form {
        grid-template-columns: 1fr;
    }

    .download-hero {
        min-height: auto;
    }

    .product-visual {
        min-height: auto;
    }

    .public-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .public-main,
    .public-footer {
        width: min(100% - 24px, 1180px);
    }

    .public-topbar {
        padding: 12px;
    }

    .mock-form label {
        grid-template-columns: 1fr;
    }

    .admin {
        padding: 16px;
    }
}

.tool-page {
    min-height: 100vh;
    background: #f6f8fb;
}

.tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 10px clamp(14px, 3vw, 28px);
    background: #fff;
    border-bottom: 1px solid #dfe5ed;
}

.admin-link {
    border: 1px solid #c9d3df;
    border-radius: 7px;
    color: #2d3a4d;
    padding: 8px 12px;
    font-size: 14px;
}

.tool-header-actions,
.xml-user-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.xml-user-bar {
    min-height: 40px;
    border-left: 1px solid var(--line);
    padding-left: 10px;
}

.xml-user-name {
    color: #172033;
    font-size: 14px;
    font-weight: 800;
}

.xml-user-points {
    border-radius: 999px;
    background: #eaf2ff;
    color: #1457b8;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 800;
}

.xml-logout {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 13px;
}

.xml-auth-hidden {
    display: none;
}

.xml-auth-shell {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 65px);
    padding: 28px 18px;
    background: #eef3f8;
}

.xml-auth-shell[hidden] {
    display: none;
}

.xml-auth-panel {
    display: grid;
    grid-template-columns: 88px minmax(260px, 1fr) minmax(320px, 430px);
    gap: 28px;
    align-items: center;
    width: min(1040px, 100%);
    border: 1px solid #cfd9e5;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(27, 45, 72, .12);
    padding: clamp(24px, 4vw, 44px);
}

.xml-auth-mark {
    display: grid;
    place-items: center;
    width: 76px;
    aspect-ratio: 1;
    border-radius: 8px;
    background: #1769e8;
    color: #fff;
    font-size: 18px;
    font-weight: 900;
}

.xml-auth-eyebrow {
    margin: 0 0 8px;
    color: #1769e8;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
}

.xml-auth-panel h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
}

.xml-auth-copy {
    max-width: 470px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.xml-login-form {
    gap: 14px;
}

.xml-login-form label {
    color: #2a3749;
    font-weight: 800;
}

.xml-login-form input {
    min-height: 44px;
    font-size: 16px;
}

.xml-login-form button {
    min-height: 46px;
}

.xml-login-message {
    display: none;
    grid-column: 3;
    border: 1px solid #e6c174;
    border-radius: 7px;
    background: #fff8e6;
    color: #8a5a00;
    padding: 10px 12px;
    font-size: 14px;
}

.xml-login-message.show {
    display: block;
}

.xml-back-link {
    grid-column: 3;
    color: #536176;
    font-size: 14px;
    font-weight: 700;
}

.tool-shell {
    width: min(1560px, calc(100% - 32px));
    margin: 18px auto;
}

.tool-card {
    min-height: calc(100vh - 104px);
    border: 1px solid #dfe5ed;
    border-radius: 8px;
    background: #fff;
    padding: 0 20px 20px;
}

.tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 14px 0 10px;
    background: #fff;
}

.tab {
    min-width: 120px;
    min-height: 36px;
    border: 1px solid transparent;
    border-radius: 0;
    background: #edf1f6;
    color: #283446;
    font-size: 16px;
    font-weight: 800;
    padding: 6px 18px;
}

.tab:first-child {
    border-radius: 7px 0 0 7px;
}

.tab:last-child {
    border-radius: 0 7px 7px 0;
}

.tab.active {
    border-color: #aeb8c6;
    background: #fff;
    color: #111827;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.form-section-title {
    margin: 6px 0 10px 18px;
    color: #293548;
    font-size: 14px;
    font-weight: 800;
}

.request-grid {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px 22px;
    border-radius: 8px;
    background: #f8fafc;
    padding: 18px;
}

.request-grid label {
    display: contents;
    color: #1f2937;
    font-size: 17px;
    font-weight: 800;
}

.request-grid input,
.request-grid select {
    min-height: 42px;
    border: 1px solid #c4ccd6;
    border-radius: 0;
    font-size: 16px;
    text-transform: uppercase;
}

.brand-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0 0;
    border-radius: 8px;
    background: #f8fafc;
    padding: 14px 18px;
}

.brand-pill {
    min-width: 112px;
    min-height: 36px;
    border: 1px solid #bac5d2;
    border-radius: 6px;
    background: #fff;
    color: #273549;
    font-size: 15px;
    font-weight: 800;
}

.brand-pill.active {
    border-color: var(--brand);
    background: #e9f1ff;
    color: var(--brand-dark);
}

.token-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) 150px;
    gap: 12px;
    align-items: stretch;
    margin: 18px 0 0;
    border: 1px solid #dfe6ef;
    border-radius: 8px;
    background: #fbfdff;
    padding: 14px 18px;
}

.token-panel > div {
    display: grid;
    gap: 4px;
    border-right: 1px solid #e4ebf3;
    padding-right: 12px;
}

.token-panel span {
    color: #657286;
    font-size: 12px;
    font-weight: 700;
}

.token-panel strong {
    color: #172033;
    font-size: 15px;
    line-height: 1.35;
}

.token-panel.ready {
    border-color: #a9d7bf;
    background: #f4fbf6;
}

.token-panel.ready strong {
    color: #176a32;
}

.token-panel.busy {
    border-color: #bdd0ec;
    background: #f0f6ff;
}

.token-panel.expired,
.token-panel.failed {
    border-color: #e6c174;
    background: #fff8e6;
}

.tool-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.ia-convert-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 7px 12px;
    border: 1px solid #343434;
    border-radius: 8px;
    background: #111;
    color: #f5f5f5;
    cursor: pointer;
}

.ia-convert-toggle input {
    width: 19px;
    height: 19px;
    margin: 0;
    accent-color: var(--brand);
}

.ia-convert-toggle span {
    display: grid;
    line-height: 1.25;
}

.ia-convert-toggle strong {
    font-size: 14px;
}

.ia-convert-toggle small {
    color: #a4a4a4;
    font-size: 12px;
}

.report-uploader {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 160px;
    gap: 12px;
    align-items: end;
    border-radius: 8px;
    background: #f8fafc;
    padding: 16px 18px;
}

.report-summary {
    margin: 14px 0;
    color: #3c4858;
    font-weight: 700;
}

.report-table-wrap {
    overflow: auto;
    max-height: calc(100vh - 260px);
    border: 1px solid #dfe5ed;
    border-radius: 8px;
}

.report-table {
    min-width: 1080px;
}

.report-table th {
    position: sticky;
    top: 0;
    background: #edf1f6;
    z-index: 2;
    color: #172033;
    font-size: 14px;
}

.report-table td {
    font-size: 14px;
    cursor: pointer;
}

.report-table tbody tr:hover {
    background: #f0f6ff;
}

.paste-import {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    border: 1px solid #dfe5ed;
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    background: #fbfdff;
    padding: 18px;
}

.paste-import-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
}

.paste-import-heading h2 {
    margin: 2px 0 0;
    color: #172033;
    font-size: 20px;
}

.paste-import-heading > p {
    margin: 0;
    color: #657286;
    font-size: 14px;
}

.paste-import textarea {
    width: 100%;
    min-height: 132px;
    resize: vertical;
    border: 1px solid #bac5d2;
    border-radius: 6px;
    background: #fff;
    color: #172033;
    font: 600 15px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    padding: 12px 14px;
}

.paste-import textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--brand) 28%, transparent);
    border-color: var(--brand);
}

.paste-import-actions,
.batch-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

#paste-message {
    color: #176a32;
    font-weight: 800;
}

#paste-message.error {
    color: #a33a2b;
}

.batch-toolbar {
    margin: 14px 0;
    border: 1px solid #dfe5ed;
    border-radius: 8px;
    background: #f8fafc;
    padding: 12px 14px;
}

.batch-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #273549;
    font-weight: 800;
}

.batch-toolbar input,
.batch-unit-check {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

#batch-progress {
    flex: 1 1 280px;
    color: #657286;
    font-size: 14px;
}

.batch-check-column {
    width: 70px;
    text-align: center;
}

.report-table tbody tr.selected {
    background: #edf5ff;
}

.report-table tbody tr.batch-success {
    background: #eff9f2;
}

.report-table tbody tr.batch-failed {
    background: #fff8e6;
}

.batch-unit-status {
    min-width: 76px;
    font-weight: 800;
}

.result-panel {
    border-radius: 8px;
    background: #f8fafc;
    min-height: 360px;
    padding: 18px;
}

.empty-result {
    display: grid;
    place-items: center;
    min-height: 320px;
    color: #6b7788;
    font-weight: 700;
}

.result-status {
    display: grid;
    gap: 6px;
    border: 1px solid #aed6bf;
    border-radius: 8px;
    background: #eef9f2;
    color: #176a32;
    padding: 14px;
}

.result-status strong {
    font-size: 20px;
}

.result-status.warn {
    border-color: #e0c27a;
    background: #fff8e6;
    color: #8a5a00;
}

.result-status.running {
    border-color: #b8c7d8;
    background: #eef4ff;
    color: #164c96;
}

.result-table {
    margin-top: 16px;
    background: #fff;
}

.result-table th {
    width: 160px;
    color: #536176;
}

.result-download {
    margin-top: 16px;
}

@media (max-width: 760px) {
    .tool-header {
        align-items: flex-start;
    }

    .tool-header-actions,
    .xml-user-bar {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .xml-user-bar {
        width: 100%;
        border-left: 0;
        padding-left: 0;
    }

    .xml-auth-panel {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .xml-login-message,
    .xml-back-link {
        grid-column: 1;
    }

    .tool-shell {
        width: min(100% - 18px, 1560px);
    }

    .tool-card {
        padding: 0 10px 16px;
    }

    .tabs {
        justify-content: flex-start;
        overflow-x: auto;
    }

    .tab {
        min-width: 104px;
        font-size: 15px;
    }

    .request-grid,
    .report-uploader,
    .token-panel {
        grid-template-columns: 1fr;
    }

    .paste-import-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .batch-toolbar button {
        flex: 1 1 150px;
    }

    .request-grid label {
        display: grid;
        gap: 6px;
    }

    .token-panel > div {
        border-right: 0;
        border-bottom: 1px solid #e4ebf3;
        padding: 0 0 10px;
    }
}
