:root {
    --bg: #edf1f5;
    --panel: #ffffff;
    --ink: #15202b;
    --muted: #687787;
    --line: #d7e0e8;
    --accent: #0f766e;
    --accent-dark: #0b5f59;
    --danger: #b91c1c;
    --success: #15803d;
    --shadow: 0 18px 45px rgba(22, 34, 45, .09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0 46px;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.back,
button.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
}

.user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.hero,
.panel,
.summary,
.group,
.stats-grid div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(22, 34, 45, .05);
}

.hero {
    padding: 26px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
}

.hero p {
    margin: 9px 0 0;
    color: var(--muted);
}

.panel {
    padding: 18px;
    margin-bottom: 14px;
}

.query {
    display: grid;
    grid-template-columns: 1fr 130px;
    gap: 10px;
}

.settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 240px));
    gap: 10px;
    margin-top: 12px;
}

.settings-row label {
    display: grid;
    grid-template-columns: 64px 1fr;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.settings-row input {
    height: 32px;
    padding: 0 8px;
    text-align: right;
}

.plan-query {
    display: grid;
    grid-template-columns: 1fr 120px 120px 150px;
    gap: 10px;
}

input,
button {
    height: 44px;
    border-radius: 8px;
    font: inherit;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    padding: 0 13px;
    background: #fff;
    color: var(--ink);
}

button {
    border: 0;
    background: var(--accent);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

button:hover {
    background: var(--accent-dark);
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.message {
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--muted);
    margin-bottom: 14px;
}

.message.error {
    border-color: #f3b4b4;
    background: #fff1f1;
    color: var(--danger);
}

.summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    margin-bottom: 14px;
}

.summary h2 {
    margin: 0 0 7px;
    font-size: 22px;
}

.product-summary {
    align-items: flex-start;
}

.product-summary h2 {
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.product-summary .meta {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.workflow {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.workflow-step {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    font-weight: 900;
}

.workflow-step span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #edf2f5;
    color: var(--muted);
    font-size: 13px;
}

.workflow-step.active {
    border-color: rgba(15, 118, 110, .35);
    background: #edf8f6;
    color: var(--accent-dark);
}

.workflow-step.active span {
    background: var(--accent);
    color: #fff;
}

.meta {
    color: var(--muted);
    font-size: 13px;
}

.score {
    text-align: right;
}

.score strong {
    display: block;
    font-size: 28px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.stats-grid div {
    padding: 15px;
}

.stats-grid strong {
    display: block;
    font-size: 24px;
}

.stats-grid span {
    color: var(--muted);
    font-size: 13px;
}

.group {
    overflow: hidden;
    margin-bottom: 14px;
}

.candidate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    padding: 14px;
}

.candidate {
    display: grid;
    grid-template-columns: 86px 1fr 104px;
    align-items: center;
    gap: 12px;
    min-height: 112px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.candidate img,
.candidate-empty {
    width: 86px;
    height: 86px;
    border-radius: 8px;
    background: #eef2f6;
    object-fit: cover;
}

.candidate strong,
.candidate span,
.candidate small {
    display: block;
}

.candidate strong {
    margin-bottom: 6px;
    line-height: 1.35;
}

.candidate span {
    color: var(--ink);
    font-weight: 900;
}

.candidate small {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.range-grid .candidate,
.stock-summary-grid .candidate {
    align-items: start;
}

.stock-summary .candidate small {
    line-height: 1.45;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.candidate button {
    width: 104px;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: #f8fafb;
    font-weight: 900;
}

.swatch {
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .16);
    background: #d9e0e6;
}

.table-scroll {
    overflow-x: auto;
}

.plan-table-scroll {
    overflow-x: visible;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.plan-table {
    table-layout: fixed;
    min-width: 0;
}

.plan-table th:first-child,
.plan-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 132px;
    box-shadow: 2px 0 8px rgba(22, 34, 45, .08);
}

.plan-table th,
.plan-table td {
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
}

.plan-table th:nth-child(1),
.plan-table td:nth-child(1) {
    width: 132px;
}

.plan-table th:nth-child(2),
.plan-table td:nth-child(2) {
    width: 23%;
}

.plan-table th:nth-child(4),
.plan-table td:nth-child(4),
.plan-table th:nth-child(5),
.plan-table td:nth-child(5),
.plan-table th:nth-child(6),
.plan-table td:nth-child(6),
.plan-table th:nth-child(7),
.plan-table td:nth-child(7) {
    width: 96px;
}

.plan-table th:first-child {
    z-index: 5;
    background: #fbfcfd;
}

.plan-table tbody tr:nth-child(odd) td {
    background: #ffffff;
}

.plan-table tbody tr:nth-child(even) td {
    background: #f4f7fa;
}

.plan-table tbody tr:hover td {
    background: #eaf3f2;
}

.plan-table tbody tr:nth-child(odd) td:first-child {
    background: #ffffff;
}

.plan-table tbody tr:nth-child(even) td:first-child {
    background: #f4f7fa;
}

.plan-table tbody tr:hover td:first-child {
    background: #eaf3f2;
}

.table-scroll table {
    min-width: 780px;
}

.option-table {
    min-width: 980px;
}

.store-table {
    min-width: 1800px;
}

.store-table th,
.store-table td {
    line-height: 1.45;
}

.store-table th:first-child,
.store-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 170px;
    box-shadow: 2px 0 8px rgba(22, 34, 45, .08);
}

.store-table th:first-child {
    z-index: 5;
    background: #fbfcfd;
}

.store-table tbody tr:nth-child(odd) td {
    background: #ffffff;
}

.store-table tbody tr:nth-child(even) td {
    background: #f4f7fa;
}

.store-table tbody tr:hover td {
    background: #eaf3f2;
}

.store-table tbody tr:nth-child(odd) td:first-child {
    background: #ffffff;
}

.store-table tbody tr:nth-child(even) td:first-child {
    background: #f4f7fa;
}

.store-table tbody tr:hover td:first-child {
    background: #eaf3f2;
}

.plan-table-scroll .plan-table {
    table-layout: fixed;
    min-width: 0;
}

th,
td {
    padding: 11px 14px;
    border-top: 1px solid #edf1f4;
    text-align: center;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 13px;
    background: #fbfcfd;
}

.ok {
    color: var(--success);
    font-weight: 900;
}

.no {
    color: var(--danger);
    font-weight: 900;
}

.hidden {
    display: none;
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 22px, 1180px);
        padding-top: 12px;
    }

    .nav,
    .summary {
        align-items: stretch;
        flex-direction: column;
    }

    .nav-links {
        align-items: stretch;
        flex-direction: column;
    }

    .query,
    .plan-query,
    .settings-row,
    .stats-grid,
    .workflow {
        grid-template-columns: 1fr;
    }

    .workflow-step {
        justify-content: flex-start;
    }

    .settings-row label {
        grid-template-columns: 64px 1fr;
    }

    .candidate {
        grid-template-columns: 72px 1fr;
    }

    .candidate img,
    .candidate-empty {
        width: 72px;
        height: 72px;
    }

    .candidate button {
        grid-column: 1 / -1;
        width: 100%;
    }

    .plan-table-scroll {
        overflow-x: auto;
    }

    .plan-table {
        table-layout: auto;
        min-width: 980px;
    }

    .plan-table-scroll .plan-table {
        table-layout: auto;
        min-width: 980px;
    }

    .plan-table th,
    .plan-table td {
        white-space: nowrap;
    }

    .score {
        text-align: left;
    }

    h1 {
        font-size: 26px;
    }
}

/* Shared layout and query states, October 2026. */
.stale-result { opacity: .55; }
.message button { margin: 6px 0 0 10px; }
.group-title { flex-wrap: wrap; }
.shared-stock .summary > div { min-width: 0; overflow-wrap: anywhere; }
.shared-stock .candidate-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.shared-stock .candidate { grid-template-columns: 86px minmax(0,1fr); grid-template-rows: 1fr auto; gap: 10px 14px; min-width: 0; align-items: start; }
.shared-stock .candidate > img, .shared-stock .candidate > .candidate-empty { grid-column: 1; grid-row: 1 / 3; object-fit: contain; }
.shared-stock .candidate > div:not(.candidate-empty) { grid-column: 2; grid-row: 1; min-width: 0; }
.shared-stock .candidate strong { overflow-wrap: anywhere; }
.shared-stock .candidate small { white-space: normal; }
.shared-stock .candidate small a { color: var(--muted); }
.shared-stock .candidate > button { grid-column: 2; grid-row: 2; justify-self: end; width: 112px; max-width: 100%; height: 38px; }
.shared-stock .settings-row { grid-template-columns: repeat(2,minmax(0,240px)); }
.shared-stock .settings-row label { min-width: 0; grid-template-columns: 48px minmax(0,1fr); }
.shared-stock .settings-row input { width: 100%; min-width: 0; }
.plan-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; }
.plan-controls label { display: grid; gap: 7px; flex: 1 1 155px; min-width: 0; font-size: 13px; color: var(--muted); }
.plan-controls .category-field { flex: 1 1 100%; }
.plan-controls input { width: 100%; min-width: 0; }
.plan-actions { display: flex; gap: 10px; }
.plan-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
.plan-secondary { margin: 12px 0; padding: 12px; background: #fff; border-radius: 8px; color: var(--muted); }
.plan-secondary summary { cursor: pointer; }
.table-hint { padding: 0 14px; color: var(--muted); font-size: 12px; }
.plan-table-scroll { overflow-x: auto; }
.plan-table-scroll .plan-table { table-layout: fixed; min-width: 1100px; }
.plan-table th, .plan-table td { white-space: normal; overflow-wrap: anywhere; }
.plan-table th:nth-child(1), .plan-table td:nth-child(1) { width: 132px; }
.plan-table th:nth-child(2), .plan-table td:nth-child(2) { width: 130px; }
.plan-table th:nth-child(3), .plan-table td:nth-child(3) { width: 240px; text-align: left; }
.plan-table th:nth-child(4), .plan-table td:nth-child(4) { width: 135px; }
.plan-table th:nth-child(5), .plan-table td:nth-child(5) { width: 100px; }
.plan-table th:nth-child(6), .plan-table td:nth-child(6), .plan-table th:nth-child(7), .plan-table td:nth-child(7), .plan-table th:nth-child(8), .plan-table td:nth-child(8) { width: 90px; }
.plan-table th:nth-child(9), .plan-table td:nth-child(9) { width: 80px; }
@media (max-width: 850px) { .shared-stock .candidate-grid { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 640px) {
  .nav { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .nav-links { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .nav .user { margin-left: auto; gap: 8px; font-size: 12px; }
  .nav button, .nav .back { padding: 8px 10px; }
  .hero { padding: 18px; }
  .hero h1 { font-size: 25px; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .shared-stock .candidate { grid-template-columns: 68px minmax(0,1fr); gap: 8px 12px; }
  .shared-stock .candidate > img, .shared-stock .candidate > .candidate-empty { width: 68px; height: 86px; }
  .shared-stock .settings-row { gap: 8px; }
  .shared-stock .settings-row label { padding: 0 8px; gap: 4px; grid-template-columns: 40px minmax(0,1fr); }
  .plan-actions { flex: 1 1 100%; }
  .plan-actions button { flex: 1; }
  .plan-controls label { flex-basis: 120px; }
}
