:root {
    --ink: #1d252c;
    --muted: #667481;
    --line: #d9e1e7;
    --paper: #ffffff;
    --page: #f4f7f8;
    --green: #286f5a;
    --blue: #2866a6;
    --amber: #b98321;
    --red: #c2413d;
    --graphite: #2d3540;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--page);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

a {
    text-decoration: none;
}

.app-shell {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.nav-inner {
    max-width: 1240px;
    margin: 0 auto;
    min-height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    color: var(--ink);
    font-weight: 750;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    color: white;
    background: linear-gradient(135deg, var(--green), var(--blue));
    font-size: 0.8rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--muted);
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 0.94rem;
}

.nav-links a:hover {
    color: var(--ink);
    background: #edf2f4;
}

.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px;
}

.flash-stack {
    margin-bottom: 14px;
}

.hero-band {
    position: relative;
    min-height: 245px;
    overflow: hidden;
    border-radius: 8px;
    display: flex;
    align-items: end;
    background: var(--graphite);
    margin-bottom: 20px;
}

.hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.58;
}

.hero-content {
    position: relative;
    max-width: 760px;
    padding: 36px;
    color: white;
}

.hero-content h1 {
    font-size: clamp(2rem, 5vw, 4.6rem);
    line-height: 1;
    margin: 8px 0 12px;
    letter-spacing: 0;
}

.hero-content p {
    max-width: 620px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.05rem;
}

.mini-label {
    display: inline-block;
    color: #d6f0df;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.metric {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric span {
    display: block;
    font-size: 2rem;
    font-weight: 780;
    color: var(--green);
}

.metric small {
    color: var(--muted);
}

.layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.25fr);
    gap: 20px;
    align-items: start;
}

.rules-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.75fr);
    margin-bottom: 20px;
}

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 8px 24px rgba(29, 37, 44, 0.04);
}

.panel + .panel {
    margin-top: 20px;
}

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

.panel-head h1,
.panel-head h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
    letter-spacing: 0;
}

.panel-head p {
    margin: 0;
    color: var(--muted);
}

.inline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.drop-zone {
    min-height: 190px;
    border: 2px dashed #9fb3bf;
    background: #f7fafb;
    border-radius: 8px;
    display: grid;
    place-items: center;
    text-align: center;
    cursor: pointer;
    padding: 26px;
    margin-bottom: 14px;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--green);
    background: #eef7f2;
}

.drop-zone input {
    display: none;
}

.drop-title,
.drop-subtitle {
    display: block;
}

.drop-title {
    font-size: 1.25rem;
    font-weight: 750;
}

.drop-subtitle {
    color: var(--muted);
    margin-top: 6px;
}

.precheck-list {
    display: grid;
    gap: 10px;
    margin: 12px 0;
}

.precheck-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--green);
    border-radius: 8px;
    padding: 12px;
    background: #fcfdfd;
}

.precheck-card.has-error {
    border-left-color: var(--red);
}

.precheck-card.has-warning {
    border-left-color: var(--amber);
}

.precheck-title {
    font-weight: 760;
    margin-bottom: 4px;
}

.precheck-meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.issue-list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.error-list li {
    color: var(--red);
}

.warning-list li {
    color: #8a6118;
}

.job-list {
    display: grid;
    gap: 10px;
}

.job-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    align-items: center;
}

.job-title {
    font-weight: 740;
    overflow-wrap: anywhere;
}

.job-meta,
.job-message {
    color: var(--muted);
    font-size: 0.9rem;
}

.thin-progress {
    height: 7px;
    margin: 8px 0;
    background: #edf2f4;
}

.progress-bar {
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.job-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.78rem;
    font-weight: 760;
    color: var(--graphite);
    background: #edf2f4;
}

.status-succeeded {
    background: #dff3e7;
    color: #135f43;
}

.status-running,
.status-queued {
    background: #e1edf8;
    color: #1f5d98;
}

.status-failed,
.status-expired {
    background: #f7dddd;
    color: #9d2d2a;
}

.rule-enabled {
    background: #dff3e7;
    color: #135f43;
}

.rule-disabled {
    background: #eef0f2;
    color: #667481;
}

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

.rule-table th,
.rule-table td {
    white-space: nowrap;
    vertical-align: middle;
}

.rule-table code {
    color: var(--ink);
    background: #f3f6f7;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 6px;
}

.rule-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.rule-actions form {
    margin: 0;
}

.empty-state {
    border: 1px dashed var(--line);
    color: var(--muted);
    padding: 22px;
    border-radius: 8px;
    text-align: center;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.info-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.info-box span {
    display: block;
    color: var(--blue);
    font-size: 1.6rem;
    font-weight: 780;
}

.info-box small {
    color: var(--muted);
}

.preview-scroll {
    max-height: 520px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.history-duplicate-cell {
    background: #fff1d6 !important;
    color: #7a4a08;
    font-weight: 760;
    box-shadow: inset 0 0 0 2px #e2a63b;
}

.history-duplicate-table {
    margin-bottom: 18px;
}

.history-duplicate-table td:first-child {
    color: #7a4a08;
    background: #fff7e8;
}

.rule-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.rule-form button {
    grid-column: 1 / -1;
}

.change-list {
    display: grid;
    gap: 8px;
}

.change-row {
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.pager {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pager-pages {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pager-link {
    min-width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.9rem;
}

.pager-link.active {
    color: white;
    border-color: var(--green);
    background: var(--green);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(40, 111, 90, 0.92), rgba(40, 102, 166, 0.88)),
        url("/static/img/workbench-banner.png") center / cover;
}

.login-panel {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 24px;
    align-items: center;
}

.login-copy {
    color: white;
}

.login-copy h1 {
    font-size: clamp(2.2rem, 4.8vw, 4.4rem);
    line-height: 1.02;
    margin: 10px 0;
    letter-spacing: 0;
}

.login-copy h1 span {
    display: block;
    white-space: nowrap;
}

.login-copy p {
    font-size: 1.08rem;
    color: rgba(255, 255, 255, 0.88);
    max-width: 520px;
}

.login-card {
    background: white;
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.login-card h2 {
    margin-bottom: 18px;
}

.login-card label {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 10px 0 6px;
}

.captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px 42px;
    gap: 8px;
}

.captcha-row img {
    width: 140px;
    height: 38px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.icon-btn {
    border: 1px solid var(--line);
    background: #f7fafb;
    border-radius: 6px;
}

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

@media (max-width: 900px) {
    .layout-grid,
    .rules-grid,
    .login-panel {
        grid-template-columns: 1fr;
    }

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

    .nav-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 18px;
    }
}

@media (max-width: 600px) {
    .page {
        padding: 14px;
    }

    .hero-content {
        padding: 24px;
    }

    .metric-grid,
    .detail-grid,
    .rule-form {
        grid-template-columns: 1fr;
    }

    .job-row {
        grid-template-columns: 1fr;
    }
}
