:root {
    --bg: #f3efe7;
    --panel: #fffdf8;
    --panel-strong: #f5ede1;
    --line: #dccfbe;
    --text: #1b2b2a;
    --muted: #6e776f;
    --accent: #146356;
    --accent-soft: #d9efe9;
    --danger: #b44d45;
    --danger-soft: #f7e3e0;
    --warning: #b67c1f;
    --shadow: 0 18px 44px rgba(32, 32, 32, 0.08);
    --radius: 20px;
    --radius-small: 12px;
    --sidebar-width: 288px;
    --font-main: "Trebuchet MS", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-main);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(20, 99, 86, 0.12), transparent 32%),
        linear-gradient(180deg, #f7f2e9 0%, #efe8dc 100%);
}

body {
    line-height: 1.5;
}

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

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

.hidden {
    display: none !important;
}

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

.eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.lead {
    margin: 0;
    font-size: 1.05rem;
    color: var(--muted);
}

.lead--small {
    max-width: 760px;
}

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: rgba(17, 42, 39, 0.94);
    color: #f4efe7;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar__brand p,
.sidebar__footer p,
.sidebar__footer small {
    margin: 0;
}

.sidebar__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f1d9b7, #dbc39c);
    color: #102a27;
    font-weight: 700;
}

.sidebar__nav {
    display: grid;
    gap: 0.4rem;
}

.sidebar__footer {
    margin-top: auto;
    padding: 1rem;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.78);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0.95rem;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.82);
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
    color: #fff;
}

.nav-link__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.09);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.shell__content {
    padding: 1.5rem 1.5rem 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.topbar h1 {
    margin: 0;
    font-size: 2rem;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workspace,
.stack {
    display: grid;
    gap: 1rem;
}

.card {
    background: rgba(255, 253, 248, 0.9);
    border: 1px solid rgba(220, 207, 190, 0.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.section-head h2 {
    margin: 0;
    font-size: 1.35rem;
}

.stats-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stats-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card {
    padding: 1rem;
    border-radius: 18px;
    background: linear-gradient(180deg, #fff9ef 0%, #f2eadf 100%);
    border: 1px solid rgba(220, 207, 190, 0.9);
}

.stat-card span {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--muted);
}

.stat-card strong {
    font-size: 1.6rem;
}

.two-column {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1fr;
}

.two-column--wide {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

.stage-list {
    display: grid;
    gap: 0.75rem;
}

.stage-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--panel-strong);
    border-radius: 14px;
}

.stage-row__label {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.stage-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.table-wrap {
    overflow: auto;
}

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

.table th,
.table td {
    text-align: left;
    padding: 0.8rem 0.7rem;
    border-bottom: 1px solid rgba(220, 207, 190, 0.75);
    vertical-align: top;
}

.table thead th {
    color: var(--muted);
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.table-link {
    color: var(--accent);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

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

.button--primary {
    color: #fff;
    background: linear-gradient(135deg, #146356 0%, #1e7a6c 100%);
    box-shadow: 0 12px 24px rgba(20, 99, 86, 0.22);
}

.button--secondary {
    color: var(--text);
    background: #efe5d5;
    border-color: #d8c5ad;
}

.button--ghost {
    color: var(--text);
    background: #fffaf2;
    border-color: #dac8b2;
}

.button--compact {
    padding: 0.6rem 0.85rem;
    font-size: 0.92rem;
}

.button--wide {
    width: 100%;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field--compact {
    min-width: 220px;
}

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

.field span {
    font-size: 0.92rem;
    color: var(--muted);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 0.82rem 0.9rem;
    border-radius: 14px;
    border: 1px solid #cfbea7;
    background: #fffdf9;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #1f7a6c;
    box-shadow: 0 0 0 4px rgba(31, 122, 108, 0.12);
}

.field-error {
    min-height: 1.1rem;
    color: var(--danger);
    font-size: 0.84rem;
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(180, 77, 69, 0.12);
}

.form-message {
    min-height: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.form-message.is-error {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: var(--danger-soft);
    color: var(--danger);
}

.form-message.is-success {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: var(--accent-soft);
    color: var(--accent);
}

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

.actions-row {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.profile-chip {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.92);
    border: 1px solid rgba(220, 207, 190, 0.9);
}

.profile-chip__meta {
    display: grid;
}

.profile-chip__meta span {
    color: var(--muted);
    font-size: 0.88rem;
}

.segmented {
    display: inline-flex;
    padding: 0.3rem;
    border-radius: 999px;
    background: #f0e6d8;
}

.segmented__item {
    border: 0;
    background: transparent;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
}

.segmented__item.is-active {
    background: #fffdf9;
    color: var(--text);
    box-shadow: 0 4px 12px rgba(17, 42, 39, 0.08);
}

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

.kanban__column {
    display: grid;
    gap: 0.9rem;
    align-content: start;
    padding: 1rem;
    min-height: 260px;
    background: rgba(255, 253, 248, 0.78);
    border: 1px solid rgba(220, 207, 190, 0.85);
    border-radius: var(--radius);
}

.kanban__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.kanban__header strong {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.kanban__card {
    display: grid;
    gap: 0.55rem;
    padding: 0.9rem;
    border-radius: 16px;
    background: #fffaf2;
    border: 1px solid rgba(216, 197, 173, 0.8);
    box-shadow: 0 10px 26px rgba(32, 32, 32, 0.06);
}

.kanban__card-title {
    margin: 0;
    font-size: 1rem;
}

.kanban__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.pill,
.status-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.32rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
}

.pill {
    background: #efe5d5;
    color: #624c2d;
}

.status-pill,
.status-badge {
    background: #ddece7;
    color: #11584b;
}

.feature-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.feature-card {
    padding: 1rem;
    border-radius: 16px;
    background: linear-gradient(180deg, #fff9ef 0%, #f3ecdf 100%);
    border: 1px solid rgba(220, 207, 190, 0.9);
}

.feature-card p {
    margin: 0.45rem 0 0;
    color: var(--muted);
}

.subcard {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: 18px;
    background: #fffaf2;
    border: 1px solid rgba(216, 197, 173, 0.75);
}

.inline-edit {
    display: grid;
    gap: 0.8rem;
    padding: 0.6rem 0;
}

.inline-edit__grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-edit__grid--tenant {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.inline-edit__toolbar {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-edit__actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.deal-items {
    grid-column: 1 / -1;
    display: grid;
    gap: 0.85rem;
}

.deal-item {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 1rem;
    border-radius: 18px;
    background: #fbf6ed;
    border: 1px solid rgba(220, 207, 190, 0.85);
}

.deal-card {
    display: grid;
    gap: 0.9rem;
    padding: 0.6rem 0;
}

.deal-card__head,
.deal-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.deal-card__summary {
    display: grid;
    gap: 0.3rem;
    justify-items: end;
}

.deal-card__actions {
    display: flex;
    justify-content: flex-start;
}

.item-list,
.deal-documents {
    display: grid;
    gap: 0.5rem;
}

.item-list__row,
.deal-documents__item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    background: #fffaf2;
    border: 1px solid rgba(216, 197, 173, 0.75);
}

.kanban__column.is-drop-target {
    outline: 2px dashed rgba(20, 99, 86, 0.5);
    outline-offset: -8px;
}

.kanban__card.is-dragging {
    opacity: 0.55;
}

.checkbox-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.check-pill {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.8rem 0.9rem;
    border-radius: 14px;
    background: #fffdf9;
    border: 1px solid rgba(216, 197, 173, 0.85);
}

.check-pill input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.org-meta,
.tag-list,
.contact-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.contact-list {
    display: grid;
    gap: 0.85rem;
}

.entity-hero {
    display: grid;
    gap: 1rem;
}

.entity-hero__stats {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.entity-summary {
    display: grid;
    gap: 0.85rem;
}

.entity-summary div,
.timeline__item,
.linked-list__item {
    padding: 0.95rem 1rem;
    border-radius: 16px;
    border: 1px solid rgba(216, 197, 173, 0.75);
    background: #fffaf2;
}

.entity-summary span {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.linked-list,
.timeline {
    display: grid;
    gap: 0.75rem;
}

.linked-list__item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.linked-list__item--documents {
    align-items: flex-start;
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-layout {
    width: min(1120px, 100%);
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.1fr 0.9fr;
}

.auth-layout--error {
    max-width: 680px;
    grid-template-columns: 1fr;
}

.auth-panel {
    border-radius: 28px;
    border: 1px solid rgba(220, 207, 190, 0.9);
    box-shadow: var(--shadow);
    background: rgba(255, 253, 248, 0.94);
    padding: 2rem;
}

.auth-panel--hero {
    background:
        radial-gradient(circle at top left, rgba(20, 99, 86, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(255, 249, 239, 0.98) 0%, rgba(244, 236, 223, 0.98) 100%);
}

.auth-panel h1 {
    margin: 0 0 1rem;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.02;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.auth-list {
    margin: 1.5rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
}

.debug-box {
    padding: 1rem;
    overflow: auto;
    border-radius: 16px;
    background: #1f2423;
    color: #f4f4f4;
}

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

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

    .topbar,
    .topbar__actions,
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .two-column,
    .two-column--wide,
    .auth-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .shell__content,
    .sidebar,
    .card,
    .auth-panel {
        padding: 1rem;
    }

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

    .field--wide,
    .actions-row {
        grid-column: auto;
    }

    .inline-edit__grid,
    .inline-edit__grid--tenant,
    .deal-item {
        grid-template-columns: 1fr;
    }

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