:root {
    --panel-radius: 8px;
    --line: #dbe4ef;
    --ink: #1e293b;
    --muted: #64748b;
    --primary: #0e7490;
    --primary-dark: #155e75;
    --accent: #b45309;
}

* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.tool-shell {
    min-height: calc(100vh - 64px);
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(241, 245, 249, 0.98)),
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.035) 0, rgba(15, 23, 42, 0.035) 1px, transparent 1px, transparent 64px),
        repeating-linear-gradient(0deg, rgba(15, 23, 42, 0.025) 0, rgba(15, 23, 42, 0.025) 1px, transparent 1px, transparent 64px);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(135deg, #12355b, #0e7490 58%, #b45309);
    box-shadow: 0 10px 24px rgba(14, 116, 144, 0.18);
}

.brand-mark svg {
    width: 21px;
    height: 21px;
}

.nav-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.nav-pill.active {
    background: white;
    color: #0e7490;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.phase-mini {
    width: min(100%, 360px);
    height: 118px;
    border: 1px solid var(--line);
    border-radius: var(--panel-radius);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 12px;
}

.phase-mini svg {
    width: 100%;
    height: 100%;
}

.phase-axis {
    stroke: #94a3b8;
    stroke-width: 1.4;
}

.phase-dome {
    fill: rgba(14, 116, 144, 0.08);
    stroke: #0e7490;
    stroke-width: 2.4;
}

.phase-line {
    fill: none;
    stroke: #b45309;
    stroke-width: 1.6;
    stroke-dasharray: 4 4;
}

.phase-point {
    fill: #b45309;
}

.phase-mini text {
    fill: #64748b;
    font-size: 10px;
    font-weight: 600;
}

.panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--panel-radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.tool-shell aside,
.tool-shell section,
.tool-shell .grid {
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px 18px 14px;
    border-bottom: 1px solid #e8eef6;
}

.panel-head h2 {
    margin: 0;
    color: #0f172a;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0;
}

.panel-head p {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.input-block {
    margin: 18px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: var(--panel-radius);
    background: #f8fafc;
}

.block-title {
    margin-bottom: 12px;
    color: #12355b;
    font-size: 13px;
    font-weight: 800;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.field-input,
.field-select {
    width: 100%;
    height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    padding: 0 11px;
    color: #0f172a;
    font-size: 14px;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.field-input:focus,
.field-select:focus {
    border-color: #0e7490;
    box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

.primary-btn,
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}

.primary-btn {
    margin: 0 18px 4px;
    width: calc(100% - 36px);
    max-width: calc(100% - 36px);
    border: 1px solid #0e7490;
    background: linear-gradient(135deg, #0e7490, #12355b);
    color: white;
    box-shadow: 0 12px 24px rgba(14, 116, 144, 0.18);
}

.primary-btn.w-full {
    width: calc(100% - 36px);
}

.primary-btn:hover,
.secondary-btn:hover {
    transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.primary-btn svg,
.secondary-btn svg {
    width: 16px;
    height: 16px;
}

.secondary-btn {
    border: 1px solid #cbd5e1;
    background: white;
    color: #334155;
    padding: 0 12px;
}

.example-btn {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: white;
    color: #334155;
    padding: 7px 9px;
    text-align: left;
    font-size: 12px;
    line-height: 1.25;
    font-weight: 700;
    white-space: normal;
    overflow-wrap: anywhere;
}

.example-btn:hover {
    border-color: #0e7490;
    color: #0e7490;
}

.sat-tool {
    margin: 18px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.sat-tool .grid {
    grid-template-columns: 88px minmax(0, 1fr) 80px;
}

.sidebar-section {
    margin: 18px;
    min-width: 0;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.summary-card {
    min-height: 86px;
    border: 1px solid #e2e8f0;
    border-radius: var(--panel-radius);
    background: linear-gradient(180deg, #f8fafc, #ffffff);
    padding: 14px;
}

.summary-card span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.summary-card strong {
    display: block;
    margin-top: 12px;
    color: #0f172a;
    font-size: 20px;
    line-height: 1.1;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    padding: 0 18px 18px;
}

.result-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    min-width: 0;
}

.result-table.compact {
    min-width: 0;
}

.result-table th:nth-child(1),
.result-table td:nth-child(1) {
    width: 28%;
}

.result-table th:nth-child(2),
.result-table td:nth-child(2) {
    width: 14%;
}

.result-table th:nth-child(3),
.result-table td:nth-child(3) {
    width: 31%;
}

.result-table th:nth-child(4),
.result-table td:nth-child(4) {
    width: 27%;
}

.result-table.compact th:nth-child(1),
.result-table.compact td:nth-child(1) {
    width: 31%;
}

.result-table.compact th:nth-child(2),
.result-table.compact td:nth-child(2),
.result-table.compact th:nth-child(3),
.result-table.compact td:nth-child(3),
.result-table.compact th:nth-child(4),
.result-table.compact td:nth-child(4) {
    width: 23%;
}

.result-table th {
    height: 38px;
    border-bottom: 1px solid #dbe4ef;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    white-space: normal;
}

.result-table td {
    height: 40px;
    border-bottom: 1px solid #eef2f7;
    color: #1e293b;
    font-size: 13px;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
}

.result-table td:nth-child(3),
.result-table.compact td:not(:first-child) {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.result-table td:nth-child(4) {
    color: #475569;
    font-size: 12px;
    line-height: 1.35;
}

.result-table.compact td {
    font-size: 12.5px;
}

.property-section h3,
.property-section summary {
    color: #12355b;
    font-size: 13px;
    font-weight: 800;
}

.property-section summary {
    cursor: pointer;
    list-style-position: inside;
}

.empty-cell {
    padding: 24px 0;
    color: #94a3b8 !important;
    text-align: center !important;
}

.info-list {
    display: grid;
    gap: 10px;
    padding: 18px;
    color: #334155;
    font-size: 13px;
    line-height: 1.6;
}

.explain-list {
    display: grid;
    gap: 10px;
    padding: 18px;
    color: #334155;
    font-size: 13px;
    line-height: 1.7;
    counter-reset: explain;
}

.explain-list li {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 8px;
}

.explain-list li::before {
    counter-increment: explain;
    content: counter(explain);
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    background: #e0f2fe;
    color: #0e7490;
    font-size: 12px;
    font-weight: 800;
}

.validation-table {
    width: 100%;
    min-width: 1060px;
    border-collapse: collapse;
}

.validation-table th {
    height: 38px;
    border-bottom: 1px solid #dbe4ef;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
}

.validation-table td {
    border-bottom: 1px solid #eef2f7;
    padding: 10px 8px;
    color: #1e293b;
    font-size: 13px;
    line-height: 1.45;
    vertical-align: top;
}

.validation-table td:nth-child(4),
.validation-table td:nth-child(5),
.validation-table td:nth-child(6),
.validation-table td:nth-child(8) {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid #e8eef6;
}

.filter-btn {
    min-height: 30px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: white;
    color: #475569;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 800;
}

.filter-btn.active,
.filter-btn:hover {
    border-color: #8bd3e6;
    background: #ecfeff;
    color: #0e7490;
}

.mini-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: #0e7490;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.mini-link:hover {
    border-color: #0e7490;
    background: #f0fdfa;
}

.info-list li {
    position: relative;
    padding-left: 18px;
}

.info-list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.72em;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #0e7490;
}

.info-list.muted li::before {
    background: #b45309;
}

.alert {
    border: 1px solid #fecaca;
    border-radius: var(--panel-radius);
    background: #fff1f2;
    color: #991b1b;
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.6;
}

.rankine-flow {
    width: min(100%, 560px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.flow-node {
    min-height: 74px;
    border: 1px solid var(--line);
    border-radius: var(--panel-radius);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 12px;
    color: #12355b;
    font-size: 16px;
    font-weight: 800;
}

.flow-node span {
    display: block;
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.3;
}

.rankine-static-state {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.rankine-static-state span,
.scan-preview {
    border: 1px solid #dbe4ef;
    border-radius: 8px;
    background: white;
    padding: 10px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.scan-preview {
    margin-top: 12px;
}

.scan-preview span {
    display: block;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.scan-preview strong {
    display: block;
    margin-top: 5px;
    color: #0f172a;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.primary-btn.rankine-submit {
    margin-bottom: 14px;
}

.rankine-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 18px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.rankine-actions .secondary-btn {
    width: 100%;
}

.task-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 18px 18px 12px;
}

.task-summary div {
    border: 1px solid #e2e8f0;
    border-radius: var(--panel-radius);
    background: #f8fafc;
    padding: 14px;
}

.task-summary b,
.task-summary span {
    display: block;
}

.task-summary b {
    color: #12355b;
    font-size: 14px;
}

.task-summary span {
    margin-top: 8px;
    color: #475569;
    font-size: 13px;
    line-height: 1.45;
}

.constraint-note {
    margin: 0 18px 18px;
    border: 1px solid #bae6fd;
    border-radius: var(--panel-radius);
    background: #f0f9ff;
    color: #0f3f5f;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.6;
    font-weight: 700;
}

.rankine-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 18px;
}

.chart-wrap {
    padding: 0 18px 18px;
}

.rankine-chart {
    width: 100%;
    height: auto;
    min-height: 260px;
    border: 1px solid #e2e8f0;
    border-radius: var(--panel-radius);
    background: white;
}

.chart-axis {
    stroke: #94a3b8;
    stroke-width: 1.2;
}

.chart-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
}

.chart-label {
    fill: #64748b;
    font-size: 11px;
    font-weight: 700;
}

.rankine-table,
.state-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    min-width: 0;
}

.state-table {
    min-width: 1040px;
}

.rankine-table th,
.state-table th {
    height: 38px;
    border-bottom: 1px solid #dbe4ef;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    white-space: normal;
}

.rankine-table td,
.state-table td {
    min-height: 40px;
    border-bottom: 1px solid #eef2f7;
    color: #1e293b;
    font-size: 12.5px;
    line-height: 1.35;
    padding: 10px 6px;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.state-table th:nth-child(n+4),
.state-table td:nth-child(n+4) {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: keep-all;
}

.rankine-table tbody tr {
    cursor: pointer;
}

.rankine-table tbody tr:hover,
.rankine-table tbody tr.selected {
    background: #ecfeff;
}

.rankine-table tbody tr.best {
    box-shadow: inset 3px 0 0 #b45309;
}

.rankine-table tbody tr.best td:last-child {
    color: #92400e;
    font-weight: 800;
}

.rankine-table td:not(:first-child),
.state-table td:nth-child(n+4):nth-child(-n+9) {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.rankine-table th:nth-child(1),
.rankine-table td:nth-child(1) {
    width: 5%;
}

.rankine-table th:nth-child(2),
.rankine-table td:nth-child(2),
.rankine-table th:nth-child(3),
.rankine-table td:nth-child(3) {
    width: 11%;
}

.rankine-table th:nth-child(n+4),
.rankine-table td:nth-child(n+4) {
    width: 10.4%;
}

.state-table th:nth-child(1),
.state-table td:nth-child(1) {
    width: 7%;
}

.state-table th:nth-child(2),
.state-table td:nth-child(2),
.state-table th:nth-child(10),
.state-table td:nth-child(10) {
    width: 12%;
}

.state-table th:nth-child(3),
.state-table td:nth-child(3) {
    width: 17%;
}

.state-table th:nth-child(n+4):nth-child(-n+9),
.state-table td:nth-child(n+4):nth-child(-n+9) {
    width: 8.5%;
}

.state-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 18px 18px 0;
}

.state-card {
    min-width: 0;
    border: 1px solid #dbe4ef;
    border-radius: var(--panel-radius);
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    padding: 14px;
}

.state-card.muted {
    grid-column: 1 / -1;
    color: #94a3b8;
    text-align: center;
}

.state-card-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.state-card-title span {
    color: #0e7490;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.state-card-title strong {
    color: #0f172a;
    font-size: 14px;
    line-height: 1.3;
    text-align: right;
}

.state-card-phase {
    display: inline-flex;
    margin-top: 10px;
    min-height: 24px;
    align-items: center;
    border-radius: 999px;
    background: #ecfeff;
    color: #0e7490;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
}

.state-card dl {
    display: grid;
    gap: 7px;
    margin-top: 12px;
}

.state-card dl div {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
}

.state-card dt {
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.state-card dd {
    color: #1e293b;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.35;
    text-align: right;
    overflow-wrap: anywhere;
}

.check-list {
    display: grid;
    gap: 10px;
    padding: 18px;
    color: #334155;
    font-size: 13px;
    line-height: 1.55;
}

.check-list li {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
}

.check-list .check-group {
    display: block;
    margin-top: 2px;
    padding: 7px 0 1px;
    color: #12355b;
    font-size: 12px;
    font-weight: 900;
}

.check-list span {
    min-height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dcfce7;
    color: #166534;
    font-size: 11px;
    font-weight: 800;
}

.check-list li.warn span {
    background: #fef3c7;
    color: #92400e;
}

.teacher-mode .rankine-full-table,
.teacher-mode .rankine-teaching-block {
    display: none;
}

.teacher-mode .rankine-chart {
    min-height: 320px;
}

@media (max-width: 900px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rankine-flow,
    .task-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rankine-summary-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 560px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .rankine-flow,
    .task-summary,
    .rankine-static-state,
    .state-card-grid {
        grid-template-columns: 1fr;
    }

    .panel-head {
        padding: 16px 14px 12px;
    }

    .input-block {
        margin: 14px;
    }

    .primary-btn {
        margin: 0 14px 4px;
        width: calc(100% - 28px);
    }
}
