:root {
    --brand-green: #C1ED00;
    --brand-cream: #f6f8ef;
    --brand-black: #0b0b09;
    --muted: #6f7567;
    --line: #e3e8d8;
    --white: #ffffff;
    --danger: #d94d3f;
    --success: #2e7d32;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--brand-black);
    background: var(--brand-cream);
    font-family: Arial, Helvetica, sans-serif;
}

a {
    color: inherit;
}

.login-page {
    background:
        radial-gradient(circle at top left, rgba(193, 237, 0, 0.24), transparent 34rem),
        var(--brand-cream);
}

.login-wrapper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 48px;
    align-items: center;
    width: min(1120px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 48px 0;
}

.login-hero h1 {
    max-width: 620px;
    margin: 18px 0;
    font-size: clamp(2rem, 4vw, 4.2rem);
    font-weight: 800;
    line-height: 1.02;
}

.login-hero p {
    max-width: 540px;
    color: var(--muted);
    font-size: 1.08rem;
}

.brand-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid rgba(11, 11, 9, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    font-weight: 700;
}

.login-card {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 20px 60px rgba(11, 11, 9, 0.10);
}

.login-card-header,
.brand,
.sidebar-user,
.topbar,
.panel-header {
    display: flex;
    align-items: center;
}

.login-card-header {
    gap: 16px;
    margin-bottom: 28px;
}

.login-card-header h2 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
}

.login-card-header p {
    margin: 2px 0 0;
    color: var(--muted);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 8px;
    color: var(--brand-black);
    background: var(--brand-green);
    font-weight: 900;
}

.brand-mark.large {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    font-size: 1.35rem;
}

.form-label {
    font-weight: 700;
}

.form-control {
    min-height: 48px;
    border-color: var(--line);
    border-radius: 8px;
}

.form-select {
    min-height: 48px;
    border-color: var(--line);
    border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 0.2rem rgba(193, 237, 0, 0.28);
}

.btn-brand {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    color: var(--brand-black);
    background: var(--brand-green);
    font-weight: 800;
}

.btn-brand:hover {
    color: var(--brand-black);
    background: #add600;
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 280px;
    height: 100vh;
    padding: 24px;
    color: var(--white);
    background: var(--brand-black);
}

.brand {
    gap: 12px;
    margin-bottom: 34px;
}

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

.brand small {
    color: rgba(255, 255, 255, 0.62);
}

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

.sidebar-nav .nav-link {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-weight: 700;
}

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link:hover {
    color: var(--brand-black);
    background: var(--brand-green);
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.sidebar-user {
    gap: 12px;
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--brand-black);
    background: var(--brand-green);
    font-weight: 900;
}

.user-info strong,
.user-info small {
    display: block;
}

.user-info small {
    color: rgba(255, 255, 255, 0.58);
}

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

.content {
    width: 100%;
    min-width: 0;
    padding: 32px;
}

.topbar {
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

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

.status-action-form {
    margin: 0;
}

.delete-offer-form {
    display: inline-block;
    margin: 0;
}

.topbar h1,
.panel h2 {
    margin: 0;
    font-weight: 850;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 4px auto;
    background: var(--brand-black);
}

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

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

.summary-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
}

.summary-card {
    padding: 22px;
}

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

.summary-card strong {
    display: block;
    margin-top: 10px;
    font-size: 2rem;
    line-height: 1;
}

.summary-card.success {
    border-color: rgba(46, 125, 50, 0.28);
}

.summary-card.danger {
    border-color: rgba(217, 77, 63, 0.28);
}

.panel {
    overflow: hidden;
}

.panel-body {
    padding: 22px;
}

.panel-header {
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.table {
    margin: 0;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
    min-width: 760px;
}

.table th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.table td,
.table th {
    padding: 16px 22px;
}

.table-actions {
    white-space: nowrap;
}

.table-actions .btn {
    margin-left: 6px;
}

.table-actions .delete-offer-form {
    margin-left: 6px;
}

.table-actions .delete-offer-form .btn {
    margin-left: 0;
}

.table-primary-link {
    color: var(--brand-black);
    font-weight: 850;
    text-decoration: none;
}

.table-primary-link:hover {
    text-decoration: underline;
}

.table-muted {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.86rem;
}

.empty-state {
    padding: 42px 22px !important;
    color: var(--muted);
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: #edf1e3;
    color: var(--brand-black);
    font-size: 0.82rem;
    font-weight: 800;
}

.status-badge.approved {
    background: rgba(46, 125, 50, 0.14);
    color: var(--success);
}

.status-badge.customer_approved {
    background: rgba(46, 125, 50, 0.18);
    color: var(--success);
}

.status-badge.cancelled {
    background: rgba(217, 77, 63, 0.14);
    color: var(--danger);
}

.status-badge.customer_rejected {
    background: rgba(217, 77, 63, 0.16);
    color: var(--danger);
}

.status-badge.editing {
    background: rgba(193, 237, 0, 0.35);
}

.filter-panel {
    margin-bottom: 22px;
}

.filter-form {
    padding: 22px;
}

.filter-grid {
    display: grid;
    gap: 16px;
    align-items: end;
}

.all-offers-filter {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.status-filter {
    grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(180px, 1fr));
}

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

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

.offer-meta-panel {
    padding: 22px;
}

.offer-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 180px;
    gap: 16px;
}

.offer-party-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 22px;
}

.offer-party-grid > .panel {
    overflow: visible;
}

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

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

.customer-autocomplete {
    position: relative;
}

.customer-suggestions {
    position: absolute;
    z-index: 12;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 16px 36px rgba(11, 11, 9, 0.12);
}

.customer-suggestions.is-open {
    display: grid;
}

.customer-suggestion-item {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--brand-black);
    background: var(--white);
    text-align: left;
}

.customer-suggestion-item:last-child {
    border-bottom: 0;
}

.customer-suggestion-item:hover,
.customer-suggestion-item:focus {
    background: var(--brand-cream);
}

.customer-suggestion-item strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.25;
}

.customer-suggestion-item span {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.customer-suggestion-empty {
    padding: 12px 14px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.company-panel {
    position: relative;
}

.company-logo-wrap {
    display: flex;
    justify-content: flex-end;
    padding: 22px 22px 0;
}

.company-logo {
    max-width: 150px;
    max-height: 68px;
    object-fit: contain;
}

.company-logo-placeholder {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
    font-size: 1.6rem;
}

.company-info {
    display: grid;
    gap: 9px;
    color: var(--muted);
}

.company-info strong {
    color: var(--brand-black);
    font-size: 1.1rem;
}

.offer-lines {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.offer-line {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf7;
}

.line-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1.3fr) minmax(180px, 1fr) 100px 140px 140px 44px;
    gap: 12px;
    align-items: end;
}

.line-actions {
    display: flex;
    align-items: end;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 8px;
    color: var(--brand-black);
    background: var(--brand-green);
    font-size: 1.45rem;
    font-weight: 900;
    line-height: 1;
}

.icon-button:hover {
    background: #add600;
}

.icon-button.danger {
    color: var(--danger);
    background: rgba(217, 77, 63, 0.12);
}

.icon-button.danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.line-tools {
    margin-top: 12px;
}

.detail-toggle {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    color: var(--brand-black);
    background: transparent;
    font-weight: 800;
}

.detail-toggle span {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-green);
    font-size: 1.05rem;
    line-height: 1;
}

.line-detail {
    display: none;
    margin-top: 12px;
}

.line-detail.is-open {
    display: block;
}

.line-total {
    color: var(--brand-black);
    background: #f1f4e8;
    font-weight: 800;
}

.totals-box {
    display: grid;
    gap: 10px;
    width: min(420px, calc(100% - 44px));
    margin: 0 22px 22px auto;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--brand-black);
    color: var(--white);
}

.totals-box div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.totals-box span {
    color: rgba(255, 255, 255, 0.72);
}

.totals-box strong,
.totals-box strong span {
    color: var(--white);
}

.totals-box .grand-total {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.totals-box .grand-total strong,
.totals-box .grand-total strong span {
    color: var(--brand-green);
    font-size: 1.2rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.form-actions .btn {
    min-width: 160px;
}

.offer-view-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 22px;
    margin-bottom: 22px;
}

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

.detail-list div {
    display: grid;
    gap: 4px;
}

.detail-list span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-list strong {
    font-weight: 700;
}

.item-detail {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.view-totals {
    margin-top: 22px;
}

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

.settings-form + .settings-form {
    margin-top: 22px;
}

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

.logo-settings {
    display: grid;
    gap: 14px;
}

.logo-preview-box {
    display: grid;
    place-items: center;
    min-height: 150px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfcf7;
}

.settings-logo-preview {
    max-width: 220px;
    max-height: 110px;
    object-fit: contain;
}

.form-help,
.current-logo-path {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.settings-actions {
    margin-top: 0;
}

.public-link-panel {
    margin-bottom: 22px;
}

.copy-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.public-offer-page {
    background: var(--brand-cream);
}

.public-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.public-document,
.public-message {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 18px 52px rgba(11, 11, 9, 0.08);
}

.public-message {
    display: grid;
    place-items: center;
    gap: 16px;
    min-height: 360px;
    padding: 34px;
    text-align: center;
}

.public-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 24px;
    align-items: start;
    padding: 30px;
    border-bottom: 1px solid var(--line);
}

.public-header h1 {
    margin: 0 0 10px;
    font-weight: 900;
}

.brand-line {
    width: 86px;
    height: 6px;
    margin-bottom: 14px;
    background: var(--brand-green);
}

.public-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-weight: 700;
}

.public-logo-wrap {
    display: flex;
    justify-content: flex-end;
}

.public-logo {
    max-width: 190px;
    max-height: 86px;
    object-fit: contain;
}

.public-party-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border-bottom: 1px solid var(--line);
}

.public-party-grid article {
    padding: 24px 30px;
}

.public-party-grid article + article {
    border-left: 1px solid var(--line);
}

.public-party-grid h2,
.public-response-panel h2 {
    margin: 0 0 14px;
    font-size: 1.12rem;
    font-weight: 850;
}

.public-party-grid p {
    margin: 0 0 7px;
    color: var(--muted);
}

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

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

.public-items-table th {
    padding: 14px 18px;
    color: var(--brand-black);
    background: var(--brand-green);
    font-size: 0.78rem;
    text-align: left;
    text-transform: uppercase;
}

.public-items-table td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.public-items-table th:nth-child(3),
.public-items-table th:nth-child(4),
.public-items-table th:nth-child(5),
.public-items-table td:nth-child(3),
.public-items-table td:nth-child(4),
.public-items-table td:nth-child(5) {
    text-align: right;
    white-space: nowrap;
}

.public-total-box {
    display: grid;
    gap: 10px;
    width: min(420px, calc(100% - 60px));
    margin: 24px 30px 0 auto;
    padding: 18px;
    border-radius: 8px;
    color: var(--white);
    background: var(--brand-black);
}

.public-total-box div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.public-total-box span {
    color: rgba(255, 255, 255, 0.72);
}

.public-total-box .grand-total {
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.public-total-box .grand-total strong {
    color: var(--brand-green);
    font-size: 1.2rem;
}

.public-response-panel {
    margin: 24px 30px 30px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf7;
}

.public-response-panel p {
    margin: 0 0 8px;
    color: var(--muted);
}

.public-response-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 992px) {
    .login-wrapper {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        width: min(82vw, 280px);
        transform: translateX(-100%);
        box-shadow: 18px 0 44px rgba(11, 11, 9, 0.22);
        transition: transform 0.2s ease;
    }

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

    .sidebar-toggle {
        display: inline-block;
    }

    .content {
        padding: 24px 16px;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn,
    .topbar-actions .status-action-form,
    .topbar-actions .status-action-form .btn {
        flex: 1 1 auto;
    }

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

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

    .offer-meta-grid,
    .offer-party-grid,
    .offer-view-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

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

    .line-actions {
        align-items: center;
    }

    .all-offers-filter,
    .status-filter {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .public-header,
    .public-party-grid {
        grid-template-columns: 1fr;
    }

    .public-party-grid article + article {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .public-logo-wrap {
        justify-content: flex-start;
    }
}

@media (max-width: 576px) {
    body {
        overflow-x: hidden;
    }

    .content {
        padding: 18px 12px;
    }

    .login-card {
        padding: 24px;
    }

    .topbar {
        gap: 14px;
        margin-bottom: 18px;
    }

    .topbar h1 {
        font-size: 1.55rem;
        line-height: 1.18;
    }

    .summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }

    .summary-card {
        padding: 18px;
    }

    .summary-card strong {
        font-size: 1.65rem;
    }

    .topbar {
        align-items: flex-start;
        justify-content: flex-start;
    }

    .panel-header {
        align-items: flex-start;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .panel-header .btn,
    .panel-header .status-action-form,
    .panel-header .status-action-form .btn,
    .topbar-actions .btn,
    .topbar-actions .status-action-form,
    .topbar-actions .status-action-form .btn,
    .modal-footer .btn,
    .form-actions .btn {
        width: 100%;
    }

    .panel,
    .summary-card {
        border-radius: 10px;
    }

    .panel-header {
        padding: 16px;
    }

    .table-responsive {
        margin-right: -16px;
        margin-left: -16px;
        padding-right: 16px;
        padding-left: 16px;
    }

    .table-responsive .table {
        min-width: 680px;
    }

    .table td,
    .table th {
        padding: 12px 14px;
    }

    .table-actions {
        white-space: normal;
    }

    .table-actions .btn {
        display: block;
        width: 100%;
        margin: 6px 0 0;
    }

    .table-actions .delete-offer-form {
        display: block;
        width: 100%;
        margin: 6px 0 0;
    }

    .table-actions .delete-offer-form .btn {
        width: 100%;
        margin: 0;
    }

    .form-grid,
    .line-grid,
    .all-offers-filter,
    .status-filter {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: stretch;
        flex-direction: column;
    }

    .filter-actions .btn {
        width: 100%;
    }

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

    .public-shell {
        width: min(100% - 18px, 1080px);
        padding: 12px 0;
    }

    .public-header,
    .public-party-grid article {
        padding: 20px;
    }

    .public-total-box {
        width: calc(100% - 40px);
        margin: 20px 20px 0;
    }

    .public-response-panel {
        margin: 20px;
    }

    .public-response-actions .btn {
        width: 100%;
    }

    .totals-box {
        width: calc(100% - 32px);
        margin: 0 16px 16px;
        padding: 16px;
    }

    .totals-box div {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .totals-box .grand-total strong,
    .totals-box .grand-total strong span {
        font-size: 1.12rem;
    }

    .offer-lines,
    .panel-body,
    .offer-meta-panel {
        padding: 16px;
    }

    .offer-line {
        padding: 14px;
    }

    .line-actions {
        align-items: stretch;
    }

    .line-actions .icon-button {
        width: 100%;
    }

    .detail-toggle {
        width: 100%;
        justify-content: center;
        background: rgba(193, 237, 0, 0.16);
    }

    .form-actions {
        justify-content: stretch;
    }

    .modal-dialog {
        margin: 12px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .modal-footer > * {
        margin: 0;
    }
}
