:root {
    --bg: #f4f6f3;
    --surface: #ffffff;
    --ink: #17211e;
    --muted: #65736d;
    --line: #d9e0dc;
    --accent: #00796b;
    --accent-2: #b23b3b;
    --accent-3: #b7791f;
    --accent-4: #315f9f;
    --shadow: 0 10px 30px rgba(23, 33, 30, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration-color: rgba(0, 121, 107, 0.45);
    text-underline-offset: 3px;
}

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

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(24px, 3vw, 38px);
    line-height: 1.08;
}

h2 {
    margin-bottom: 2px;
    font-size: 18px;
}

h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.top-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.google-login {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 13px 8px 10px;
    border: 1px solid #dadce0;
    border-radius: 999px;
    background: #fff;
    color: #3c4043;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
}

.google-mark {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    color: #1a73e8;
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: 800;
}

.account-pill {
    color: var(--ink);
}

.account-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.dot-ok {
    background: var(--accent);
}

.dot-error {
    background: var(--accent-2);
}

.page {
    width: min(1480px, calc(100% - 32px));
    margin: 24px auto 56px;
}

.page.narrow {
    width: min(720px, calc(100% - 32px));
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(178, 59, 59, 0.25);
    border-left: 4px solid var(--accent-2);
    border-radius: 8px;
    background: #fff8f7;
    color: #5c201f;
}

.alert span {
    display: block;
    margin-top: 6px;
    color: #7b4a47;
    font-size: 13px;
}

.alert.success {
    border-color: rgba(0, 121, 107, 0.25);
    border-left-color: var(--accent);
    background: #f1fbf8;
    color: #164b42;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.kpi {
    min-height: 112px;
    padding: 16px;
}

.kpi span,
.kpi small,
.panel-heading p,
.article-row p,
.run-row small,
.metric-list dt {
    color: var(--muted);
}

.kpi span {
    display: block;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.kpi strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.05;
}

.kpi small {
    display: block;
    margin-top: 7px;
    font-size: 12px;
}

.kpi-risk strong {
    color: var(--accent-2);
}

.layout-two {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(340px, 0.8fr);
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    padding: 18px;
    min-width: 0;
}

.panel-wide {
    min-height: 430px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.panel-heading p {
    margin-bottom: 0;
    font-size: 13px;
}

.segmented {
    display: inline-grid;
    grid-auto-flow: column;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf8;
}

.segmented button,
.upload-form button {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.segmented button {
    min-width: 48px;
    min-height: 32px;
    padding: 6px 10px;
}

.segmented button.active {
    background: var(--accent);
    color: #fff;
}

.chart-wrap {
    position: relative;
    min-height: 330px;
}

.chart-wrap-small {
    min-height: 260px;
}

#throughputChart {
    display: block;
    width: 100%;
    min-height: 330px;
}

#brentFuturesChart,
#aramcoOptionsChart {
    display: block;
    width: 100%;
    min-height: 260px;
}

.empty-state {
    display: none;
    color: var(--muted);
    font-size: 14px;
}

.empty-state.visible,
#throughputEmpty.visible {
    display: block;
}

#throughputEmpty {
    position: absolute;
    inset: 0;
    place-content: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.88);
}

.chart-wrap-small .empty-state.visible {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    padding: 18px;
    text-align: center;
}

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

.metric-list div {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.metric-list dt,
.metric-list dd {
    margin: 0;
}

.metric-list dd {
    font-weight: 800;
    overflow-wrap: anywhere;
}

.matrix {
    display: grid;
    gap: 10px;
}

.matrix-row {
    display: grid;
    grid-template-columns: minmax(110px, 0.85fr) minmax(120px, 1.3fr) 52px;
    align-items: center;
    gap: 12px;
    min-height: 30px;
    font-size: 14px;
}

.bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7ece8;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-3));
}

.matrix-row b {
    text-align: right;
}

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

.probability-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.prob-card {
    min-height: 116px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.prob-card div:first-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
}

.prob-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.prob-card strong {
    color: var(--accent-2);
    font-size: 30px;
    line-height: 1;
}

.prob-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.prob-track {
    height: 12px;
    margin: 14px 0 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #ece3df;
}

.prob-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
}

.probability-table {
    margin-top: 4px;
}

.run-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.run-row small {
    grid-column: 2;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e7ece8;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.badge-ok {
    background: #e5f5ef;
    color: #0d6b5f;
}

.badge-error {
    background: #fae7e4;
    color: #9b2d2a;
}

.badge-partial,
.badge-empty,
.badge-not_configured {
    background: #fff4dd;
    color: #855a13;
}

.table-scroll {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

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

.compact-list {
    max-height: 420px;
    overflow: auto;
}

.article-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 14px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.article-row h3,
.article-row p {
    margin-bottom: 0;
}

.article-row strong {
    display: inline-grid;
    place-items: center;
    min-height: 34px;
    border-radius: 6px;
    background: #eef5f1;
    color: var(--accent);
}

.analysis-row {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.analysis-row small,
.analysis-row p {
    margin: 0;
    color: var(--muted);
}

.analysis-row p {
    color: var(--ink);
    font-size: 13px;
}

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

.settings-form {
    display: grid;
    gap: 22px;
}

.compact-form {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.compact-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.compact-form input[type="text"],
.compact-form input[type="email"] {
    width: 100%;
    min-height: 38px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8faf8;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.settings-section {
    display: grid;
    gap: 10px;
}

.settings-section h3 {
    margin-bottom: 0;
}

.settings-table {
    min-width: 1180px;
}

.settings-table th:first-child,
.settings-table td:first-child {
    width: 52px;
    text-align: center;
}

.settings-table td {
    vertical-align: top;
}

.settings-table td:nth-child(2) {
    width: 220px;
}

.settings-table td:nth-child(3) {
    width: 190px;
}

.settings-table td:nth-child(4) {
    width: 210px;
}

.settings-table td:nth-child(5) {
    width: 260px;
}

.settings-table strong,
.settings-table small {
    display: block;
}

.settings-table small,
.inline-check {
    color: var(--muted);
    font-size: 12px;
}

.settings-table input[type="email"],
.settings-table input[type="password"],
.settings-table input[type="text"],
.settings-table input[type="url"],
.settings-table textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8faf8;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.settings-table input[type="email"],
.settings-table input[type="password"],
.settings-table input[type="text"],
.settings-table input[type="url"] {
    min-height: 36px;
    padding: 7px 9px;
}

.settings-table textarea {
    min-height: 76px;
    padding: 8px 9px;
    resize: vertical;
}

.toggle-cell {
    display: inline-grid;
    place-items: center;
    min-height: 36px;
}

.toggle-cell input,
.inline-check input {
    accent-color: var(--accent);
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
}

.upload-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 800;
}

.upload-form input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf8;
}

.upload-form button {
    justify-self: start;
    min-height: 40px;
    padding: 8px 14px;
    background: var(--accent);
    color: #fff;
}

.primary-action {
    justify-self: start;
    min-height: 42px;
    padding: 9px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.button-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.muted-copy {
    color: var(--muted);
    font-size: 14px;
}

.inline-form {
    display: inline;
}

.danger-action {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid rgba(178, 59, 59, 0.28);
    border-radius: 6px;
    background: #fff8f7;
    color: var(--accent-2);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

@media (max-width: 1100px) {
    .layout-two {
        grid-template-columns: 1fr;
    }
}

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

    .page {
        width: min(100% - 20px, 1480px);
        margin-top: 14px;
    }

    .panel {
        padding: 14px;
    }

    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .segmented {
        grid-auto-flow: initial;
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .segmented button {
        min-width: 0;
        padding-inline: 4px;
    }

    .matrix-row {
        grid-template-columns: minmax(96px, 0.8fr) minmax(80px, 1fr) 42px;
        gap: 8px;
    }

    .probability-grid {
        grid-template-columns: 1fr;
    }
}
