/* ADVSAT - Mini CRM Comercial */

:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-soft: #fafafa;
    --text: #18181b;
    --text-secondary: #71717a;
    --text-muted: #a1a1aa;
    --border: #e4e4e7;
    --border-soft: #eeeeef;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success-bg: #ecfdf5;
    --success-text: #15803d;
    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;
    --info-bg: #eff6ff;
    --info-text: #2563eb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(24,24,27,.03), 0 8px 24px rgba(24,24,27,.03);
    --sidebar-width: 232px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    padding: 24px 16px;
    background: var(--surface-soft);
    border-right: 1px solid var(--border);
    z-index: 20;
}

.sidebar-main { height: 100%; }

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 40px 42px 60px;
}

.content-container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    margin-bottom: 30px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(79,70,229,.18);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 15px;
    letter-spacing: -.02em;
}

.brand-text small {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.nav-label {
    padding: 0 10px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    color: #52525b;
    font-weight: 500;
    transition: background .15s ease, color .15s ease;
}

.nav-link:hover {
    background: #f1f1f3;
    color: var(--text);
}

.nav-link.active {
    background: #ececef;
    color: var(--text);
}

.nav-icon {
    width: 18px;
    color: var(--text-secondary);
    text-align: center;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 30px;
}

.page-title {
    margin: 0;
    font-size: 29px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -.035em;
}

.page-subtitle {
    margin: 7px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover { background: #f5f5f6; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79,70,229,.18);
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.stat-card {
    min-height: 120px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.stat-value {
    margin-top: 16px;
    font-size: 31px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.04em;
}

.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 12px;
}

.section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.015em;
}

.section-description {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 13px;
}

.text-link {
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
}

.table-card { overflow: hidden; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.table th {
    padding: 11px 16px;
    background: #fbfbfc;
    border-bottom: 1px solid var(--border);
    color: #8b8b94;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .055em;
    white-space: nowrap;
}

.table td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--border-soft);
    color: #3f3f46;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: #fafafe; }

.table-primary {
    color: var(--text);
    font-weight: 600;
    letter-spacing: -.01em;
}

.table-primary:hover { color: var(--primary); }
.table-secondary { color: var(--text-secondary); }

.table-money {
    text-align: right;
    color: #27272a;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.align-right { text-align: right !important; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: #f4f4f5; color: #52525b; }
.badge-contacted { background: var(--info-bg); color: var(--info-text); }
.badge-proposal { background: var(--primary-soft); color: var(--primary); }
.badge-won { background: var(--success-bg); color: var(--success-text); }
.badge-lost { background: var(--danger-bg); color: var(--danger-text); }

.date-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.date-label::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #c4c4cb;
}

.date-today { color: #3730a3; }
.date-today::before { background: #6366f1; }

.date-overdue { color: #be123c; }
.date-overdue::before { background: #fb7185; }

.form-card {
    width: 100%;
    max-width: 860px;
    padding: 26px;
}

.form-section + .form-section {
    margin-top: 30px;
    padding-top: 26px;
    border-top: 1px solid var(--border);
}

.form-section-title {
    margin: 0 0 20px;
    font-size: 14px;
    font-weight: 700;
}

.form-section-title-inline { margin-bottom: 0; }

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

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

.form-label {
    color: #3f3f46;
    font-size: 13px;
    font-weight: 600;
}

.form-required { color: var(--danger-text); }

.form-control {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    background: var(--surface);
    border: 1px solid #d4d4d8;
    border-radius: 8px;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(79,70,229,.10);
}

.filter-select { width: 220px; }

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

.field-error {
    color: var(--danger-text);
    font-size: 12px;
}

.edit-status-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.status-control {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.alert {
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
}

.alert-success {
    background: var(--success-bg);
    border-color: #bbf7d0;
    color: var(--success-text);
}

.alert-error {
    background: var(--danger-bg);
    border-color: #fecaca;
    color: var(--danger-text);
}

.empty-state {
    padding: 54px 24px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 16px;
}

.empty-state p {
    margin: 0 auto 20px;
    max-width: 440px;
}

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .main-content { padding: 32px 28px 50px; }
}

@media (max-width: 760px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        padding: 14px;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-main {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    .brand { margin: 0; }
    .brand-text small, .nav-label { display: none; }
    .nav { flex-direction: row; }
    .nav-link { min-height: 38px; padding: 0 10px; }

    .main-content {
        margin-left: 0;
        padding: 26px 18px 42px;
    }

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

    .page-header .btn-primary { width: 100%; }

    .form-grid { grid-template-columns: 1fr; }
    .form-group-full { grid-column: auto; }

    .edit-status-row {
        flex-direction: column;
        align-items: stretch;
    }

    .status-control { width: 100%; }
    .filter-select { width: 100%; }
}

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

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

    .page-title { font-size: 26px; }
    .form-card { padding: 20px; }
}
