:root {
    --bg: #f8faf7;
    --surface: #ffffff;
    --surface-soft: #eef5eb;
    --text: #111111;
    --muted: #5d645d;
    --green: #4aa34a;
    --green-deep: #2e7d32;
    --border: rgba(17, 17, 17, 0.1);
    --shadow: 0 24px 60px rgba(46, 125, 50, 0.12);
    --radius-lg: 28px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --font-display: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    --font-body: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(74, 163, 74, 0.18), transparent 32%),
        linear-gradient(135deg, #ffffff 0%, #f4f8f2 60%, #edf5ea 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(17, 17, 17, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(17, 17, 17, 0.025) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
}

img {
    display: block;
    max-width: 100%;
}

.login-shell,
.dashboard-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.login-shell {
    display: grid;
    gap: 18px;
    align-items: stretch;
}

.brand-panel,
.card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.brand-panel {
    padding: 28px;
    overflow: hidden;
    position: relative;
}

.brand-panel::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -40px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74, 163, 74, 0.22), rgba(74, 163, 74, 0));
}

.brand-mark {
    width: 84px;
    height: 84px;
    padding: 12px;
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(74, 163, 74, 0.16), rgba(74, 163, 74, 0.04));
    margin-bottom: 20px;
}

.eyebrow,
.card-label {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.75rem;
    color: var(--green-deep);
}

h1,
h2 {
    font-family: var(--font-display);
    margin: 0;
    line-height: 1.05;
}

h1 {
    font-size: clamp(2.2rem, 4vw, 4.5rem);
    max-width: 10ch;
}

h2 {
    font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.lead {
    max-width: 40ch;
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 18px 0 0;
    color: var(--muted);
}

.feature-list {
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.feature-list li {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    border: 1px solid rgba(74, 163, 74, 0.12);
}

.login-card,
.roadmap-card {
    padding: 24px;
}

.card-header p,
.roadmap-card p {
    color: var(--muted);
    line-height: 1.6;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.field {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

.field span {
    font-size: 0.92rem;
}

.field input,
.field select,
.primary-button,
.secondary-button,
.toggle-password {
    font: inherit;
}

.field input,
.field select {
    width: 100%;
    border: 1px solid rgba(17, 17, 17, 0.14);
    border-radius: 16px;
    background: #fff;
    color: var(--text);
    min-height: 56px;
    padding: 0 16px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.field input:focus,
.field select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(74, 163, 74, 0.14);
    transform: translateY(-1px);
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 92px;
}

.toggle-password {
    position: absolute;
    right: 8px;
    top: 8px;
    bottom: 8px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--green-deep);
    padding: 0 14px;
    font-weight: 700;
    cursor: pointer;
}

.primary-button,
.secondary-button {
    min-height: 58px;
    border-radius: 18px;
    border: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.primary-button {
    background: linear-gradient(135deg, var(--green), var(--green-deep));
    color: #fff;
    font-weight: 800;
    box-shadow: 0 18px 34px rgba(46, 125, 50, 0.28);
}

.secondary-button {
    background: #fff;
    color: var(--text);
    border: 1px solid rgba(17, 17, 17, 0.12);
    font-weight: 700;
}

.alert {
    padding: 16px 18px;
    border-radius: 16px;
    margin-top: 16px;
    border: 1px solid transparent;
}

.alert-error {
    background: #fff3f2;
    border-color: rgba(202, 63, 44, 0.18);
    color: #8f2f21;
}

.alert-success,
.alert-info {
    background: #eff8ed;
    border-color: rgba(74, 163, 74, 0.18);
    color: #205b22;
}

.footnote {
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.95rem;
}

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

.topbar-brand {
    display: flex;
    gap: 16px;
    align-items: center;
}

.topbar-brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.metric-card strong {
    font-size: 1.2rem;
    line-height: 1.4;
}

.metric-card,
.roadmap-card {
    padding: 24px;
}

.workflow-shell {
    position: relative;
    z-index: 1;
    width: min(1320px, calc(100% - 24px));
    margin: 0 auto;
    padding: 20px 0 40px;
}

.flow-shell {
    position: relative;
    z-index: 1;
    width: min(1320px, calc(100% - 24px));
    margin: 0 auto;
    padding: 16px 0 32px;
}

.mini-header {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.mini-header-left,
.mini-header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.mini-header-copy {
    display: grid;
    gap: 3px;
}

.mini-header-copy strong {
    font-size: 0.98rem;
    line-height: 1.2;
}

.mini-header-copy span,
.mini-session {
    color: var(--muted);
    font-size: 0.84rem;
}

.mini-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 6px;
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(74, 163, 74, 0.12), rgba(74, 163, 74, 0.03));
}

.mini-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.back-button {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text);
    border-radius: 14px;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: #fff;
    font-size: 1.5rem;
    line-height: 1;
}

.compact-button {
    min-height: 46px;
    padding: 0 16px;
    border-radius: 14px;
}

.search-stage {
    min-height: calc(100vh - 140px);
    display: grid;
    place-items: center;
}

.search-card {
    width: min(760px, 100%);
    padding: 28px;
}

.search-title {
    font-size: clamp(2rem, 4vw, 3.8rem);
    max-width: none;
}

.search-submit {
    min-height: 64px;
    font-size: 1.05rem;
}

.search-alert {
    margin-top: 18px;
}

.search-note {
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.materials-stage {
    display: grid;
    gap: 16px;
}

.materials-hero,
.hero-stat,
.fir-panel,
.materials-panel {
    padding: 22px;
}

.materials-hero-grid {
    display: grid;
    gap: 12px;
}

.hero-stat {
    border-radius: 18px;
    border: 1px solid rgba(17, 17, 17, 0.1);
    background: #fff;
}

.hero-stat strong {
    display: block;
    margin-top: 8px;
    line-height: 1.35;
}

.materials-layout {
    display: grid;
    gap: 16px;
}

.materials-note {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.6;
}

.materials-compare-grid {
    display: grid;
    gap: 16px;
}

.compare-column {
    display: grid;
    gap: 14px;
}

.compare-header h3 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.2;
}

.compare-list {
    display: grid;
    gap: 14px;
}

.compare-card {
    padding: 18px;
    border-radius: 20px;
    border: 1px solid rgba(17, 17, 17, 0.1);
    background: #fff;
}

.planned-card {
    background: linear-gradient(135deg, rgba(74, 163, 74, 0.08), rgba(74, 163, 74, 0.02));
}

.actual-card {
    background: linear-gradient(135deg, rgba(17, 17, 17, 0.03), rgba(17, 17, 17, 0.01));
}

.compare-title-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.compare-state {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(74, 163, 74, 0.14);
    color: var(--green-deep);
    font-size: 0.82rem;
    font-weight: 700;
}

.compare-state-edit {
    background: rgba(17, 17, 17, 0.08);
    color: var(--text);
}

.compare-meta,
.compare-meta-grid,
.compare-form-grid {
    display: grid;
    gap: 12px;
}

.compare-meta span,
.compare-meta-grid span,
.compare-footer span {
    color: var(--muted);
    font-size: 0.85rem;
}

.compare-meta strong,
.compare-meta-grid strong,
.compare-footer strong {
    display: block;
    margin-top: 4px;
    line-height: 1.35;
}

.compare-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(17, 17, 17, 0.08);
}

.action-chip-primary {
    min-height: 48px;
    border-radius: 14px;
    padding: 0 18px;
}

.workflow-topbar {
    align-items: flex-start;
    margin-bottom: 24px;
}

.topbar-copy {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.5;
}

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

.session-chip {
    display: grid;
    gap: 4px;
    min-width: 220px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.session-chip span,
.status-label {
    color: var(--muted);
    font-size: 0.88rem;
}

.workflow-hero,
.workflow-grid,
.workflow-bottom,
.field-grid,
.metrics-grid,
.status-grid {
    display: grid;
    gap: 16px;
}

.workflow-hero,
.workflow-bottom {
    margin-bottom: 16px;
}

.order-entry-card,
.state-card,
.panel-card {
    padding: 24px;
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h2 {
    max-width: 16ch;
}

.order-search-form {
    display: grid;
    gap: 14px;
}

.field-large input {
    min-height: 72px;
    font-size: 1.25rem;
    font-weight: 700;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.action-chip {
    min-height: 48px;
    border-radius: 14px;
    padding: 0 16px;
}

.stack-list {
    display: grid;
    gap: 12px;
}

.list-item {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(17, 17, 17, 0.12);
    background: #fff;
    color: var(--text);
    border-radius: 18px;
    padding: 16px 18px;
    display: grid;
    gap: 6px;
    cursor: pointer;
}

.list-item.is-active {
    border-color: rgba(74, 163, 74, 0.45);
    background: linear-gradient(135deg, rgba(74, 163, 74, 0.14), rgba(74, 163, 74, 0.04));
    box-shadow: 0 16px 30px rgba(46, 125, 50, 0.12);
}

.list-title {
    font-size: 1.08rem;
    font-weight: 800;
}

.list-meta {
    color: var(--green-deep);
    font-weight: 700;
}

.compact-item {
    padding: 14px 16px;
}

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

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

.split-head,
.split-row {
    display: grid;
    gap: 8px;
    align-items: center;
}

.split-head {
    padding: 0 4px;
    color: var(--muted);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.split-row {
    padding: 16px 18px;
    background: var(--surface-soft);
    border: 1px solid rgba(74, 163, 74, 0.12);
    border-radius: 18px;
}

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

.metric-box {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(17, 17, 17, 0.1);
    background: #fff;
}

.metric-box strong {
    display: block;
    margin-top: 8px;
    line-height: 1.4;
}

.timeline {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 14px;
}

.timeline li {
    display: grid;
    gap: 6px;
    padding: 16px 18px 16px 24px;
    border-left: 4px solid var(--green);
    border-radius: 0 18px 18px 0;
    background: rgba(255, 255, 255, 0.86);
}

@media (min-width: 840px) {
    .login-shell {
        grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
        min-height: 100vh;
        padding: 28px 0;
    }

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

    .workflow-hero {
        grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    }

    .workflow-grid {
        grid-template-columns: 0.9fr 1.1fr;
    }

    .workflow-bottom {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
    }

    .field-grid,
    .status-grid,
    .split-head,
    .split-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .split-card {
        grid-column: 1 / -1;
    }

    .split-head,
    .split-row {
        grid-template-columns: 1.4fr 0.8fr 0.8fr 0.9fr 1fr;
    }

    .materials-hero-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .materials-layout {
        grid-template-columns: minmax(300px, 0.72fr) minmax(0, 1.28fr);
    }

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

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

@media (max-width: 839px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

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

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

    .split-head {
        display: none;
    }

    .mini-header {
        flex-direction: column;
        align-items: stretch;
    }

    .mini-header-right {
        justify-content: space-between;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .brand-panel,
    .login-card,
    .metric-card,
    .roadmap-card,
    .order-entry-card,
    .state-card,
    .panel-card,
    .session-chip {
        animation: rise 420ms ease both;
    }

    .login-card {
        animation-delay: 80ms;
    }

    .metric-card:nth-child(2) {
        animation-delay: 80ms;
    }

    .metric-card:nth-child(3) {
        animation-delay: 160ms;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
