:root {
    /* Tokens de personalização de aparência (preenchidos pelo servidor via
       <style> injetado no <head>; estes são os padrões do MeuCRM). */
    --app-accent: #d4a8a0;
    --app-bg: #faf8f7;
    --app-sidebar: #2e2a2a;
    --app-sidebar-text: #d8d0ce;

    --primary: var(--app-accent);
    --primary-dark: color-mix(in srgb, var(--app-accent, #d4a8a0) 82%, #7d5a54);
    --primary-light: color-mix(in srgb, var(--app-accent, #d4a8a0) 26%, #ffffff);
    --primary-bg: color-mix(in srgb, var(--app-accent, #d4a8a0) 12%, #ffffff);
    --secondary: #8f9a8c;
    --dark: #3d3a3a;
    --text: #2d2a2a;
    --text-muted: #8b8585;
    --border: #e8e2e0;
    --bg: var(--app-bg);
    --surface: #ffffff;
    --white: #ffffff;
    --success: #5cb377;
    --warning: #e6a23c;
    --danger: #e0574f;
    --info: #6b9ec9;
    --sidebar-bg: var(--app-sidebar);
    --sidebar-text: var(--app-sidebar-text);
    --sidebar-active: #ffffff;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(45, 42, 42, 0.08), 0 1px 2px rgba(45, 42, 42, 0.04);
    --shadow-lg: 0 10px 30px rgba(45, 42, 42, 0.12);
}

/* ====== TEMA ESCURO ====== */
[data-theme="dark"] {
    --bg: #1a181d;
    --surface: #232129;
    --text: #ece9f0;
    --text-muted: #a49daa;
    --border: #36323d;
    --primary-bg: color-mix(in srgb, var(--app-accent, #d4a8a0) 20%, #232129);
    --primary-light: color-mix(in srgb, var(--app-accent, #d4a8a0) 30%, #232129);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] ::placeholder,
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #6e6876; }

[data-theme="dark"] .alert-success { background: rgba(92,179,119,0.15); color: #8fd3a6; border-color: rgba(92,179,119,0.35); }
[data-theme="dark"] .alert-error { background: rgba(224,87,79,0.16); color: #f0a09a; border-color: rgba(224,87,79,0.35); }
[data-theme="dark"] .stat-icon-green { background: rgba(92,179,119,0.18); }
[data-theme="dark"] .stat-icon-blue { background: rgba(107,158,201,0.2); }
[data-theme="dark"] .stat-icon-purple { background: rgba(160,112,201,0.2); }
[data-theme="dark"] .btn-secondary:hover { border-color: #4a4553; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

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

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
}

/* ====== APP SHELL ====== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
}

.brand-text {
    font-size: 19px;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: -0.3px;
}

.brand-accent {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--sidebar-text);
    transition: background 0.15s, color 0.15s;
    font-weight: 500;
    font-size: 14px;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link:hover {
    background: color-mix(in srgb, var(--sidebar-text, #d8d0ce) 12%, transparent);
    color: var(--sidebar-text);
}

.nav-link.active {
    background: var(--primary);
    color: var(--white);
}

.nav-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .nav-link {
    color: var(--sidebar-text);
}

.sidebar-footer .nav-link:hover {
    color: var(--danger);
    background: rgba(224, 87, 79, 0.12);
}

.main-wrapper {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.user-avatar img { width:100%; height:100%; object-fit:cover; border-radius:inherit; }

.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.main-content {
    padding: 28px;
    flex: 1;
}

.sidebar-overlay {
    display: none;
}

/* ====== GENERIC STYLES ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.15s;
    line-height: 1.2;
}

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

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

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

.btn-secondary:hover {
    background: var(--bg);
    border-color: #d5cfcc;
}

.btn-ghost {
    background: none;
    color: var(--primary-dark);
    border-color: transparent;
}

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

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 12px;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 22px 0 12px;
}

/* ====== FORMS ====== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 168, 160, 0.15);
}

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

.form-label-static {
    color: var(--text-muted) !important;
    margin-bottom: 6px !important;
}

/* ====== ALERTS ====== */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}

.alert-icon {
    font-size: 16px;
    font-weight: 700;
}

.alert-success {
    background: #e8f6ee;
    color: #2f7a4f;
    border: 1px solid #c5e8d3;
}

.alert-error {
    background: #fdeceb;
    color: #b0433e;
    border: 1px solid #f6d5d3;
}

/* ====== DASHBOARD ====== */
.dashboard-hero {
    margin-bottom: 24px;
}

.dashboard-hero h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.dashboard-hero p {
    color: var(--text-muted);
    margin-top: 4px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-icon-green { background: #e8f6ee; color: var(--success); }
.stat-icon-blue { background: #e8f1fb; color: var(--info); }
.stat-icon-purple { background: #f1e8f5; color: #a070c9; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
}

.dashboard-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.goal-progress-block {
    margin-top: -6px;
}

.goal-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.goal-progress-head h4 {
    font-size: 15px;
    font-weight: 600;
}

.goal-type {
    font-size: 12px;
    color: var(--text-muted);
}

.goal-value {
    display: flex;
    align-items: center;
    gap: 6px;
}

.goal-realizado {
    font-size: 18px;
    font-weight: 700;
    color: var(--success);
}

.goal-separator {
    color: var(--text-muted);
}

.goal-alvo {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-bar {
    background: var(--bg);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.goal-progress-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-percent { font-weight: 600; color: var(--text); }
.progress-restante { color: var(--warning); font-weight: 600; }

.recent-sims .sim-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--bg);
}

.recent-sims .sim-row:last-child {
    border-bottom: none;
}

.sim-info {
    display: flex;
    flex-direction: column;
}

.sim-name {
    font-weight: 600;
    font-size: 13px;
}

.sim-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.sim-price {
    font-weight: 600;
    font-size: 13px;
    color: var(--primary-dark);
}

.empty-state {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.mix-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.mix-stat {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.mix-label {
    font-size: 11px;
    color: var(--text-muted);
}

.mix-value {
    font-size: 16px;
    font-weight: 700;
}

.mix-value-green { color: var(--success); }

.mix-items {
    list-style: none;
}

.mix-items li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--bg);
    font-size: 13px;
}

.mix-item-name { font-weight: 500; }
.mix-item-qty, .mix-item-price { color: var(--text-muted); }

/* ====== CALCULATOR ====== */
.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.materials-list {
    margin-bottom: 10px;
}

.material-row {
    display: grid;
    grid-template-columns: 1fr 90px 110px 110px 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.material-row .form-control {
    padding: 8px 10px;
    font-size: 13px;
}

.material-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.mat-total-cell {
    font-weight: 600;
    color: var(--primary-dark);
    text-align: right;
    font-size: 13px;
}

.mat-action-cell {
    display: flex;
    justify-content: flex-end;
}

.btn-remove-material {
    background: none;
    border: none;
    color: var(--danger);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.btn-remove-material:hover {
    background: #fdeceb;
}

.costs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.result-area {
    animation: fadeIn 0.3s ease;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.result-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.3;
}

.result-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin: 18px 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-title:first-child {
    margin-top: 0;
}

.result-table {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 9px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--bg);
}

.result-row:last-child {
    border-bottom: none;
}

.result-row .r-label {
    color: var(--text-muted);
}

.result-row .r-value {
    font-weight: 600;
}

.result-row .r-value.highlight {
    font-size: 16px;
    color: var(--primary-dark);
}

.result-row.total .r-value {
    font-weight: 800;
    color: var(--primary-dark);
}

.result-row.muted .r-value {
    color: var(--text-muted);
}

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

/* ====== TABLE ====== */
.table-wrap {
    overflow-x: auto;
}

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

.table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--bg);
    font-size: 13px;
    vertical-align: middle;
}

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

.table-actions-col {
    width: 90px;
    text-align: right;
}

.table-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.btn-icon {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.15s;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

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

.btn-icon-open:hover { color: var(--info); }
.btn-icon-dup:hover { color: var(--primary-dark); }
.btn-icon-del:hover { color: var(--danger); background: #fdeceb; }

.sim-cell-name { font-weight: 600; }
.sim-cell-price { font-weight: 600; color: var(--primary-dark); }

/* ====== GOALS ====== */
.goal-form {
    padding: 4px 0;
}

.goal-card {
    margin-bottom: 20px;
}

.goal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 12px;
}

.goal-card-title h4 {
    font-size: 16px;
    font-weight: 700;
}

.goal-card-title .goal-type {
    display: inline-block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.goal-card-actions {
    display: flex;
    gap: 4px;
}

.goal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.goal-summary-item {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    padding: 10px 14px;
    border-radius: 8px;
}

.goal-summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.goal-summary-value {
    font-size: 17px;
    font-weight: 700;
    margin-top: 2px;
}

.goal-summary-realizado { color: var(--success); }
.goal-summary-falta { color: var(--warning); }
.goal-summary-percent { color: var(--primary-dark); }

.goal-period-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.quantidade-bloco {
    border-top: 1px solid var(--border);
    padding-top: 18px;
    margin-top: 18px;
}

.quantidade-bloco h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.quantidade-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.quantidade-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 14px;
}

.quantidade-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.quantidade-input-group {
    display: flex;
    gap: 8px;
}

.quantidade-result {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    padding: 8px;
    border-radius: 6px;
    background: var(--surface);
    min-height: 36px;
    display: flex;
    align-items: center;
}

.quantidade-result.has-result {
    color: var(--primary-dark);
}

.mix-bloco {
    border-top: 1px solid var(--border);
    padding-top: 18px;
    margin-top: 18px;
}

.mix-bloco h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.mix-table .form-control {
    padding: 7px 9px;
    font-size: 13px;
}

.mix-table td input.form-control {
    min-width: 0;
}

.mix-result {
    margin-top: 14px;
}

.mix-result-summary {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

.mix-result-item {
    display: flex;
    flex-direction: column;
}

.mix-result-label {
    font-size: 11px;
    color: var(--text-muted);
}

.mix-result-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
}

.mix-result-value.warn {
    color: var(--warning);
}

.mix-add, .mix-save {
    margin-right: 8px;
    margin-top: 10px;
}

/* ====== SETTINGS ====== */
.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-tab {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.settings-tab:hover {
    color: var(--text);
}

.settings-tab.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.settings-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

/* ====== NAVEGAÇÃO INTERNA DE ÁREAS (Compras / Vendas / Relacionamento) ======
   Barra de contexto no topo das páginas de cada área. Mantém o mesmo visual
   discreto das abas de Configurações, mas com links âncora. */
.area-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.area-nav-item {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    cursor: pointer;
}

.area-nav-item:hover {
    color: var(--text);
}

.area-nav-item.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

.settings-note {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.settings-note code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.profile-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-proprietaria { background: #f1e8f5; color: #7a4a9c; }
.badge-administrador { background: #e8f1fb; color: #3a6ea5; }
.badge-gerente { background: #e8f6ee; color: #2f7a4f; }
.badge-atendente { background: #fdf3e1; color: #a06a1c; }
.badge-producao { background: #fdeceb; color: #b0433e; }

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.status-saudavel { background: #e8f6ee; color: #2f7a4f; }
.status-atencao { background: #fdf3e1; color: #a06a1c; }
.status-abaixo_minimo { background: #fdeceb; color: #b0433e; }

.text-danger { color: var(--danger) !important; }

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted, #8895a7);
}

.qty-highlight {
    color: var(--primary-dark);
    font-size: 17px;
}

.form-label-static {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.badge-padrao {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    font-weight: 600;
}

.tag {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    margin-right: 4px;
    margin-bottom: 2px;
}

.others-container {
    margin-bottom: 16px;
}

.others-list {
    margin-bottom: 8px;
}

.other-row {
    display: grid;
    grid-template-columns: 1fr 80px 30px;
    gap: 8px;
    margin-bottom: 8px;
}

.other-row .form-control {
    padding: 8px 10px;
    font-size: 13px;
}

.security-info ul {
    padding-left: 20px;
    margin: 12px 0;
}

.security-info li {
    margin-bottom: 8px;
    color: var(--text);
}

/* ====== AUTH ====== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-bg) 0%, #f7ece9 100%);
    padding: 20px;
}

.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.brand-mark-large {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 18px;
}

.brand-text-large {
    font-size: 26px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 24px;
}

/* ====== ERROR PAGE ====== */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}

.error-card {
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
}

.error-code {
    font-size: 60px;
    font-weight: 800;
    color: var(--primary);
}

.error-card h1 {
    font-size: 20px;
    margin: 12px 0 8px;
}

.error-card p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ====== MODAL ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 42, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Modal Novo Insumo: largura maior, rolagem interna + cabeçalho/rodapé fixos */
#novoInsumoModal .modal {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    max-height: min(92vh, 860px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

#novoInsumoModal .modal-header,
#novoInsumoModal .modal-footer {
    position: sticky;
    background: var(--surface);
    z-index: 5;
    flex: 0 0 auto;
}

#novoInsumoModal .modal-header { top: 0; }
#novoInsumoModal .modal-footer { bottom: 0; }

.novo-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.novo-modal-close:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.novo-modal-close:focus-visible {
    outline: 2px solid var(--primary, #6b5bd2);
    outline-offset: 2px;
}

.modal-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 1100px) {
    .dashboard-cols,
    .calculator-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(45, 42, 42, 0.4);
        z-index: 99;
    }

    .sidebar-overlay.hidden {
        display: none;
    }

    .topbar {
        padding: 12px 16px;
    }

    .main-content {
        padding: 18px 16px;
    }

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

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

    .material-row {
        grid-template-columns: 1fr;
        gap: 4px;
        background: var(--bg);
        padding: 10px;
        border-radius: 8px;
        margin-bottom: 10px;
    }

    .material-header {
        display: none;
    }

    .mat-total-cell {
        text-align: left;
    }

    .mat-action-cell {
        justify-content: flex-end;
    }

    .topbar-user {
        gap: 8px;
    }

    .user-info {
        display: none;
    }

    .calc-actions {
        flex-direction: column;
    }

    .calc-actions .btn {
        width: 100%;
    }

    .goal-summary {
        grid-template-columns: 1fr 1fr;
    }

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

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

    .goal-summary {
        grid-template-columns: 1fr;
    }

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

/* ====== ETAPA 02 : Insumos / Estoque / Fornecedores / Compras ====== */
.module-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.filter-bar .form-control {
    min-width: 0;
}

.inline-form { display: inline-flex; }
.inline-create {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}
.inline-create .form-control { flex: 1; }
.inline-edit {
    display: flex;
    gap: 8px;
    align-items: center;
}
.inline-nome { max-width: 260px; }

.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table .num.muted { color: var(--text-muted); }

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

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

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.compra-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg);
    border-radius: 10px;
}
.compra-summary > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 140px 140px 34px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.btn-icon-edit { color: var(--text-muted); }
.btn-icon-edit:hover { color: var(--primary-dark); }

/* Seletor de insumo cadastrado na Calculadora (barra sobre a linha de material) */
.material-row .mat-insumo-bar {
    grid-column: 1 / -1;
}
.mat-insumo-bar .form-control {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.mat-insumo-bar .form-control option { color: var(--text); }

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .item-row {
        grid-template-columns: 1fr;
        background: var(--bg);
        padding: 10px;
        border-radius: 8px;
    }
}

/* =====================================================================
   PERSONALIZAÇÃO DE APARÊNCIA
   ===================================================================== */

/* Logo no menu lateral — preserva proporção, não distorce, não quebra o menu */
.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 8px;
    background: var(--surface);
    padding: 2px;
}

/* Tema escuro: superfícies de tabela/filtro/badge mais coerentes */
[data-theme="dark"] .table thead th { background: color-mix(in srgb, var(--surface) 88%, #000); }
[data-theme="dark"] .table tbody tr:nth-child(even) { background: rgba(255,255,255,0.025); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,0.05); }
[data-theme="dark"] .modal { background: var(--surface); }
[data-theme="dark"] .modal-header, [data-theme="dark"] .modal-footer { background: var(--surface); }
[data-theme="dark"] .topbar { background: var(--surface); }
[data-theme="dark"] .dropdown, [data-theme="dark"] .popup { background: var(--surface); }

.settings-subsection { margin-top: 26px; }
.settings-subsection:first-of-type { margin-top: 0; }

.appearance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
@media (max-width: 760px) { .appearance-grid { grid-template-columns: 1fr; } }

.appearance-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.appearance-field .color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.appearance-color {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}
.appearance-color::-webkit-color-swatch-wrapper { padding: 4px; }
.appearance-color::-webkit-color-swatch { border: none; border-radius: 6px; }
.appearance-color::-moz-color-swatch { border: none; border-radius: 6px; }
.appearance-hex {
    width: 130px;
}

.appearance-field .form-hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Seletor de tema (segmentado) */
.theme-segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 9px;
    overflow: hidden;
    background: var(--surface);
}
.theme-segmented button {
    border: none;
    background: none;
    padding: 9px 18px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}
.theme-segmented button.active {
    background: var(--primary);
    color: var(--surface);
}
.theme-option { margin-bottom: 16px; }
.theme-option label { font-weight: 600; font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 6px; }

/* Prévia */
.appearance-preview {
    margin-top: 22px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.appearance-preview-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
#appearancePreview {
    min-height: 150px;
    display: flex;
    align-items: stretch;
}
.preview-shell { display: flex; width: 100%; min-height: 150px; }
.preview-sidebar {
    width: 90px;
    flex-shrink: 0;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-right: 1px solid rgba(128,128,128,0.25);
}
.preview-sidebar .pv-brand { font-weight: 700; font-size: 13px; }
.preview-sidebar .pv-link { font-size: 11px; padding: 4px 6px; border-radius: 6px; }
.preview-sidebar .pv-link.active { font-weight: 600; }
.preview-main { flex: 1; padding: 16px; }
.preview-card {
    border: 1px solid rgba(128,128,128,0.22);
    border-radius: 8px;
    padding: 12px;
}
.preview-card .pv-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.preview-card .pv-bar { height: 8px; border-radius: 4px; margin-bottom: 8px; opacity: 0.9; }
.preview-card .pv-bar.short { width: 55%; }

.appearance-logo-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.appearance-logo-current {
    width: 120px;
    height: 70px;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    overflow: hidden;
}
.appearance-logo-current img { max-width: 100%; max-height: 100%; object-fit: contain; }
.appearance-logo-current .appearance-logo-placeholder { font-size: 30px; font-weight: 800; color: var(--text-muted); }

.appearance-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.appearance-actions .btn-primary { color: var(--surface); }

.appearance-contrast-warn {
    display: none;
    margin-top: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12px;
    background: rgba(230,162,60,0.16);
    color: #9a6b16;
    border: 1px solid rgba(230,162,60,0.4);
}
[data-theme="dark"] .appearance-contrast-warn { color: #f0c67a; }
.appearance-contrast-warn.show { display: block; }

.logo-file-label { display: inline-block; }

/* (append marker) */
/* ====== ETAPA 03 : Produtos e Ficha Técnica ====== */

.muted { color: var(--text-muted); }

.card-actions { display: flex; align-items: center; gap: 8px; }
.link-cell { color: var(--primary-dark); font-weight: 600; text-decoration: none; }
.link-cell:hover { text-decoration: underline; }

.page-actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.produto-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; padding-top: 4px; }
.produto-meta-item { font-size: 13px; }
.produto-meta-item.full { flex-basis: 100%; }

.status-info { background: #e8f1fb; color: #3a6ea5; }

.product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 900px) { .product-grid { grid-template-columns: 1fr; } }

.capacity-big {
    text-align: center;
    padding: 22px 16px;
    background: var(--primary-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
}
.capacity-number { font-size: 44px; font-weight: 800; color: var(--primary-dark); line-height: 1.1; }
.capacity-label { font-size: 13px; color: var(--text); }

.ficha-lines .table { margin-bottom: 8px; }
.table-total-line { text-align: right; font-size: 13px; padding-top: 8px !important; border-top: 2px solid var(--border); }
.table-total-line strong { color: var(--primary-dark); }

.table.table-compact td { padding: 8px 12px; }
.grand-total td { border-top: 2px solid var(--border); font-weight: 700; color: var(--primary-dark); background: var(--primary-bg); }

.card-inner { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 14px; }

.preco-form { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.inline-cost-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-cost-row .form-control { max-width: 220px; }

/* Editor de ficha (linhas de insumos e custos manuais) */
.editor-lines { margin-bottom: 6px; }
.editor-row {
    display: grid;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
.editor-row.editor-header {
    border: none;
    background: none;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.editor-row:not(.editor-header) { grid-template-columns: 1fr 140px 110px 36px; }
@media (max-width: 700px) { .editor-row:not(.editor-header) { grid-template-columns: 1fr 110px 36px; } .editor-row .cell-cust { display: none; } }
.cell-select { min-width: 0; }
.cell-qty .form-control { text-align: right; }
.cell-cust { font-size: 13px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.cell-action { display: flex; justify-content: center; }

.custo-preview { margin-top: 16px; }
.cap-preview { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.cap-preview .table { margin-top: 8px; }

[data-theme="dark"] .editor-row { background: var(--surface); }
[data-theme="dark"] .cap-preview { background: var(--surface); }
[data-theme="dark"] .capacity-big { background: var(--primary-bg); }
[data-theme="dark"] .status-info { background: rgba(107,158,201,0.2); color: #8fb8dd; }
[data-theme="dark"] .grand-total td { color: #ecc4b3; }

/* ===== Mão de Obra (Etapa 03/2) ===== */
#moEditor .editor-row:not(.editor-header) { grid-template-columns: 1fr 270px 110px 36px; }
.editor-row .mo-time { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.editor-row .mo-time .form-control { text-align: left; }

#calcMoList .material-row:not(.material-header) { grid-template-columns: 1fr 300px 90px 90px 30px; }
#calcMoList .mo-time { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.mo-form { margin-bottom: 8px; }
.mo-form .mo-dynamic { margin-top: 4px; }
.mo-dynamic { padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; margin-bottom: 10px; }

@media (max-width: 700px) {
    #moEditor .editor-row:not(.editor-header) { grid-template-columns: 1fr 36px; }
    #moEditor .editor-row .cell-qty, #moEditor .editor-row .cell-cust { grid-column: 1; }
    #calcMoList .material-row:not(.material-header) { grid-template-columns: 1fr 30px; }
}

/* ===== ETAPA 04 : Interessados e Clientes ===== */
.crm-page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}
.crm-page-heading h2 { font-size: 24px; line-height: 1.2; margin-top: 5px; }
.crm-page-heading p { color: var(--text-muted); margin-top: 4px; }
.crm-back-link { color: var(--primary-dark); font-size: 13px; font-weight: 600; }
.crm-heading-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crm-origin-badge, .crm-origin-lock {
    display: inline-flex;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}
.crm-info-note, .crm-sync-strip {
    border: 1px solid color-mix(in srgb, var(--info) 35%, var(--border));
    border-left: 4px solid var(--info);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--info) 9%, var(--surface));
    padding: 13px 16px;
    color: var(--text);
}
.crm-sync-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.crm-sync-strip.ready { border-left-color: var(--success); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.crm-sync-strip.pending { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); }
.crm-sync-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crm-people-filters { grid-template-columns: minmax(230px, 2fr) repeat(3, minmax(140px, 1fr)) auto; padding: 16px 0 4px; }
.crm-people-table a:not(.btn) { color: var(--primary-dark); font-weight: 650; }
.crm-classification, .crm-sync-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.crm-classification-normal { background: color-mix(in srgb, var(--text-muted) 12%, var(--surface)); color: var(--text-muted); }
.crm-classification-prioridade { background: color-mix(in srgb, var(--success) 18%, var(--surface)); color: color-mix(in srgb, var(--success) 75%, var(--text)); }
.crm-classification-atencao { background: color-mix(in srgb, var(--warning) 18%, var(--surface)); color: color-mix(in srgb, var(--warning) 72%, var(--text)); }
.crm-classification-nao_atender { background: color-mix(in srgb, var(--danger) 17%, var(--surface)); color: color-mix(in srgb, var(--danger) 76%, var(--text)); }
.crm-sync-sincronizado { background: color-mix(in srgb, var(--success) 17%, var(--surface)); color: color-mix(in srgb, var(--success) 75%, var(--text)); }
.crm-sync-pendente { background: color-mix(in srgb, var(--warning) 17%, var(--surface)); color: color-mix(in srgb, var(--warning) 72%, var(--text)); }
.crm-sync-erro { background: color-mix(in srgb, var(--danger) 17%, var(--surface)); color: color-mix(in srgb, var(--danger) 75%, var(--text)); }
.crm-person-form { padding: 22px; }
.crm-person-form .card-header { margin: -4px 0 12px; }
.crm-form-section { border-top: 1px solid var(--border); padding-top: 18px; margin: 22px 0 12px; }
.crm-form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.crm-form-section h3 { font-size: 15px; }
.crm-form-section p { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.crm-person-form .form-grid + .form-grid { margin-top: 14px; }
.crm-field-wide { grid-column: span 2; }
.crm-duplicate-confirm { margin-top: 20px; padding: 12px; background: var(--primary-bg); border-radius: 8px; font-size: 12px; }
.crm-duplicate-confirm label { display: flex; align-items: flex-start; gap: 8px; }
.crm-duplicate-confirm input { margin-top: 3px; }
.crm-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.crm-detail-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 0.8fr); gap: 18px; align-items: start; }
.crm-detail-side { display: flex; flex-direction: column; gap: 18px; }
.crm-detail-side .card { padding: 18px; }
.crm-detail-side h3 { font-size: 15px; margin-bottom: 6px; }
.crm-detail-side p { color: var(--text-muted); font-size: 12px; margin-bottom: 14px; }
.crm-full-button { width: 100%; justify-content: center; }
.crm-observations form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.crm-observation-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.crm-observation-list article { border-top: 1px solid var(--border); padding-top: 10px; }
.crm-observation-list article p { color: var(--text); white-space: normal; overflow-wrap: anywhere; margin-bottom: 5px; }
.crm-observation-list small { color: var(--text-muted); }
.crm-inline-create { display: flex; align-items: flex-end; gap: 10px; margin: 14px 0 20px; }
.crm-inline-create .form-group { flex: 1; margin-bottom: 0; }
.crm-origin-edit { display: flex; gap: 8px; align-items: center; max-width: 480px; }
.crm-integration-card { margin-top: 18px; }
.crm-integration-card p { margin-top: 10px; color: var(--text-muted); }
.crm-conciliation-card { max-width: 760px; }
.crm-conciliation-card .form-group { margin: 14px 0; }

@media (max-width: 1050px) {
    .crm-people-filters { grid-template-columns: 1fr 1fr; }
    .crm-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .crm-page-heading, .crm-sync-strip { align-items: flex-start; flex-direction: column; }
    .crm-people-filters { grid-template-columns: 1fr; }
    .crm-field-wide { grid-column: auto; }
    .crm-person-form { padding: 16px; }
    .crm-inline-create, .crm-origin-edit { align-items: stretch; flex-direction: column; }
    .crm-form-actions { flex-direction: column-reverse; }
    .crm-form-actions .btn { width: 100%; justify-content: center; }
}

/* ===== Configuracao WooCommerce ===== */
.wc-settings-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    padding: 22px 24px;
    margin-bottom: 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 20%, var(--surface)), var(--surface) 72%);
    border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border));
}
.wc-eyebrow, .wc-card-kicker { color: var(--primary-dark); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.wc-settings-hero h2 { margin-top: 4px; font-size: 25px; }
.wc-settings-hero p, .wc-settings-side p { color: var(--text-muted); margin-top: 4px; }
.wc-state-summary { display: flex; gap: 10px; flex-wrap: wrap; }
.wc-state-summary > div { min-width: 118px; padding: 10px 13px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 90%, transparent); border: 1px solid var(--border); }
.wc-state-summary span { display: block; color: var(--text-muted); font-size: 11px; }
.wc-state-summary strong { display: block; margin-top: 4px; font-size: 13px; }
.wc-good { color: var(--success); }
.wc-bad { color: var(--danger); }
.wc-muted { color: var(--text-muted); }
.wc-settings-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(290px, .8fr); gap: 18px; align-items: start; }
.wc-settings-main { padding: 22px; }
.wc-settings-main .card-header { margin-bottom: 18px; }
.wc-enable-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--primary-bg); }
.wc-switch-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.wc-switch-label input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary-dark); }
.wc-switch-label span, .wc-switch-label small { display: block; }
.wc-switch-label small, .wc-field-note { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.wc-managed { border-radius: 999px; padding: 4px 8px; background: var(--surface); color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.wc-secret-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wc-secret-grid .form-group:last-child { grid-column: 1 / -1; }
.wc-current-value { min-height: 34px; display: flex; align-items: center; padding: 7px 10px; margin-bottom: 6px; border-radius: 7px; background: color-mix(in srgb, var(--text-muted) 7%, var(--surface)); color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.wc-form-actions { display: flex; justify-content: flex-end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.wc-test-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 16px; border-radius: 10px; border: 1px solid var(--border); }
.wc-test-row p { color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.wc-test-row small { color: var(--text-muted); }
.wc-disable-form { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.wc-disable-form small { color: var(--text-muted); }
.wc-settings-side { display: flex; flex-direction: column; gap: 18px; }
.wc-settings-side .card { padding: 18px; }
.wc-settings-side h3 { margin-top: 3px; font-size: 16px; }
.wc-webhook-card label { display: block; margin: 16px 0 5px; font-size: 12px; font-weight: 650; }
.wc-copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.wc-copy-row .form-control { font-size: 11px; }
.wc-event-list { display: flex; gap: 7px; flex-wrap: wrap; list-style: none; margin: 13px 0; }
.wc-event-list li { padding: 4px 8px; border-radius: 999px; background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: color-mix(in srgb, var(--success) 75%, var(--text)); font-size: 11px; font-weight: 700; }
.wc-settings-side details { margin-top: 12px; color: var(--text-muted); }
.wc-settings-side summary { color: var(--text); cursor: pointer; font-size: 12px; font-weight: 650; }
.wc-runtime-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.wc-runtime-line:last-of-type { border-bottom: 0; }

@media (max-width: 1000px) {
    .wc-settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
    .wc-settings-hero, .wc-test-row { align-items: flex-start; flex-direction: column; }
    .wc-secret-grid { grid-template-columns: 1fr; }
    .wc-secret-grid .form-group:last-child { grid-column: auto; }
    .wc-form-actions .btn, .wc-test-row .btn { width: 100%; justify-content: center; }
.wc-copy-row { grid-template-columns: 1fr; }
}

/* ====== GESTÃO DE USUÁRIOS, CARGOS E PERMISSÕES (Etapa 05.5 Bloco 2) ====== */
.badge-muted {
    background: color-mix(in srgb, var(--text-muted) 15%, var(--surface));
    color: var(--text-muted);
}
.badge-sistema {
    background: color-mix(in srgb, var(--info, #0284c7) 15%, var(--surface));
    color: var(--info, #0284c7);
    font-variant: small-caps;
}
.badge-proprietaria {
    background: color-mix(in srgb, var(--accent, #ca8a04) 16%, var(--surface)) !important;
    color: var(--accent, #ca8a04) !important;
}
.form-control-static {
    background: color-mix(in srgb, var(--border) 35%, var(--surface));
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--text-muted);
}
.table-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}

/* Matriz de permissões (cargos e exceções individuais). */
.perm-matrix {
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.perm-group {
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
}
.perm-group:last-child { border-bottom: 0; }
.perm-group .section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 0 0 8px;
}
.perm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px dashed var(--border);
    font-size: 14px;
}
.perm-row:first-of-type { border-top: 0; }
.perm-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.perm-states { display: flex; gap: 14px; align-items: center; }
.perm-states label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.perm-states .perm-allow { color: var(--success); }
.perm-states .perm-deny { color: var(--danger); }
.perm-states input { accent-color: var(--primary); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger:hover, .btn-danger:focus { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: var(--danger); }
.btn-success:hover, .btn-success:focus { background: color-mix(in srgb, var(--success) 88%, #000); border-color: var(--success); }
.inline-form { display: inline; margin: 0; }

@media (max-width: 700px) {
    .perm-row { flex-direction: column; align-items: flex-start; }
    .table-actions { justify-content: flex-start; }
}

/* ===== Atendimento: estrutura administrativa (Bloco 2) ===== */
.atd-page { display: flex; flex-direction: column; gap: 18px; }
.atd-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.atd-subnav { margin-bottom: 4px; }
.atd-presenca-form .theme-segmented { margin-bottom: 12px; }
.atd-presenca-buttons button[disabled] { opacity: .6; cursor: default; }
.atd-capacidade { max-width: 220px; }
.atd-stat-grid { grid-template-columns: repeat(6, 1fr); }
.atd-stat-grid .stat-value { font-size: 26px; }
.atd-stat-card-alerta .stat-value { color: var(--danger); }
.atd-empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 18px; color: var(--text-muted); font-size: 13px; background: var(--surface);
}
.atd-form-grid { display: flex; flex-direction: column; gap: 14px; }
.atd-kb-resposta { max-width: 320px; }
.atd-sons-table .form-control { min-width: 120px; }
.atd-volume { width: 160px; vertical-align: middle; }
.atd-horarios-table input[type=time] { max-width: 130px; }
.atd-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.atd-checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.checkbox-line input { flex: none; }
.atd-kb-add { display: grid; grid-template-columns: 1fr 1fr 180px 120px; gap: 12px; align-items: end; margin-bottom: 14px; }
@media (max-width: 900px) {
  .atd-cards, .atd-stat-grid { grid-template-columns: 1fr 1fr; }
  .atd-kb-add { grid-template-columns: 1fr 1fr; }
  .atd-stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .atd-cards, .atd-stat-grid, .atd-kb-add { grid-template-columns: 1fr; }
}
