:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --sidebar: #0f172a;
    --sidebar-soft: #1e293b;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #15803d;
    --primary-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #ffedd5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--text);
}

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

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

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: white;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 24px;
    background: linear-gradient(135deg, #22c55e, #15803d);
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.35);
}

.brand h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 3px;
}

.menu-title {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 12px;
    margin-bottom: 8px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu a {
    color: rgba(255, 255, 255, 0.84);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s ease;
}

.menu a:hover,
.menu a.active {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    transform: translateX(3px);
}

.menu .icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.06);
    font-size: 15px;
}

.sidebar-footer {
    margin-top: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 18px;
    padding: 16px;
}

.sidebar-footer .small {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}

.sidebar-footer strong {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

.logout-link {
    display: inline-flex;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 700;
    color: #dcfce7;
}

.content {
    padding: 26px;
}

.topbar {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius-xl);
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.topbar h2 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.topbar p {
    color: var(--muted);
    margin-top: 6px;
    font-size: 14px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search {
    min-width: 280px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    color: var(--muted);
    font-size: 14px;
}

.user {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px 14px;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    background: linear-gradient(135deg, #16a34a, #14532d);
}

.user small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

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

.page-body {
    display: block;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary);
}

.small {
    font-size: 13px;
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
}

.alert-success {
    background: #ecfdf3;
    border-color: #abefc6;
    color: #067647;
}

.alert-error {
    background: #fef3f2;
    border-color: #fecdca;
    color: #b42318;
}

.hero {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 22px;
    margin-bottom: 22px;
}

.hero-card,
.panel,
.table-card,
.form-card,
.metric-card {
    background: var(--panel);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.hero-card {
    padding: 28px;
    background: linear-gradient(135deg, #14532d 0%, #166534 45%, #22c55e 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    right: -70px;
    top: -70px;
}

.hero-card h3 {
    font-size: 15px;
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 12px;
}

.hero-card .value {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 8px;
}

.hero-card .desc {
    font-size: 14px;
    max-width: 520px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.88);
    margin-bottom: 20px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

button,
.btn {
    border: none;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s ease;
}

button,
.btn:not(.light):not(.ghost):not(.btn-secondary):not(.btn-danger) {
    background: var(--primary);
    color: white;
}

.btn.light {
    background: white;
    color: #14532d;
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--line);
}

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

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.panel,
.table-card,
.form-card {
    padding: 24px;
}

.panel h3,
.panel h4,
.table-card h3,
.form-card h3 {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.mini-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mini-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #eef2f7;
}

.mini-item span {
    color: var(--muted);
    font-size: 13px;
    display: block;
    margin-top: 3px;
}

.tag,
.status-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 8px 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.success,
.status-pago,
.status-ativo {
    background: var(--primary-soft);
    color: var(--primary);
}

.warn,
.status-pendente,
.status-atrasado {
    background: var(--warning-soft);
    color: var(--warning);
}

.danger,
.status-cancelado,
.status-inativo {
    background: var(--danger-soft);
    color: var(--danger);
}

.stats,
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 22px;
}

.stat-card,
.metric-card {
    background: var(--panel);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 22px;
    padding: 22px;
    box-shadow: var(--shadow);
}

.stat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 700;
}

.stat-card h5,
.metric-card p {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-card .number,
.metric-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.trend {
    font-size: 13px;
    font-weight: 700;
}

.grid {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 22px;
}

.content-grid {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 22px;
}

.sales-layout {
    grid-template-columns: minmax(440px, 520px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.section-card {
    background: var(--panel);
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-header {
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
}

.section-header h4 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.section-header p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.link-btn {
    border: 1px solid var(--line);
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

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

th,
td {
    padding: 16px 24px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
    border-bottom: 1px solid #eef2f7;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #fbfdff;
}

td strong {
    font-size: 14px;
}

.right {
    text-align: right;
}

.list-card {
    padding: 12px 18px 20px;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 8px;
    border-bottom: 1px solid #eef2f7;
}

.alert-item:last-child {
    border-bottom: none;
}

.alert-badge {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.alert-content h5 {
    font-size: 14px;
    margin-bottom: 4px;
}

.alert-content p {
    font-size: 13px;
    color: var(--muted);
}

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

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

.sales-form-card {
    padding: 28px;
}

.sales-form-card .form-grid.three {
    gap: 20px 18px;
}

.sales-form-card .field {
    min-width: 0;
}

.sales-form-card input,
.sales-form-card select {
    min-height: 60px;
}

.sales-form-card textarea {
    min-height: 120px;
}

.sales-observacoes {
    margin-top: 20px;
}

.form-group,
.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full,
.field.full {
    grid-column: 1 / -1;
}

label {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

input,
select,
textarea {
    width: 100%;
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    color: var(--text);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

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

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

.list-note {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.input-action-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.input-action-row input {
    flex: 1;
}

.btn-inline {
    white-space: nowrap;
}

.field-helper {
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

.field-helper.is-loading {
    color: #2563eb;
}

.field-helper.is-success {
    color: var(--primary);
}

.field-helper.is-error {
    color: var(--danger);
}

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

.login-card {
    width: min(430px, 100%);
    padding: 28px;
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 8px;
}

.login-card .muted {
    margin-bottom: 18px;
}

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

    .hero,
    .grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .sales-layout {
        grid-template-columns: 1fr;
    }

    .search {
        min-width: 220px;
    }
}

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

    .sidebar {
        position: relative;
        height: auto;
        border-bottom-left-radius: 24px;
        border-bottom-right-radius: 24px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-right {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .search {
        min-width: 100%;
        width: 100%;
    }

    .stats,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 16px;
    }

    th,
    td {
        padding: 14px 16px;
    }
}

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

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

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .input-action-row {
        flex-direction: column;
    }
}
