:root {
    --ink: #17212f;
    --muted: #64748b;
    --line: #dbe3ee;
    --panel: #ffffff;
    --bg: #f5f7fb;
    --nav: #101927;
    --blue: #063b80;
    --teal: #00aeb5;
    --green: #178f63;
    --amber: #b7791f;
    --shadow: 0 16px 40px rgba(20, 34, 55, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--nav);
    color: #fff;
    padding: 22px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    min-height: 76px;
    margin-bottom: 26px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: #ffffff;
}

.brand img {
    width: 100%;
    max-width: 232px;
    height: auto;
    display: block;
}

.main-nav {
    display: grid;
    gap: 8px;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #d9e7f8;
    text-decoration: none;
}

.main-nav a:hover,
.main-nav a.active {
    background: rgba(0, 174, 181, 0.16);
    color: #fff;
}

.nav-icon {
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    color: var(--teal);
}

.main-panel {
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 90px;
    padding: 22px 32px;
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.topbar h1,
.panel h2 {
    margin: 0;
    font-size: 25px;
    line-height: 1.2;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--teal);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.content {
    display: grid;
    gap: 22px;
    padding: 28px 32px 48px;
}

.status-pill,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef4fb;
    color: #344256;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-pill.ok {
    background: #e8f7f0;
    color: var(--green);
}

.status-pill.warn {
    background: #fff6df;
    color: var(--amber);
}

.system-notice {
    margin: 20px 32px 0;
    padding: 12px 14px;
    border: 1px solid #f1d28c;
    border-radius: 8px;
    background: #fff9e9;
    color: #77530b;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.metric-card {
    display: grid;
    gap: 6px;
    padding: 18px;
}

.metric-card span,
.metric-card small,
td small,
.form-actions span {
    color: var(--muted);
}

.metric-card strong {
    font-size: 34px;
    line-height: 1;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    gap: 22px;
}

.panel {
    padding: 20px;
}

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

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.button:hover {
    text-decoration: none;
}

.button.primary {
    background: var(--blue);
    color: #fff;
}

.button.ghost {
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.progress-panel {
    display: none;
}

.progress-panel.visible {
    display: grid;
    gap: 14px;
}

.progress-line {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2f7;
}

.progress-line span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    transition: width 160ms ease;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.progress-stats div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.progress-stats strong,
.progress-stats span {
    display: block;
}

.progress-stats span {
    color: var(--muted);
    font-size: 13px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
}

.alert.error {
    border: 1px solid #efb4b4;
    background: #fff1f1;
    color: #9b1c1c;
}

.alert.success {
    border: 1px solid #a7dfc2;
    background: #edfdf4;
    color: #126b4a;
}

.icon-button {
    display: none;
    width: 40px;
    padding: 0;
    border-color: var(--line);
    background: #fff;
}

.pipeline,
.batch-preview {
    display: grid;
    gap: 12px;
}

.pipeline div,
.batch-preview div {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 4px 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.pipeline span {
    grid-row: span 2;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: #e6f8f9;
    color: #007f86;
    font-weight: 800;
}

.pipeline p,
.batch-preview span {
    grid-column: 2;
    margin: 0;
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.compact table {
    min-width: 520px;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: #f7fafc;
    color: #41516a;
    font-size: 13px;
}

td {
    color: #263449;
}

td strong,
td span,
td small {
    display: block;
    max-width: 420px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.form-panel {
    max-width: 980px;
}

.form-grid,
.filters {
    display: grid;
    gap: 16px;
}

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

.filters {
    grid-template-columns: minmax(220px, 1fr) 180px 200px auto auto;
    align-items: end;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

label span {
    font-size: 13px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cfd8e6;
    border-radius: 8px;
    padding: 9px 11px;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus {
    border-color: var(--teal);
    outline: 3px solid rgba(0, 174, 181, 0.18);
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.batch-preview div {
    grid-template-columns: 170px minmax(0, 1fr);
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 12px;
}

.empty-state p {
    color: var(--muted);
}

@media (max-width: 1050px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        inset: 0 auto 0 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 160ms ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .icon-button {
        display: inline-flex;
    }

    .metrics-grid,
    .split-layout,
    .form-grid,
    .filters {
        grid-template-columns: 1fr 1fr;
    }

    .filters .button {
        width: 100%;
    }
}

@media (max-width: 700px) {
    .topbar {
        align-items: flex-start;
        padding: 18px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .status-pill {
        display: none;
    }

    .content {
        padding: 18px;
    }

    .system-notice {
        margin: 16px 18px 0;
    }

    .metrics-grid,
    .split-layout,
    .form-grid,
    .filters,
    .batch-preview div {
        grid-template-columns: 1fr;
    }

    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .pipeline div {
        grid-template-columns: 34px minmax(0, 1fr);
    }
}
