:root {
    --bg: #f5f7f4;
    --panel: #ffffff;
    --ink: #20252b;
    --muted: #66717c;
    --line: #d9e0dd;
    --gold: #b88732;
    --gold-dark: #8f6520;
    --teal: #1e6f67;
    --teal-soft: #e7f2f0;
    --red: #b4433c;
    --green: #267348;
    --blue: #2f6690;
    --purple: #7f4f9f;
    --orange: #bf6b2b;
    --shadow: 0 18px 45px rgba(28, 34, 39, 0.08);
    --shadow-soft: 0 10px 28px rgba(28, 34, 39, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(184, 135, 50, 0.09), transparent 260px),
        linear-gradient(90deg, rgba(30, 111, 103, 0.07), transparent 42%),
        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: var(--teal);
    text-decoration: none;
    font-weight: 700;
}

a:hover {
    text-decoration: underline;
}

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

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(30, 111, 103, 0.14);
    outline: none;
}

textarea {
    resize: vertical;
}

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

label span {
    font-weight: 600;
}

.checkbox-label {
    align-items: center;
    display: flex;
    gap: 10px;
    min-height: 44px;
}

.checkbox-label input {
    min-height: auto;
    width: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

tbody tr:hover {
    background: #fbfcfb;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(30, 111, 103, 0.12), transparent 38%),
        linear-gradient(300deg, rgba(184, 135, 50, 0.16), transparent 42%),
        var(--bg);
}

.public-shell {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(184, 135, 50, 0.09), transparent 260px),
        var(--bg);
}

.auth-card {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 32px;
    display: grid;
    gap: 24px;
}

.auth-card.wide {
    width: min(760px, 100%);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background:
        linear-gradient(180deg, rgba(184, 135, 50, 0.18), transparent 36%),
        #1f292c;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
}

.brand-logo {
    width: 54px;
    height: 64px;
    border-radius: 6px;
    background: #fff;
    object-fit: contain;
    padding: 4px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--gold);
    color: #fff;
    font-weight: 900;
}

.brand small,
.account small {
    display: block;
    color: rgba(255, 255, 255, 0.68);
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    border-radius: 8px;
    color: #fff;
    padding: 11px 12px;
    font-weight: 800;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.nav a:focus-visible,
.button:focus-visible {
    outline: 3px solid rgba(242, 207, 138, 0.5);
    outline-offset: 2px;
}

.account {
    margin-top: auto;
    display: grid;
    gap: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 18px;
}

.account a {
    color: #f2cf8a;
    margin-top: 6px;
}

.main {
    width: min(1220px, 100%);
    margin: 0 auto;
    padding: 32px;
}

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

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.page-header h1,
.auth-card h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.12;
}

.auth-card p {
    margin: 10px 0 0;
    color: var(--muted);
}

.eyebrow {
    color: var(--gold-dark);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.button {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    font-weight: 900;
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    text-decoration: none;
}

.button.primary {
    background: var(--teal);
    color: #fff;
    box-shadow: 0 8px 18px rgba(30, 111, 103, 0.18);
}

.button.secondary {
    background: #e7ece9;
    color: var(--ink);
}

.button.primary:hover {
    background: #185c56;
}

.button.secondary:hover {
    background: #dce5e1;
}

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

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.metric,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.metric {
    padding: 18px;
    border-top: 4px solid var(--metric-accent, var(--gold));
    position: relative;
    overflow: hidden;
}

.metric::after {
    content: "";
    position: absolute;
    right: -24px;
    top: -28px;
    width: 92px;
    height: 92px;
    border-radius: 999px;
    background: var(--metric-glow, rgba(184, 135, 50, 0.15));
}

.metric:nth-child(1) {
    --metric-accent: #1e6f67;
    --metric-glow: rgba(30, 111, 103, 0.14);
    background: linear-gradient(135deg, #ffffff 45%, #e4f2ef);
}

.metric:nth-child(2) {
    --metric-accent: #2f6690;
    --metric-glow: rgba(47, 102, 144, 0.14);
    background: linear-gradient(135deg, #ffffff 45%, #e5eff7);
}

.metric:nth-child(3) {
    --metric-accent: #267348;
    --metric-glow: rgba(38, 115, 72, 0.14);
    background: linear-gradient(135deg, #ffffff 45%, #e7f4ec);
}

.metric:nth-child(4) {
    --metric-accent: #bf6b2b;
    --metric-glow: rgba(191, 107, 43, 0.14);
    background: linear-gradient(135deg, #ffffff 45%, #fff1df);
}

.metric:nth-child(5) {
    --metric-accent: #7f4f9f;
    --metric-glow: rgba(127, 79, 159, 0.14);
    background: linear-gradient(135deg, #ffffff 45%, #f5ecfa);
}

.metric:nth-child(6) {
    --metric-accent: #b4433c;
    --metric-glow: rgba(180, 67, 60, 0.12);
    background: linear-gradient(135deg, #ffffff 45%, #f8e9e7);
}

.metric span {
    color: var(--muted);
    font-weight: 800;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    color: var(--metric-accent, var(--ink));
}

.panel {
    padding: 20px;
}

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

.panel-title h2,
.form-section h2 {
    margin: 0;
    font-size: 18px;
}

.two-column,
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 18px;
    align-items: start;
}

.dashboard-panels {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
}

.provider-panel {
    align-self: start;
}

.pipeline-list {
    display: grid;
    gap: 9px;
}

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

.pipeline-row span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
}

.pipeline-row i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: currentColor;
}

.pipeline-row strong {
    min-width: 34px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal);
    padding: 4px 8px;
    text-align: center;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.filters .button {
    align-self: end;
}

.form-panel,
.grid-form {
    display: grid;
    gap: 16px;
}

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

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

.form-section {
    display: grid;
    gap: 13px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
    border-bottom: 0;
}

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

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

.table-actions a + a {
    margin-left: 10px;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 900;
}

.status-new {
    background: #fff2cf;
    color: #7b5615;
    box-shadow: inset 0 0 0 1px rgba(184, 135, 50, 0.2);
}

.status-contacted {
    background: #e7f2f0;
    color: var(--teal);
    box-shadow: inset 0 0 0 1px rgba(30, 111, 103, 0.16);
}

.status-estimate {
    background: #e8f0f8;
    color: var(--blue);
    box-shadow: inset 0 0 0 1px rgba(47, 102, 144, 0.16);
}

.status-proposal {
    background: #f5ecfa;
    color: var(--purple);
    box-shadow: inset 0 0 0 1px rgba(127, 79, 159, 0.16);
}

.status-sold {
    background: #e9f5ee;
    color: var(--green);
    box-shadow: inset 0 0 0 1px rgba(38, 115, 72, 0.16);
}

.status-lost {
    background: #f8e9e7;
    color: var(--red);
    box-shadow: inset 0 0 0 1px rgba(180, 67, 60, 0.16);
}

.status-completed {
    background: #fff3df;
    color: var(--orange);
    box-shadow: inset 0 0 0 1px rgba(191, 107, 43, 0.16);
}

.pipeline-row.status-new,
.pipeline-row.status-contacted,
.pipeline-row.status-estimate,
.pipeline-row.status-proposal,
.pipeline-row.status-sold,
.pipeline-row.status-lost,
.pipeline-row.status-completed {
    color: var(--ink);
}

.pipeline-row.status-new i {
    color: var(--gold-dark);
}

.pipeline-row.status-contacted i {
    color: var(--teal);
}

.pipeline-row.status-estimate i {
    color: var(--blue);
}

.pipeline-row.status-proposal i {
    color: var(--purple);
}

.pipeline-row.status-sold i {
    color: var(--green);
}

.pipeline-row.status-lost i {
    color: var(--red);
}

.pipeline-row.status-completed i {
    color: var(--orange);
}

.provider-list {
    display: grid;
    gap: 9px;
}

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

.provider-row span {
    font-weight: 800;
}

.provider-row small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-top: 2px;
}

.provider-row strong {
    min-width: 34px;
    border-radius: 999px;
    background: #fff3df;
    color: var(--orange);
    padding: 4px 8px;
    text-align: center;
}

@media (prefers-reduced-motion: no-preference) {
    .status.status-new {
        animation: leadStatusPulse 2.2s ease-in-out infinite;
    }
}

@keyframes leadStatusPulse {
    0%,
    100% {
        box-shadow: inset 0 0 0 1px rgba(184, 135, 50, 0.22), 0 0 0 0 rgba(184, 135, 50, 0);
        transform: translateY(0);
    }

    50% {
        box-shadow: inset 0 0 0 1px rgba(184, 135, 50, 0.35), 0 0 0 6px rgba(184, 135, 50, 0.12);
        transform: translateY(-1px);
    }
}

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

.details div {
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.details dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.details dd {
    margin: 4px 0 0;
    font-weight: 800;
}

.description {
    border-left: 4px solid var(--gold);
    margin: 18px 0 0;
    padding-left: 14px;
    color: var(--muted);
}

.note-form,
.upload-form {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.timeline,
.file-list {
    display: grid;
    gap: 12px;
}

.timeline article,
.file-list article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: #fbfcfb;
}

.timeline small,
.file-list small {
    display: block;
    color: var(--muted);
}

.form-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.timeline p {
    margin: 8px 0 0;
}

.file-list article {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.invoice-document {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin: 0 auto;
    max-width: 920px;
    padding: 34px;
}

.invoice-top,
.invoice-parties,
.invoice-line,
.invoice-total,
.payment-boxes,
.invoice-actions {
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.invoice-top {
    align-items: flex-start;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 24px;
}

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

.invoice-brand img {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    height: 92px;
    object-fit: contain;
    padding: 6px;
    width: 74px;
}

.invoice-brand span,
.invoice-meta strong {
    display: block;
    font-size: 24px;
    font-weight: 900;
}

.invoice-brand small,
.invoice-meta small {
    color: var(--muted);
}

.invoice-meta {
    text-align: right;
}

.invoice-meta span {
    color: var(--gold-dark);
    display: block;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.invoice-parties {
    margin: 26px 0;
}

.invoice-parties > div {
    background: #fbfcfb;
    border: 1px solid var(--line);
    border-radius: 8px;
    flex: 1;
    padding: 16px;
}

.invoice-parties h2,
.payment-boxes h3 {
    margin: 5px 0 8px;
}

.invoice-parties p,
.payment-boxes p {
    color: var(--muted);
    margin: 0;
}

.invoice-line-items {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.invoice-line,
.invoice-total {
    padding: 16px;
}

.invoice-line-head {
    background: #1f292c;
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.invoice-total {
    align-items: center;
    background: #e7f2f0;
    color: var(--teal);
    font-weight: 900;
}

.invoice-total strong {
    font-size: 26px;
}

.payment-boxes {
    margin-top: 22px;
}

.payment-boxes article {
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    border-radius: 8px;
    flex: 1;
    padding: 16px;
}

.invoice-actions {
    justify-content: flex-end;
    margin-top: 22px;
}

.flash,
.notice {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 800;
}

.flash.success {
    background: #e9f5ee;
    color: var(--green);
}

.flash.error,
.notice.error {
    background: #f8e9e7;
    color: var(--red);
}

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

.empty {
    text-align: center;
    padding: 24px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

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

    .metric-grid,
    .two-column,
    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 680px) {
    .main {
        padding: 20px;
    }

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

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

    .page-header h1,
    .auth-card h1 {
        font-size: 28px;
    }

    .nav,
    .metric-grid,
    .two-column,
    .detail-grid,
    .filters,
    .grid-form,
    .details {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .auth-card {
        padding: 24px;
    }

    .button {
        width: 100%;
    }

    .invoice-document {
        padding: 22px;
    }

    .invoice-top,
    .invoice-parties,
    .invoice-line,
    .invoice-total,
    .payment-boxes,
    .invoice-actions {
        flex-direction: column;
    }

    .invoice-meta {
        text-align: left;
    }
}
