:root {
    /* Core Colors (Identidade Palette) */
    --primary: #A35139; /* Truffle Trouble */
    --primary-hover: #8C442E;
    --secondary: #2C3B4D; /* Blue Fantastic */
    --success: #2D6B5E;
    --danger: #A82525;
    --warning: #FFB162;
    --info: #1B2632; /* Abyssal */

    /* Backgrounds */
    --bg-app: #EEE9DF;
    --bg-surface: #ffffff;
    --bg-surface-hover: #F8F6F2;

    /* Text */
    --text-main: #1B2632;
    --text-secondary: #2C3B4D;
    --text-muted: #79838E;
    --text-inverse: #ffffff;

    /* Borders & Dividers */
    --border: #C9C1B1;
    --divider: #C9C1B1;

    /* Spacing & Sizing (Compact) */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --header-height: 50px;
    --sidebar-width: 220px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    margin: 0;
    font-size: 13px;
    /* Base condensed size */
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

a:hover {
    text-decoration: underline;
}

/* Utilities */
.hidden {
    display: none !important;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

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

.text-center {
    text-align: center;
}

.w-full {
    width: 100%;
}

.cursor-pointer {
    cursor: pointer;
}

.nowrap {
    white-space: nowrap;
}

/* Layout Grid */
.crm-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 20;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-app);
    padding: 0.5rem 1rem 0;
    border-bottom: 1px solid var(--border);
}

.nav-tab {
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.nav-tab:hover {
    color: var(--primary);
    background: var(--bg-surface-hover);
}

.nav-tab.active {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--primary);
    font-weight: 600;
    margin-bottom: -1px;
    padding-bottom: 0.6rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Dashboard Cards (KPIs) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Force 4 columns for a denser look on desktop */
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

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

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dashboard Widgets Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Side by side on large screens */
    gap: 1.5rem;
    align-items: start;
}

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

.widget-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--divider);
}

.widget-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Lists in Widgets */
.list-item {
    display: flex;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 0.5rem;
    background: var(--bg-app);
    transition: background 0.2s;
}

.list-item:hover {
    background: var(--bg-surface-hover);
}

.list-content {
    flex: 1;
}

.list-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.list-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.btn--sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

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

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

.btn--outline {
    border-color: var(--border);
    color: var(--text-secondary);
    background: var(--bg-surface);
}

.btn--outline:hover {
    border-color: var(--secondary);
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.btn--ghost {
    color: var(--text-secondary);
}

.btn--ghost:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

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

.btn--danger:hover {
    background: #fef2f2;
    border-color: #fecaca;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.form-control {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Filter Bar */
.filter-bar {
    background: var(--bg-app);
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

/* Data Tables */
.table-container {
    overflow-x: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-app);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    white-space: nowrap;
    position: relative;
}

.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    cursor: col-resize;
    user-select: none;
    height: 100%;
    z-index: 1;
}

.resizer:hover, .resizer.resizing {
    border-right: 2px solid var(--primary);
    background-color: rgba(163, 81, 57, 0.1);
}

td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--divider);
    color: var(--text-main);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-surface-hover);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    border: 1px solid transparent;
}

.badge--novo {
    background: #FFF5EB;
    color: #cc8400; /* Darkened Warning */
    border-color: #FFB162;
}

.badge--andamento {
    background: #E6F0ED;
    color: #1a4239; /* Darkened Success */
    border-color: #2D6B5E;
}

.badge--fechado {
    background: #FCE8E8;
    color: #7a1b1b; /* Darkened Danger */
    border-color: #e5b3b3;
}

.badge--perdido {
    background: #FCE8E8;
    color: #7a1b1b;
    border-color: #e5b3b3;
}

.badge--cancelado {
    background: #FCE8E8;
    color: #7a1b1b;
    border-color: #e5b3b3;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding-bottom: 1rem;
    height: calc(100vh - 220px);
}

.kanban-col {
    flex: 0 0 280px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
}

.kanban-header {
    padding: 0.75rem;
    border-bottom: 1px solid var(--divider);
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.5);
}

.kanban-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kanban-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: transform 0.1s, box-shadow 0.1s;
    position: relative;
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.kanban-card-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

.kanban-card-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-surface);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.2s;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-app);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
    min-width: 250px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}
/* Charts Section */
.dashboard-charts {
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .dashboard-charts {
        grid-template-columns: 1fr !important;
    }
}

.chart-card {
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
