:root {
    --bg: #f4f6f2;
    --surface: #ffffff;
    --surface-soft: #eef3ee;
    --ink: #17211f;
    --muted: #64716d;
    --line: #d9e0d9;
    --primary: #126b61;
    --primary-dark: #0d4c45;
    --secondary: #315f7d;
    --accent: #c66b3d;
    --danger: #b83b3b;
    --success: #2f7a4e;
    --shadow: 0 18px 40px rgba(28, 45, 40, 0.10);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin-inline: auto;
}

.section {
    padding-block: 34px 54px;
}

.narrow {
    max-width: 980px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar-inner {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: max-content;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav a {
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 700;
}

.nav a:hover,
.nav a.is-active {
    background: var(--surface-soft);
    color: var(--ink);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-weight: 700;
}

.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 800;
    line-height: 1.1;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.button:hover {
    transform: translateY(-1px);
}

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

.button.primary:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: #e6eef3;
    color: #173d55;
    border-color: #c9dae5;
}

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

.button.danger {
    color: var(--danger);
}

.button.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.button.full {
    width: 100%;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.hero {
    position: relative;
    overflow: hidden;
    min-height: 560px;
    display: grid;
    align-items: center;
    color: #ffffff;
    background: #10231f;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(16, 35, 31, 0.95), rgba(16, 35, 31, 0.68) 48%, rgba(16, 35, 31, 0.34)),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 22px);
}

.hero-grid {
    position: relative;
    min-height: 500px;
    display: grid;
    align-items: center;
}

.hero-copy {
    position: relative;
    z-index: 2;
    width: min(660px, 100%);
    padding-block: 70px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.hero h1 {
    margin: 0;
    font-size: clamp(44px, 7vw, 88px);
    line-height: 0.95;
}

.hero-text {
    width: min(620px, 100%);
    margin: 22px 0 0;
    color: rgba(255, 255, 255, 0.84);
    font-size: 19px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.product-preview {
    position: absolute;
    right: 0;
    bottom: 34px;
    width: min(520px, 48vw);
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.11);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.preview-bar,
.preview-metrics,
.preview-table div {
    display: grid;
    align-items: center;
    gap: 10px;
}

.preview-bar {
    grid-template-columns: 12px 1fr auto;
    color: rgba(255, 255, 255, 0.82);
}

.preview-bar span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
}

.preview-metrics {
    grid-template-columns: repeat(3, 1fr);
    margin-top: 18px;
}

.preview-metrics div,
.preview-table div {
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.12);
}

.preview-metrics div {
    min-height: 92px;
    padding: 14px;
}

.preview-metrics small,
.preview-table span:last-child {
    color: rgba(255, 255, 255, 0.66);
}

.preview-metrics strong {
    display: block;
    margin-top: 8px;
    font-size: 21px;
}

.preview-table {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.preview-table div {
    grid-template-columns: 1fr auto auto;
    min-height: 44px;
    padding: 10px 12px;
}

.section-heading {
    width: min(720px, 100%);
    margin-bottom: 22px;
}

.section-heading h2,
.page-heading h1,
.auth-card h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.1;
}

.feature-grid,
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

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

.feature-card {
    padding: 22px;
}

.feature-card h3 {
    margin: 0 0 9px;
    font-size: 18px;
}

.feature-card p,
.muted {
    color: var(--muted);
}

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

.metric-grid {
    grid-template-columns: repeat(6, 1fr);
    margin-bottom: 18px;
}

.metric-grid.compact {
    grid-template-columns: repeat(5, 1fr);
}

.metric-card {
    min-height: 112px;
    padding: 17px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 16px;
    font-size: 24px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
    gap: 18px;
    align-items: start;
}

.content-grid .wide {
    min-width: 0;
}

.panel {
    padding: 18px;
}

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

.panel-heading h2,
.calc-panel h2 {
    margin: 0;
    font-size: 18px;
}

.panel-heading a,
.panel-heading span {
    color: var(--muted);
    font-weight: 800;
    font-size: 13px;
}

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

table {
    width: 100%;
    min-width: 860px;
    border-collapse: collapse;
    background: var(--surface);
}

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

th {
    background: #f7faf7;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

td strong,
td small {
    display: block;
}

td small {
    max-width: 320px;
    margin-top: 4px;
    color: var(--muted);
    white-space: normal;
}

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

.empty-cell {
    color: var(--muted);
    text-align: center;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

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

.driver-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfb;
}

.driver-row span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.filter-bar {
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.filters {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 14px;
}

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

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
    align-items: start;
}

.full-field {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-weight: 800;
}

label small {
    color: var(--muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cdd8d2;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    padding: 10px 11px;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(18, 107, 97, 0.14);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

.calc-panel dl {
    display: grid;
    gap: 10px;
    margin: 14px 0 0;
}

.calc-panel dl div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.calc-panel dt {
    color: var(--muted);
    font-weight: 800;
}

.calc-panel dd {
    margin: 0;
    font-weight: 900;
}

.auth-page {
    background: #edf2ed;
}

.auth-shell {
    min-height: calc(100vh - 150px);
    display: grid;
    place-items: center;
    padding: 34px 16px;
}

.auth-card,
.notice-panel {
    width: min(460px, 100%);
    padding: 28px;
}

.notice-panel {
    width: min(720px, 100%);
}

.notice-panel h1 {
    margin: 0 0 10px;
}

.setup-list {
    margin: 18px 0 0;
    padding-left: 22px;
}

.setup-list li + li {
    margin-top: 8px;
}

.flash {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-weight: 800;
}

.flash.inline {
    margin: 0 0 16px;
}

.flash.success {
    background: #e7f3ec;
    color: #245d3d;
    border: 1px solid #bfdfcb;
}

.flash.error {
    background: #f8e8e8;
    color: #8f2b2b;
    border: 1px solid #efc6c6;
}

.status,
.role-badge,
.summary-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status.active {
    background: #e7f3ec;
    color: var(--success);
}

.status.inactive {
    background: #edf0f2;
    color: var(--muted);
}

.role-badge,
.summary-pill {
    background: #e9eef5;
    color: var(--secondary);
}

.text-danger {
    color: var(--danger);
    font-weight: 900;
}

.footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.55);
}

.footer-inner {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

@media (max-width: 1050px) {
    .topbar-inner,
    .page-heading,
    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-menu {
        width: 100%;
        justify-content: space-between;
    }

    .product-preview {
        position: relative;
        right: auto;
        bottom: auto;
        width: 100%;
        margin-bottom: 32px;
    }

    .hero-grid {
        min-height: auto;
        padding-top: 18px;
    }

    .hero-copy {
        padding-block: 54px 24px;
    }

    .metric-grid,
    .metric-grid.compact,
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .content-grid,
    .form-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .shell {
        width: min(100% - 22px, 1180px);
    }

    .section {
        padding-block: 24px 42px;
    }

    .nav {
        justify-content: flex-start;
    }

    .hero {
        min-height: auto;
    }

    .hero h1 {
        font-size: 48px;
    }

    .hero-text {
        font-size: 17px;
    }

    .preview-metrics,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .preview-table div {
        grid-template-columns: 1fr;
    }

    .metric-grid,
    .metric-grid.compact,
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        min-height: 94px;
    }

    .filters,
    .form-actions,
    .hero-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .button {
        width: 100%;
    }

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }
}
