:root {
    --peach: #ffc4a8;
    --green: #5b845a;
    --coral: #ef865f;
    --white: #ffffff;
    --paper: #fbf8f4;
    --paper-soft: #f6f0eb;
    --ink: #24211d;
    --muted: #81766f;
    --quiet: #a49a94;
    --line: #eaded6;
    --line-soft: rgba(234, 222, 214, 0.64);
    --glass: rgba(255, 255, 255, 0.78);
    --shadow: 0 22px 60px rgba(59, 48, 39, 0.075);
    --shadow-soft: 0 14px 36px rgba(59, 48, 39, 0.055);
    --radius: 8px;
    --radius-lg: 18px;
    --serif: "Playfair Display", Georgia, serif;
    --sans: Inter, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        linear-gradient(120deg, rgba(255, 196, 168, 0.13), rgba(255, 255, 255, 0) 34%),
        linear-gradient(180deg, var(--paper), #fffdfb 58%, #f7f1ed);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
}

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

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

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: 252px;
    padding: 38px 24px;
    background: rgba(255, 255, 255, 0.88);
    border-right: 1px solid var(--line-soft);
    box-shadow: 10px 0 40px rgba(91, 132, 90, 0.035);
    backdrop-filter: blur(18px);
    transition: transform 0.24s ease;
}

.brand,
.login-brand {
    display: grid;
    gap: 4px;
    color: var(--ink);
}

.brand {
    margin-bottom: 48px;
}

.brand span,
.login-brand span {
    font-family: var(--serif);
    font-size: 31px;
    font-weight: 600;
}

.brand small,
.login-brand small {
    color: var(--ink);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

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

.sidebar-nav a {
    position: relative;
    padding: 13px 15px;
    border-radius: var(--radius);
    color: #756d67;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-nav a::before {
    content: "";
    position: absolute;
    inset: 12px auto 12px 0;
    width: 2px;
    border-radius: 999px;
    background: transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 196, 168, 0.18);
    color: var(--ink);
    transform: translateX(1px);
}

.sidebar-nav a.active {
    background: rgba(255, 196, 168, 0.24);
    color: var(--ink);
    font-weight: 700;
}

.sidebar-nav a.active::before {
    background: var(--green);
}

.main-content {
    width: calc(100% - 252px);
    min-width: 0;
    min-height: 100vh;
    padding: 42px;
    margin-left: 252px;
}

.menu-toggle {
    display: none;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--coral);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--serif);
    color: var(--ink);
    font-weight: 600;
}

h1 {
    font-size: 52px;
    line-height: 1;
}

h2 {
    font-size: 26px;
    line-height: 1.1;
}

h3 {
    font-size: 19px;
}

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

.page-subtitle {
    max-width: 455px;
    margin: 0;
    line-height: 1.65;
    text-align: right;
}

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

.metric-card,
.panel,
.contract-card,
.login-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.metric-card {
    position: relative;
    overflow: hidden;
    min-height: 124px;
    padding: 24px 24px 22px;
    isolation: isolate;
}

.metric-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    background: var(--peach);
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(145deg, rgba(255, 196, 168, 0.08), rgba(255, 255, 255, 0) 52%);
}

.accent-green::before {
    background: var(--green);
}

.accent-coral::before {
    background: var(--coral);
}

.accent-peach::before {
    background: var(--peach);
}

.metric-card span {
    display: block;
    margin-bottom: 20px;
    color: var(--quiet);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    font-family: var(--sans);
    font-size: 28px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
}

.content-grid {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.dashboard-table-area {
    grid-template-columns: 1fr;
    min-width: 0;
}

.dashboard-table-area .wide-panel {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.two-columns {
    grid-template-columns: minmax(0, 1fr) 340px;
}

.panel {
    padding: 26px;
    min-width: 0;
}

.section-title,
.actions-row,
.contract-actions,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-title {
    margin-bottom: 20px;
}

.section-title.compact {
    margin: 4px 0 14px;
}

.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(91, 132, 90, 0.45);
    border-radius: 999px;
    padding: 10px 18px;
    background: transparent;
    color: var(--green);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    background: rgba(91, 132, 90, 0.08);
    box-shadow: 0 8px 20px rgba(91, 132, 90, 0.08);
}

.btn.primary {
    border-color: var(--green);
    background: var(--green);
    color: var(--white);
}

.btn.primary:hover {
    background: #50764f;
}

.btn.subtle {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.78);
    color: var(--ink);
}

.btn.text {
    min-height: auto;
    border: 0;
    padding: 8px;
    color: var(--muted);
    box-shadow: none;
}

.btn.danger,
.danger {
    color: #ad4a39;
}

.btn.wide {
    width: 100%;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

.dashboard-table-area table {
    min-width: 1240px;
}

.deadline-selected {
    margin-bottom: 24px;
}

.deadline-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.deadline-card {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    padding: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(251, 248, 244, 0.56));
}

.deadline-card h3 {
    margin-bottom: 18px;
    color: var(--green);
    font-size: 25px;
}

.deadline-card dl {
    display: grid;
    gap: 10px;
    margin: 0;
}

.deadline-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 9px;
}

.deadline-card dt {
    color: var(--quiet);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.deadline-card dd {
    margin: 0;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.deadline-controls {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.deadline-actions {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.deadline-badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 7px 11px;
    background: #edf4ec;
    color: var(--green);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.deadline-atrasado {
    background: #fff0ec;
    color: #ad4a39;
}

.deadline-aguardando,
.deadline-aguardando_fotos,
.deadline-aguardando_escolha {
    background: #fff8ed;
    color: #9b7048;
}

.deadline-em_producao,
.deadline-em_andamento {
    background: #edf4ec;
    color: var(--green);
}

.deadline-entregue {
    background: #f2f0eb;
    color: var(--muted);
}

.deadline-table .btn {
    min-height: 36px;
}

.dashboard-search {
    display: flex;
    justify-content: center;
    margin: -4px 0 22px;
}

.dashboard-search input {
    width: min(360px, 100%);
    height: 44px;
    border-radius: 999px;
    padding: 0 20px;
    text-align: center;
    background: rgba(251, 248, 244, 0.76);
}

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

th,
td {
    padding: 15px 14px;
    border-bottom: 1px solid rgba(234, 222, 214, 0.72);
    text-align: left;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

th {
    color: var(--quiet);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

tbody tr {
    transition: background 0.18s ease;
}

tbody tr:hover {
    background: rgba(255, 196, 168, 0.08);
}

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

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    background: #f6eee9;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-ativo {
    background: #edf4ec;
    color: var(--green);
}

.status-cancelado {
    background: #fff0ec;
    color: #ad4a39;
}

.contract-list {
    display: grid;
    gap: 18px;
}

.contract-card {
    padding: 26px;
}

.contract-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.contract-top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.contract-card-head .muted {
    margin: 8px 0 0;
}

.mini-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
    margin: 22px 0;
}

.mini-metrics span {
    display: grid;
    gap: 6px;
    padding: 13px 14px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: rgba(251, 248, 244, 0.52);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.mini-metrics b {
    color: var(--quiet);
    font-size: 11px;
    text-transform: uppercase;
}

.contract-details {
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    padding: 16px 0;
}

.contract-details summary {
    cursor: pointer;
    color: var(--green);
    font-weight: 700;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    margin-top: 18px;
    min-width: 0;
}

.inline-edit {
    display: grid;
    grid-template-columns: minmax(70px, 1fr) minmax(120px, 1fr) minmax(140px, 1fr) minmax(86px, auto) minmax(140px, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: rgba(251, 248, 244, 0.48);
}

.inline-edit input {
    min-width: 0;
}

.inline-edit > span {
    min-width: 0;
    line-height: 1.2;
}

.contract-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

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

.form-grid.three {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

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

.form-section .form-grid + .form-grid {
    margin-top: 16px;
}

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

.span-three {
    grid-column: span 3;
}

label,
.field-label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(234, 222, 214, 0.95);
    border-radius: 12px;
    padding: 13px 14px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(239, 134, 95, 0.72);
    box-shadow: 0 0 0 4px rgba(239, 134, 95, 0.11);
    background: var(--white);
}

.money-field {
    position: relative;
}

.money-field input {
    padding-left: 42px;
}

.money-field::after {
    content: "R$";
    position: absolute;
    left: 14px;
    bottom: 13px;
    color: var(--quiet);
    font-weight: 700;
}

.check-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    color: var(--muted);
}

.check-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--green);
}

.check-row.small {
    min-height: 0;
    font-size: 12px;
}

.form-section {
    margin: 0 0 22px;
    padding: 24px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(251, 248, 244, 0.46));
}

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

.form-section legend {
    width: 100%;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--green);
    font-family: var(--serif);
    font-size: 23px;
    font-weight: 600;
}

.question-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 15px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
    min-width: 0;
    overflow: hidden;
}

.question-card strong {
    color: var(--ink);
    font-size: 13px;
    line-height: 1.25;
}

.question-card .conditional {
    grid-column: 1 / -1;
}

.segmented {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(251, 248, 244, 0.74);
    width: 178px;
    max-width: 100%;
}

.segmented label {
    display: inline-flex;
    min-width: 0;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.segmented span {
    display: inline-flex;
    width: 100%;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented input:checked + span {
    background: var(--white);
    color: var(--green);
    box-shadow: 0 7px 18px rgba(59, 48, 39, 0.08);
}

.conditional {
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    opacity: 0;
    transition: grid-template-rows 0.22s ease, opacity 0.18s ease, margin-top 0.18s ease;
}

.conditional > * {
    min-height: 0;
}

.conditional.show {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: 2px;
}

.installments-box {
    padding: 18px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    background: rgba(251, 248, 244, 0.62);
}

.installment-row {
    display: grid;
    grid-template-columns: 92px 1fr 1fr 92px 1fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
}

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

.form-hint.error {
    color: #ad4a39;
}

.form-hint.ok {
    color: var(--green);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    place-items: center;
    padding: 26px;
    background: rgba(36, 34, 31, 0.42);
    backdrop-filter: blur(8px);
}

.modal.open {
    display: grid;
}

.modal-dialog {
    width: min(1050px, 100%);
    max-height: 92vh;
    overflow: auto;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.68);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 34px 90px rgba(36, 34, 31, 0.22);
    animation: modalIn 0.22s ease;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.modal-actions {
    position: sticky;
    bottom: -30px;
    margin: 22px -30px -30px;
    padding: 18px 30px;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid var(--line-soft);
    backdrop-filter: blur(14px);
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #edf4ec;
    color: var(--green);
    font-weight: 700;
}

.flash-error {
    background: #fff0ec;
    color: #ad4a39;
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(255, 196, 168, 0.18), rgba(91, 132, 90, 0) 34%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(36, 34, 31, 0.08)),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 18px),
        #5b845a;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(458px, 100%);
    padding: 44px;
    border: 1px solid rgba(255, 255, 255, 0.58);
    background: var(--glass);
    box-shadow: 0 30px 90px rgba(32, 43, 31, 0.26);
    backdrop-filter: blur(18px);
}

.login-brand {
    justify-items: center;
    margin-bottom: 34px;
    text-align: center;
}

.login-brand span {
    color: var(--ink);
    font-size: 40px;
    line-height: 1.05;
}

.login-brand small {
    color: var(--ink);
    font-size: 13px;
    text-transform: none;
}

.page-contracts .page-head,
.page-contracts .contract-card,
.page-contracts .contract-card-head,
.page-contracts .mini-metrics,
.page-contracts th,
.page-contracts td {
    text-align: center;
}

.page-contracts .contract-details {
    text-align: left;
}

.page-contracts .contract-details summary,
.page-contracts .contract-details h3 {
    text-align: center;
}

.page-contracts .contract-card-head {
    align-items: center;
}

.page-contracts .contract-card-head > div:first-child {
    flex: 1;
}

.page-contracts .contract-actions {
    justify-content: center;
}

.login-card .form-grid {
    gap: 18px;
}

.fade-in {
    animation: fadeIn 0.28s ease both;
}

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

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-columns,
    .detail-grid {
        grid-template-columns: 1fr;
    }

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

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

@media (max-width: 760px) {
    body.menu-open {
        overflow: hidden;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(306px, 86vw);
    }

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

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 15;
        display: none;
        background: rgba(36, 34, 31, 0.28);
        backdrop-filter: blur(4px);
    }

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

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

    .menu-toggle {
        display: inline-flex;
        margin-bottom: 18px;
        border: 1px solid var(--line);
        border-radius: 999px;
        padding: 10px 16px;
        background: rgba(255, 255, 255, 0.86);
        color: var(--green);
        font-weight: 700;
    }

    .page-head,
    .contract-card-head,
    .contract-top-actions,
    .section-title,
    .actions-row,
    .contract-actions,
    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-subtitle {
        text-align: left;
    }

    .metric-grid,
    .form-grid,
    .form-grid.three,
    .dashboard-search,
    .mini-metrics,
    .installment-row,
    .question-card {
        grid-template-columns: 1fr;
    }

    .span-two,
    .span-three {
        grid-column: auto;
    }

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

    .responsive-contracts table,
    .responsive-contracts thead,
    .responsive-contracts tbody,
    .responsive-contracts th,
    .responsive-contracts td,
    .responsive-contracts tr {
        display: block;
    }

    .responsive-contracts thead {
        display: none;
    }

    .responsive-contracts tr {
        margin-bottom: 14px;
        border: 1px solid var(--line-soft);
        border-radius: 16px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.9);
    }

    .responsive-contracts td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        border: 0;
        padding: 9px 0;
        white-space: normal;
    }

    .responsive-contracts td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
    }

    .inline-edit {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 10px;
        align-items: end;
    }

    .modal-dialog {
        max-height: 94vh;
        padding: 22px;
        border-radius: 20px 20px 0 0;
    }

    .modal-actions {
        bottom: -22px;
        margin: 18px -22px -22px;
        padding: 16px 22px;
    }

    .login-card {
        padding: 34px 24px;
    }

    h1 {
        font-size: 38px;
    }

    .login-brand span {
        font-size: 34px;
    }
}
