:root {
    --bg: #f4f1e8;
    --surface: #fffdf8;
    --surface-alt: #f0e7d5;
    --ink: #1f2a2c;
    --muted: #677274;
    --line: #d7c9ab;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b42318;
    --success: #027a48;
    --warning: #b54708;
    --shadow: 0 18px 40px rgba(31, 42, 44, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 28%),
        radial-gradient(circle at bottom right, rgba(181, 71, 8, 0.14), transparent 24%),
        var(--bg);
    overflow-x: hidden;
}

a {
    color: inherit;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel,
.card {
    background: rgba(255, 253, 248, 0.92);
    border: 1px solid rgba(215, 201, 171, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
}

.login-card {
    width: min(460px, 100%);
    padding: 36px;
    border-radius: 24px;
}

.login-card button[type="submit"] {
    background: linear-gradient(135deg, #ea580c, #c2410c);
    border-color: #c2410c;
    box-shadow: 0 14px 28px rgba(194, 65, 12, 0.22);
}

.login-card button[type="submit"]:hover,
.login-card button[type="submit"]:focus-visible {
    background: linear-gradient(135deg, #f97316, #c2410c);
    border-color: #9a3412;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 28px 32px 12px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 0 32px 12px;
    align-items: center;
}

.nav-item {
    position: relative;
}

.nav-toggle {
    display: none;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.9);
    color: var(--ink);
}

.nav-toggle-bars {
    display: inline-grid;
    gap: 5px;
}

.nav-toggle-bars span {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.topnav a {
    text-decoration: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: rgba(31, 42, 44, 0.78);
    font-weight: 700;
    position: relative;
    transition: color 140ms ease, transform 140ms ease;
}

.nav-link-parent {
    cursor: default;
    gap: 8px;
}

.nav-caret {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    transform-origin: center;
    transition: transform 120ms ease;
    flex: 0 0 auto;
}

.nav-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #d97706);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 140ms ease;
}

.nav-link:hover,
.nav-link:focus-visible {
    color: var(--accent-dark);
    transform: translateY(-1px);
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
    transform: scaleX(1);
}

.nav-link.active {
    color: var(--accent-dark);
}

.nav-link.active::after {
    transform: scaleX(1);
}

.nav-item-group:hover .nav-submenu,
.nav-item-group:focus-within .nav-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-item-group:hover .nav-caret,
.nav-item-group:focus-within .nav-caret {
    transform: rotate(225deg) translateY(-1px);
}

.nav-submenu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 220px;
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(215, 201, 171, 0.9);
    background: rgba(255, 253, 248, 0.98);
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
    z-index: 20;
}

.nav-sublink {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(31, 42, 44, 0.82);
    font-weight: 700;
    transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

.nav-sublink:hover,
.nav-sublink:focus-visible {
    background: rgba(240, 231, 213, 0.85);
    color: var(--accent-dark);
    transform: translateX(2px);
}

.nav-sublink.active {
    background: rgba(15, 118, 110, 0.12);
    color: var(--accent-dark);
}

.page {
    padding: 12px 32px 40px;
    display: grid;
    gap: 24px;
}

.panel {
    border-radius: 24px;
    padding: 24px;
}

.hero-panel {
    display: grid;
    gap: 24px;
}

.hero-main {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.hero-wide {
    width: 100%;
    display: grid;
    gap: 14px;
}

.hero-copy h2 {
    margin-bottom: 10px;
}

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

.stat-card {
    background: rgba(240, 231, 213, 0.75);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 1.3rem;
}

.stat-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
    font-weight: 700;
}

.stat-card-warning {
    background: linear-gradient(135deg, rgba(181, 71, 8, 0.15), rgba(255, 251, 235, 0.95));
}

.stat-card-success {
    background: linear-gradient(135deg, rgba(2, 122, 72, 0.16), rgba(240, 253, 244, 0.96));
}

.stat-card-critical {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.95), rgba(220, 38, 38, 0.72));
    color: #fff4f4;
}

.stat-card-critical .stat-label {
    color: rgba(255, 244, 244, 0.82);
}

.alert-panel {
    border-color: rgba(181, 71, 8, 0.35);
    background:
        linear-gradient(135deg, rgba(255, 247, 237, 0.96), rgba(255, 253, 248, 0.94)),
        rgba(255, 253, 248, 0.92);
}

.alert-panel .section-title h2 {
    color: #9a3412;
}

.alert-subsection + .alert-subsection {
    margin-top: 18px;
}

.alert-subsection h3 {
    margin: 0 0 12px;
    font-size: 1rem;
}

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

.dashboard-lower {
    align-items: start;
}

.grid {
    display: grid;
    gap: 16px;
}

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

.card {
    border-radius: 20px;
    padding: 20px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    margin-bottom: 20px;
}

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

.section-title-inline {
    margin-bottom: 0;
    align-items: center;
}

.section-title-inline h3,
.section-title-inline p {
    margin-bottom: 0;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    color: var(--accent-dark);
    font-weight: 700;
}

.brand-eyebrow,
.login-card .login-eyebrow {
    color: #ea580c;
}

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

.stack {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

input,
select,
textarea,
button,
.button-link {
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 12px 14px;
    font: inherit;
}

input,
select,
textarea {
    background: #fff;
}

button,
.button-link {
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.button-link.secondary {
    background: var(--surface-alt);
    color: var(--ink);
}

.logout-button {
    width: 56px;
    height: 56px;
    padding: 0;
    flex: 0 0 auto;
}

.logout-icon {
    width: 22px;
    height: 22px;
    display: inline-block;
}

.logout-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.alert {
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 20px;
    font-weight: 700;
}

.alert-success {
    background: rgba(2, 122, 72, 0.12);
    color: var(--success);
}

.alert-error {
    background: rgba(180, 35, 24, 0.12);
    color: var(--danger);
}

.alert-warning {
    background: rgba(181, 71, 8, 0.14);
    color: #9a3412;
}

.flash-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 24px;
}

.flash-modal.is-closing {
    pointer-events: none;
}

.flash-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(31, 42, 44, 0.34);
    backdrop-filter: blur(3px);
}

.flash-card {
    position: relative;
    z-index: 1;
    width: min(520px, calc(100vw - 32px));
    margin: 0;
    padding: 22px 52px 22px 20px;
    background: #ffffff;
    color: var(--ink);
    border: 1px solid rgba(215, 201, 171, 0.9);
    border-left-width: 6px;
    box-shadow: 0 28px 54px rgba(31, 42, 44, 0.2);
    animation: flash-pop 140ms ease;
}

.flash-card.alert-success {
    background: #ffffff;
    color: var(--ink);
    border-left-color: var(--success);
}

.flash-card.alert-error {
    background: #ffffff;
    color: var(--ink);
    border-left-color: var(--danger);
}

.flash-card.alert-warning {
    background: #ffffff;
    color: var(--ink);
    border-left-color: var(--warning);
}

.flash-message {
    line-height: 1.5;
}

.flash-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 0;
    padding: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    color: currentColor;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

@keyframes flash-pop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.table-wrap-scroll-y {
    max-height: 560px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.progress {
    margin-top: 16px;
    height: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-alt);
    display: flex;
}

.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #1d4ed8);
}

.segmented-progress {
    gap: 1px;
    background: #e8dcc2;
}

.capacity-caption {
    margin-top: 10px;
    font-size: 0.92rem;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
}

.badge-ok {
    background: rgba(2, 122, 72, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(181, 71, 8, 0.12);
    color: var(--warning);
}

.badge-critical {
    background: rgba(180, 35, 24, 0.14);
    color: var(--danger);
}

.user-pill,
.demo-box {
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px 14px;
}

.user-pill {
    min-height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.user-pill span {
    display: block;
    font-size: 0.86rem;
    color: var(--muted);
}

.demo-box {
    margin-top: 20px;
}

.color-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(31, 42, 44, 0.18);
    flex: 0 0 auto;
}

.cell-negative {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.95), rgba(220, 38, 38, 0.72));
    color: #fff4f4;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(127, 29, 29, 0.35);
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.card-actions .button-link {
    flex: 1;
}

.positioning-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.positioning-card {
    padding: 22px;
}

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

.positioning-card-header h3 {
    margin: 0;
}

.positioning-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.positioning-summary-item {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(240, 231, 213, 0.55);
    border: 1px solid rgba(215, 201, 171, 0.9);
}

.positioning-summary-item span {
    display: block;
    margin-bottom: 4px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 700;
}

.positioning-summary-item strong {
    display: block;
}

.positioning-bars {
    display: grid;
    gap: 16px;
}

.positioning-row {
    display: grid;
    gap: 8px;
}

.positioning-row-chart {
    grid-template-columns: minmax(130px, 180px) minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
}

.positioning-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.positioning-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.alert-owner-cell {
    display: grid;
    gap: 6px;
}

.product-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    cursor: pointer;
}

.product-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.product-toggle-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid rgba(180, 35, 24, 0.18);
    background: rgba(180, 35, 24, 0.08);
    color: var(--danger);
    font-weight: 700;
    transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.product-toggle:hover .product-toggle-pill {
    transform: translateY(-1px);
}

.product-toggle-input:focus-visible + .product-toggle-pill {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
}

.product-toggle-input:checked + .product-toggle-pill {
    border-color: rgba(2, 122, 72, 0.24);
    background: rgba(2, 122, 72, 0.12);
    color: var(--success);
}

.product-toggle-state-on,
.product-toggle-input:checked + .product-toggle-pill .product-toggle-state-off {
    display: none;
}

.product-toggle-input:checked + .product-toggle-pill .product-toggle-state-on {
    display: inline;
}

.positioning-track {
    width: 100%;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(215, 201, 171, 0.95);
    background:
        repeating-linear-gradient(
            to right,
            rgba(148, 163, 184, 0.28) 0,
            rgba(148, 163, 184, 0.28) 2px,
            transparent 2px,
            transparent calc(10% - 1px)
        ),
        rgba(240, 231, 213, 0.82);
    overflow: hidden;
}

.positioning-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.positioning-value {
    white-space: nowrap;
}

.tank-detail-list {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
}

.tank-detail-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tank-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(240, 231, 213, 0.55);
}

.tank-detail-row strong {
    white-space: nowrap;
}

.tank-detail-row-negative {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.95), rgba(220, 38, 38, 0.72));
    color: #fff4f4;
    box-shadow: inset 0 0 0 1px rgba(127, 29, 29, 0.35);
}

.forecast-grid {
    display: grid;
    gap: 18px;
}

.forecast-card {
    padding: 22px;
}

.forecast-card-subtitle {
    margin: 6px 0 0;
}

.forecast-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.forecast-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.forecast-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.forecast-legend-swatch {
    width: 22px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
}

.forecast-legend-stock {
    background: #0f766e;
}

.forecast-legend-projection {
    background: linear-gradient(90deg, #0f766e 0 45%, transparent 45% 55%, #0f766e 55% 100%);
}

.forecast-legend-consumption {
    background: #ea580c;
}

.forecast-chart {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 18px;
    border: 1px solid rgba(215, 201, 171, 0.9);
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.05), transparent 34%),
        rgba(255, 253, 248, 0.96);
}

.forecast-axis {
    stroke: rgba(71, 85, 105, 0.34);
    stroke-width: 1.2;
}

.forecast-cutoff {
    stroke: rgba(234, 88, 12, 0.45);
    stroke-width: 1.5;
    stroke-dasharray: 6 6;
}

.forecast-bar {
    fill: rgba(234, 88, 12, 0.76);
}

.forecast-line {
    fill: none;
    stroke: #0f766e;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.forecast-line-projection {
    stroke-dasharray: 8 8;
    opacity: 0.72;
}

.forecast-label {
    fill: #677274;
    font-size: 12px;
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
}

.forecast-footnote {
    margin-top: 12px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cell-negative .color-chip,
.tank-detail-row-negative .color-chip {
    color: inherit;
}

@media (max-width: 960px) {
    .hero-panel,
    .hero-main,
    .stats-grid,
    .cards-3,
    .two-columns {
        grid-template-columns: 1fr;
    }

    .topbar,
    .section-title {
        flex-direction: column;
        align-items: start;
    }

    .page,
    .topbar,
    .topnav {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (max-width: 720px) {
    .topbar {
        padding-top: 20px;
        gap: 14px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .user-pill {
        order: 2;
        flex: 1 1 0;
        min-width: 0;
    }

    .nav-toggle {
        order: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topnav {
        display: none;
        padding-top: 4px;
        gap: 8px;
    }

    .topnav.is-open {
        display: grid;
    }

    .nav-item,
    .nav-link {
        width: 100%;
    }

    .nav-item-group {
        display: grid;
        gap: 6px;
    }

    .nav-submenu {
        position: static;
        min-width: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        backdrop-filter: none;
        padding: 0 0 0 14px;
        border: 0;
        background: transparent;
    }

    .nav-sublink {
        padding: 8px 0;
    }

    button {
        width: 100%;
    }

    .logout-button {
        order: 3;
        width: 48px;
    }

    .panel,
    .card,
    .login-card {
        padding: 18px;
        border-radius: 20px;
    }

    .section-title {
        gap: 10px;
        margin-bottom: 16px;
    }

    .card-actions {
        flex-direction: column;
    }

    .table-wrap {
        overflow-x: visible;
    }

    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table th,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tbody {
        display: grid;
        gap: 12px;
    }

    .responsive-table tr {
        border: 1px solid var(--line);
        border-radius: 16px;
        background: rgba(240, 231, 213, 0.35);
        padding: 10px 12px;
    }

    .responsive-table td {
        border-bottom: 1px solid rgba(215, 201, 171, 0.7);
        padding: 10px 0;
        display: grid;
        grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-size: 0.78rem;
        line-height: 1.3;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--muted);
        font-weight: 700;
    }

    .responsive-table td[colspan] {
        display: block;
        padding: 4px 0;
        border-bottom: 0;
    }

    .responsive-table td[colspan]::before {
        content: none;
    }

    .positioning-row-chart {
        grid-template-columns: 1fr;
        gap: 8px;
    }

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

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

    .positioning-value {
        justify-self: start;
    }
}

@media (max-width: 480px) {
    .page,
    .topbar,
    .topnav {
        padding-left: 14px;
        padding-right: 14px;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card strong {
        font-size: 1.15rem;
    }

    .responsive-table td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
