:root {
    --bg: #f3f7f5;
    --card: #ffffff;
    --card-soft: #f7fbfa;
    --text: #1b2d2a;
    --muted: #667975;
    --line: #d9e5e1;
    --line-strong: #c9dbd6;
    --primary: #2d7a78;
    --primary-dark: #215f5e;
    --primary-soft: #e6f3f0;
    --sidebar-bg: linear-gradient(180deg, #f8fcfb 0%, #eef6f4 100%);
    --danger: #d92727;
    --success: #108a52;
    --shadow: 0 20px 45px rgba(20, 55, 52, 0.08);
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    background:
        radial-gradient(circle at top left, rgba(95, 165, 159, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(45, 122, 120, 0.05), transparent 24%),
        var(--bg);
}

img,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

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

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 10px;
    left: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #fff;
    color: var(--primary-dark);
    box-shadow: var(--shadow);
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

b,
strong {
    font-weight: 800;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 294px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px 20px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    box-shadow: 18px 0 42px rgba(24, 53, 51, 0.05);
    overflow-y: auto;
}

.page-shell {
    min-height: 100vh;
    min-width: 0;
    margin-left: 294px;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

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

.sidebar-label {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

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

.sidebar-nav a,
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: #44615c;
    font-weight: 700;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.logout-form {
    margin: 0;
}

.sidebar-logout {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.sidebar-account {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 22px 0;
}

.account-password-card {
    max-width: 760px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.readiness-list,
.guide-grid {
    display: grid;
    gap: 16px;
}

.readiness-list .alert {
    display: grid;
    gap: 4px;
}

.guide-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.guide-number {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 900;
}

.plain-checklist {
    display: grid;
    gap: 10px;
    padding-left: 22px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

.sidebar-nav a:hover,
.sidebar-logout:hover {
    background: rgba(45, 122, 120, 0.08);
    color: var(--primary);
    transform: translateX(2px);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 14px 26px rgba(45, 122, 120, 0.22);
}

.nav-mark {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: rgba(45, 122, 120, 0.1);
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.sidebar-nav a.active .nav-mark {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.sidebar-user {
    margin-top: auto;
    display: grid;
    gap: 12px;
    padding-top: 8px;
}

.sidebar-close,
.sidebar-toggle {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.sidebar-close {
    display: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #e7f0ee;
    color: #416763;
}

.sidebar-toggle {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 14px 24px rgba(45, 122, 120, 0.22);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    border: 0;
    background: rgba(18, 38, 37, 0.36);
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 16px 18px 0;
    transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.mobile-brand {
    min-width: 0;
}

.mobile-brand strong,
.mobile-brand span {
    display: block;
}

.mobile-brand span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.brand-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #6bb2ae);
    color: #fff;
    font-weight: 800;
}

.brand span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.container {
    width: min(1380px, calc(100% - 40px));
    min-width: 0;
    margin: 0 auto;
    padding: 28px 0 50px;
}

.hero,
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.hero > div:first-child,
.page-head > div:first-child {
    min-width: 0;
}

.hero h1,
.page-head h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.hero p,
.page-head p {
    margin: 0;
}

.hero p:not(.eyebrow),
.page-head p:not(.eyebrow) {
    max-width: 68ch;
    color: var(--muted);
    font-size: 15px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-card {
    min-width: 190px;
    padding: 22px;
    border-radius: 22px;
    background: var(--card);
    box-shadow: var(--shadow);
    text-align: center;
}

.hero-card strong {
    display: block;
    font-size: clamp(34px, 5vw, 42px);
    color: var(--primary);
}

.hero-card span {
    color: var(--muted);
}

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

.search-panel,
.form-card,
.table-card,
.quote-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.search-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
    padding: 18px;
    margin-bottom: 18px;
}

.search-panel.compact {
    align-items: end;
}

.field {
    min-width: 180px;
    display: flex;
    flex: 1 1 180px;
    flex-direction: column;
    gap: 7px;
}

.field.grow {
    flex: 1 1 240px;
}

.field.wide {
    grid-column: span 2;
}

.field.narrow {
    flex: 0 1 160px;
    min-width: 140px;
}

label {
    color: #334c49;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    color: var(--text);
    background: #fbfefd;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(45, 122, 120, 0.14);
    border-color: var(--primary);
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 12px 15px;
    background: #edf2f1;
    color: #223634;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

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

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

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

.btn.muted {
    background: #eef3f2;
    color: var(--muted);
}

.btn.danger {
    background: #ffe8e8;
    color: var(--danger);
}

.btn.small {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 13px;
}

.btn.full {
    width: 100%;
}

.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.scroll-top-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 70;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 14px;
    background: rgba(45, 122, 120, 0.94);
    color: #fff;
    box-shadow: 0 18px 34px rgba(20, 55, 52, 0.2);
    cursor: pointer;
    font: inherit;
    font-size: 24px;
    font-weight: 800;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease, background 0.18s ease;
}

.scroll-top-button:hover {
    background: var(--primary-dark);
    transform: translateY(8px);
}

body.show-scroll-top .scroll-top-button {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

body.is-scrolling .scroll-top-button {
    opacity: 0.72;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
}

.table-card {
    overflow: hidden;
    min-width: 0;
}

.table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.table-head h2 {
    margin: 0;
    font-size: clamp(18px, 3vw, 22px);
}

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

.table-responsive {
    width: 100%;
    overflow: auto;
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
}

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

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

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f6fbfa;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.35;
}

.product-table-title {
    display: block;
    line-height: 1.28;
}

.product-measure-value {
    display: inline-block;
    color: #1f3632;
    font-size: clamp(15px, 1.4vw, 17px);
    font-weight: 800;
    line-height: 1.25;
}

td small.product-measure-meta,
.product-measure-meta {
    color: #253f3b;
    font-size: clamp(15px, 1.4vw, 17px);
    font-weight: 800;
    line-height: 1.3;
}

tr:hover td {
    background: #fbfefd;
}

.right {
    text-align: right;
}

.price {
    color: var(--success);
    font-weight: 800;
}

.pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.empty {
    padding: 30px;
    text-align: center;
    color: var(--muted);
}

.quote-card {
    position: sticky;
    top: 24px;
    width: 100%;
    padding: 18px;
}

.quote-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.quote-title h2 {
    margin: 0;
    font-size: clamp(18px, 3vw, 22px);
}

.cart-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 56vh;
    margin: 16px 0;
    overflow: auto;
}

.cart-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: #fbfefd;
}

.cart-item strong {
    display: block;
    font-size: 14px;
    margin-bottom: 8px;
}

.cart-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 8px;
    align-items: center;
}

.cart-row input {
    padding: 8px;
}

.cart-subtotal {
    margin-top: 8px;
    text-align: right;
    color: var(--success);
    font-weight: 800;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.cart-total strong {
    font-size: 24px;
    color: var(--success);
}

.hint {
    color: var(--muted);
    font-size: 13px;
}

.quote-actions {
    margin-top: 14px;
}

.form-card {
    padding: 20px;
}

.form-card h2 {
    margin: 0 0 18px;
    font-size: clamp(20px, 3vw, 24px);
}

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

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

.inline-form {
    display: inline-flex;
    margin: 0;
}

.form-actions {
    margin-top: 18px;
}

.footer {
    padding: 18px 24px 24px;
    text-align: center;
    color: var(--muted);
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.7);
}

.user-box strong,
.user-box span {
    display: block;
}

.user-box strong {
    font-size: 14px;
}

.user-box span:last-child {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 800;
}

.stack-table {
    min-width: 0;
}

@media (max-width: 1280px) {
    .grid-layout {
        grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
    }
}

@media (max-width: 1120px) {
    .hero,
    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-card {
        width: 100%;
        min-width: 0;
    }

    .search-panel .btn,
    .search-panel .link-button,
    .search-panel a.btn {
        flex: 1 1 160px;
    }
}

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

    .quote-card {
        position: static;
    }
}

@media (max-width: 980px) {
    .sidebar {
        width: min(100%, 320px);
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    .page-shell {
        margin-left: 0;
        padding-top: 58px;
    }

    .mobile-topbar {
        display: flex;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 60;
        width: auto;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .mobile-topbar .mobile-brand {
        display: none;
    }

    .mobile-topbar .sidebar-toggle {
        background: rgba(45, 122, 120, 0.94);
        box-shadow: 0 18px 32px rgba(20, 55, 52, 0.2);
        backdrop-filter: blur(12px);
    }

    body.is-scrolling .mobile-topbar {
        opacity: 0.66;
        transform: translateY(-2px);
    }

    body.sidebar-open .mobile-topbar {
        opacity: 0;
        pointer-events: none;
    }

    body.sidebar-open {
        overflow: hidden;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .sidebar-close {
        display: inline-grid;
        place-items: center;
    }
}

@media (max-width: 760px) {
    .container {
        width: min(100%, calc(100% - 22px));
        padding: 20px 0 36px;
    }

    .hero,
    .page-head {
        gap: 12px;
        margin-bottom: 18px;
    }

    .hero h1,
    .page-head h1 {
        font-size: clamp(24px, 8vw, 32px);
    }

    .hero p:not(.eyebrow),
    .page-head p:not(.eyebrow) {
        font-size: 14px;
    }

    .search-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }

    .search-panel .field,
    .search-panel .field.grow,
    .search-panel .btn,
    .search-panel a.btn,
    .search-panel .link-button {
        flex: 0 0 auto;
    }

    .field {
        min-width: 0;
    }

    .field.wide {
        grid-column: span 1;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .table-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 16px;
    }

    .form-card,
    .table-card,
    .quote-card,
    .search-panel {
        border-radius: 18px;
    }

    .quote-title,
    .cart-total,
    .form-actions,
    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cart-row {
        grid-template-columns: 1fr;
    }

    .form-actions .btn,
    .actions .btn,
    .actions a.btn {
        width: 100%;
    }

    .stack-table thead {
        display: none;
    }

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

    .stack-table tr {
        display: block;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: #fff;
    }

    .stack-table td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        padding: 10px 12px;
        border-bottom: 1px solid #edf3f2;
        text-align: left;
    }

    .stack-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .stack-table td.right {
        text-align: left;
    }

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

    .stack-table td.actions-cell {
        grid-template-columns: 1fr;
    }

    .stack-table td.actions-cell::before {
        margin-bottom: 4px;
    }

    .stack-table td.actions-cell .btn,
    .stack-table td.actions-cell a.btn {
        width: 100%;
    }

    .stack-table td.empty {
        display: block;
        text-align: center;
    }

    .stack-table td.empty::before {
        content: none;
    }

    .scroll-top-button {
        right: 14px;
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 560px) {
    .mobile-topbar {
        top: 8px;
        left: 8px;
        width: auto;
        padding: 0;
    }

    .sidebar-toggle {
        padding: 9px 12px;
        font-size: 14px;
    }

    .container {
        width: min(100%, calc(100% - 14px));
        padding: 16px 0 30px;
    }

    .sidebar {
        padding: 18px 14px;
    }

    .page-shell {
        padding-top: 54px;
    }

    .hero-card,
    .form-card,
    .quote-card,
    .search-panel {
        padding: 16px;
    }

    .table-responsive {
        max-height: none;
    }

    table {
        min-width: 680px;
    }

    th,
    td {
        padding: 10px 12px;
    }

    .btn {
        width: 100%;
        padding: 11px 14px;
    }

    input,
    select,
    textarea {
        padding: 11px 12px;
        font-size: 15px;
    }

    .stack-table td {
        grid-template-columns: 1fr;
    }

    .stack-table td::before {
        margin-bottom: 2px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .sidebar-backdrop,
    .mobile-topbar,
    .scroll-top-button,
    .search-panel,
    .table-card,
    .footer,
    .hero,
    .page-head {
        display: none !important;
    }

    .container {
        width: 100%;
        padding: 0;
    }

    .page-shell {
        margin-left: 0;
    }

    .grid-layout {
        display: block;
    }

    .quote-card {
        position: static;
        border: 0;
        box-shadow: none;
    }

    .quote-actions,
    .hint,
    [data-clear-cart],
    .remove-item {
        display: none !important;
    }

    .cart-items {
        max-height: none;
    }
}
