/* ==========================================
   PAINEL ML — Mercado Livre Admin
   ========================================== */

:root {
    --ml-yellow: #FFE600;
    --ml-blue: #3483FA;
    --sidebar-bg: #1B2838;
    --sidebar-hover: #253447;
    --sidebar-active: #2D4059;
    --bg: #F0F2F5;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-light: #6B7280;
    --text-muted: #9CA3AF;
    --border: #E5E7EB;
    --success: #00A650;
    --warning: #FF7733;
    --danger: #F23D4F;
    --info: #3483FA;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --sidebar-width: 250px;
    --topbar-height: 60px;
    --transition: 0.25s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== LOGIN ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2D4059 100%);
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 90%;
    max-width: 380px;
}

.login-logo {
    width: 70px;
    height: 70px;
    background: var(--ml-yellow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
    color: var(--sidebar-bg);
}

.login-box h1 { font-size: 22px; margin-bottom: 6px; }
.login-box p { color: var(--text-light); margin-bottom: 24px; font-size: 14px; }

.login-box .form-group { margin-bottom: 16px; }
.login-box input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition);
}
.login-box input:focus { border-color: var(--ml-blue); }

/* ==================== LAYOUT ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #E0E0E0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ml-yellow);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header i { font-size: 22px; }
.sidebar-close { display: none; background: none; border: none; color: #E0E0E0; font-size: 18px; cursor: pointer; margin-left: auto; }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #B0BEC5;
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    position: relative;
    cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
    background: var(--sidebar-active);
    color: var(--ml-yellow);
    border-right: 3px solid var(--ml-yellow);
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item .badge {
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 600;
}

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

.user-info {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.user-info i { font-size: 22px; }
.logout { color: var(--danger) !important; }

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* ==================== TOPBAR ==================== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
}

.page-title { font-size: 18px; font-weight: 600; flex: 1; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ==================== CONTENT ==================== */
.content { padding: 24px; }

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--ml-blue); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ==================== FORM CONTROLS ==================== */
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.form-control:focus {
    border-color: var(--ml-blue);
    box-shadow: 0 0 0 3px rgba(52,131,250,0.12);
}
.form-control:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.5; }

/* ==================== CARDS ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    overflow: hidden;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-card-link {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.stat-icon.blue   { background: #EBF3FE; color: var(--ml-blue); }
.stat-icon.green  { background: #E6F9EE; color: var(--success); }
.stat-icon.yellow { background: #FFF9DB; color: #E5A100; }
.stat-icon.red    { background: #FDE8EB; color: var(--danger); }

.stat-info { min-width: 0; flex: 1; }
.stat-info h3 { font-size: 26px; font-weight: 700; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-info p  { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.stat-info .stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ==================== TABLES ==================== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg);
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:hover { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

/* ==================== STATUS BADGES ==================== */
.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.status-paid      { background: #E6F9EE; color: var(--success); }
.status-confirmed { background: #E6F9EE; color: var(--success); }
.status-shipped   { background: #EBF3FE; color: var(--ml-blue); }
.status-delivered  { background: #E6F9EE; color: #007A3D; }
.status-cancelled { background: #FDE8EB; color: var(--danger); }
.status-pending   { background: #FFF9DB; color: #B08800; }
.status-active    { background: #E6F9EE; color: var(--success); }
.status-paused    { background: #FFF9DB; color: #B08800; }
.status-closed    { background: #F3F4F6; color: var(--text-light); }

/* ==================== FILTERS ==================== */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: center;
}

.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 13px; color: var(--text-light); white-space: nowrap; }

select, .input-text {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}
select:focus, .input-text:focus { border-color: var(--ml-blue); }

input[type="date"] {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}

/* ==================== QUESTIONS ==================== */
.question-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card-bg);
}

.question-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.question-item-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg);
}

.question-item-info { flex: 1; }
.question-item-info h4 { font-size: 14px; font-weight: 500; }
.question-item-info small { color: var(--text-muted); font-size: 12px; }

.question-text {
    background: var(--bg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.question-answer-box {
    display: flex;
    gap: 8px;
}
.question-answer-box textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    min-height: 60px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.question-answer-box textarea:focus { border-color: var(--ml-blue); }

.question-answered {
    background: #E6F9EE;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: #007A3D;
    margin-top: 8px;
}
.question-answered strong { display: block; font-size: 12px; margin-bottom: 4px; }

/* ==================== CHAT / MESSAGES ==================== */
.chat-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    height: calc(100vh - var(--topbar-height) - 48px);
}

.chat-list {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.chat-list-items {
    flex: 1;
    overflow-y: auto;
}

.chat-list-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    gap: 12px;
    align-items: center;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item.active { background: #EBF3FE; border-left: 3px solid var(--ml-blue); }

.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--ml-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-preview { flex: 1; min-width: 0; }
.chat-preview h4 { font-size: 14px; font-weight: 500; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview p { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview time { font-size: 11px; color: var(--text-muted); }

.chat-window {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-window-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-window-header h3 { font-size: 15px; font-weight: 600; }
.chat-window-header small { color: var(--text-muted); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F7F8FA;
}

.chat-msg {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
}
.chat-msg.sent {
    background: var(--ml-blue);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-msg.received {
    background: var(--card-bg);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-msg time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.chat-input {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    position: relative;
}
.chat-input textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    max-height: 100px;
    outline: none;
}
.chat-input textarea:focus { border-color: var(--ml-blue); }
.chat-input .btn { border-radius: 50%; width: 42px; height: 42px; padding: 0; justify-content: center; }

/* Quick Messages */
.quick-msg-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all .2s;
    flex-shrink: 0;
}
.quick-msg-btn:hover { background: var(--ml-blue); color: #fff; border-color: var(--ml-blue); }
.quick-msg-btn.active { background: var(--ml-blue); color: #fff; border-color: var(--ml-blue); }

.quick-msg-popup {
    position: absolute;
    bottom: 70px;
    left: 16px;
    width: 320px;
    max-width: calc(100% - 32px);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    padding: 14px;
    display: none;
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
}
.quick-msg-popup.open { display: block; }
.quick-msg-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}
.quick-msg-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.quick-msg-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    color: var(--text);
    max-width: 100%;
}
.quick-msg-chip:hover { background: var(--ml-blue); color: #fff; border-color: var(--ml-blue); }
.quick-msg-chip .chip-delete {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0,0,0,.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    transition: background .15s;
}
.quick-msg-chip:hover .chip-delete { background: rgba(255,255,255,.3); }
.quick-msg-chip-add {
    background: none;
    border: 1px dashed var(--border);
    color: var(--ml-blue);
    font-weight: 600;
}
.quick-msg-chip-add:hover { background: var(--ml-blue); color: #fff; border-style: solid; }

.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-muted);
    gap: 10px;
}
.chat-empty i { font-size: 48px; opacity: 0.3; }

/* ==================== ITEMS / ANÚNCIOS ==================== */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.item-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.item-card-img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #f9f9f9;
    padding: 10px;
}

.item-card-body { padding: 14px; }
.item-card-body h4 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-card-body .price { font-size: 20px; font-weight: 700; color: var(--text); }
.item-card-body .price small { font-size: 14px; font-weight: 400; color: var(--text-light); }

.item-card-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-light);
    gap: 8px;
}
.item-toggle { margin-left: auto; flex-shrink: 0; }

.item-edit-btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: auto;
    color: var(--ml-blue);
    border-color: var(--ml-blue);
}
.item-edit-btn:hover { background: var(--ml-blue); color: #fff; }
.item-edit-btn + .item-toggle { margin-left: 0; }

/* ==================== REPUTATION ====================*/
.reputation-body {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}
.rep-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}
.rep-thermometer {
    display: flex;
    align-items: center;
    gap: 6px;
}
.rep-seg {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--border);
    transition: transform 0.2s;
}
.rep-seg.rep-seg-filled {
    background: var(--rep-color);
    opacity: 0.5;
}
.rep-seg.rep-seg-active {
    background: var(--rep-color);
    transform: scale(1.25);
    box-shadow: 0 2px 12px rgba(0,0,0,0.22);
    position: relative;
    z-index: 1;
}
.rep-level-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.rep-ps-badge {
    background: #FFF9DB;
    color: #996600;
    border: 1px solid #F5C518;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.rep-metrics {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}
.rep-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 90px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
    flex: 1;
}
.rep-metric-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.rep-metric-label {
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    font-weight: 500;
}
.rep-metric-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ==================== NOTIFICATIONS ==================== */
.notification-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.notification-item:last-child { border-bottom: none; }

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.notif-icon.orders   { background: #E6F9EE; color: var(--success); }
.notif-icon.questions { background: #EBF3FE; color: var(--ml-blue); }
.notif-icon.payments { background: #FFF9DB; color: #B08800; }
.notif-icon.items    { background: #F3F4F6; color: var(--text-light); }
.notif-icon.messages { background: #EDE9FE; color: #7C3AED; }
.notif-icon.default  { background: #F3F4F6; color: var(--text-light); }

.notif-content { flex: 1; }
.notif-content h4 { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.notif-content p { font-size: 13px; color: var(--text-light); }
.notif-content time { font-size: 12px; color: var(--text-muted); }

/* ==================== PAGINATION ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 16px;
}
.pagination .btn { min-width: 36px; justify-content: center; }
.pagination .page-info { font-size: 13px; color: var(--text-light); margin: 0 8px; }

/* ==================== ALERTS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error   { background: #FDE8EB; color: var(--danger); }
.alert-success { background: #E6F9EE; color: var(--success); }
.alert-info    { background: #EBF3FE; color: var(--ml-blue); }
.alert-warning { background: #FFF9DB; color: #B08800; }

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-light); cursor: pointer; padding: 4px; }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ==================== LOADING / SPINNER ==================== */
.loading-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    gap: 12px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--ml-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}
.loading-inline .spinner { width: 18px; height: 18px; border-width: 2px; }

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: 8px;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    border-left: 4px solid;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.info    { border-color: var(--info); }
.toast.warning { border-color: var(--warning); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ==================== SETTINGS ==================== */
.settings-section {
    margin-bottom: 24px;
}
.settings-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label { font-size: 14px; font-weight: 500; }
.settings-row small { font-size: 12px; color: var(--text-muted); display: block; }

.info-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    font-size: 14px;
}
.info-grid dt { font-weight: 600; color: var(--text-light); }
.info-grid dd { word-break: break-all; }

/* ==================== ORDER DETAIL ==================== */
.order-detail-section {
    margin-bottom: 20px;
}
.order-detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.order-items-list .order-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.order-items-list .order-item:last-child { border-bottom: none; }
.order-item-thumb {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg);
}
.order-item-info h5 { font-size: 14px; font-weight: 500; }
.order-item-info p { font-size: 13px; color: var(--text-light); }

/* ==================== EMPTY STATES ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; color: var(--text-light); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ==================== TABS ==================== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--ml-blue); border-bottom-color: var(--ml-blue); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close { display: block; }

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

    .menu-toggle { display: block; }

    .content { padding: 16px; }

    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chat-list { max-height: 300px; }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-info h3 { font-size: 18px; }

    .modal {
        max-width: 100%;
        max-height: 90vh;
        margin: 0;
        border-radius: 8px;
    }

    .modal-body { padding: 16px; }

    .automation-form .form-group label { font-size: 13px; }
    .automation-form textarea { min-height: 80px; }

    .filters { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .filters .filter-group { flex: none; }
    .filters .filter-group:has(input[type="date"]) { flex: 1; min-width: 0; }
    .filters .filter-group:has(input[type="date"]) input[type="date"] { width: 100%; }
    .filters .filter-group:has(select) { width: 100%; }
    .filters .filter-group:has(select) select { width: 100%; }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; gap: 8px; }
    .stat-icon { width: 36px; height: 36px; font-size: 14px; border-radius: 10px; }
    .stat-info h3 { font-size: 15px; }
    .stat-info p { font-size: 11px; }
    .items-grid { grid-template-columns: 1fr; }
}

/* ===== AUTOMATIONS ===== */
.automation-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    border-left: 4px solid var(--success);
    transition: box-shadow .2s;
}
.automation-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.automation-card.inactive { border-left-color: #CBD5E0; opacity: .75; }
.automation-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.automation-info { display: flex; align-items: center; gap: 10px; }
.automation-info h3 { margin: 0; font-size: 16px; }
.automation-badge {
    font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 12px;
}
.automation-badge.active { background: #C6F6D5; color: #22543D; }
.automation-badge.inactive { background: #EDF2F7; color: #718096; }
.automation-actions { display: flex; align-items: center; gap: 8px; }
.btn-icon {
    width: 34px; height: 34px; border: none; background: var(--bg);
    border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-light); transition: background .15s, color .15s;
}
.btn-icon:hover { background: #E2E8F0; color: var(--text); }
.btn-icon.danger:hover { background: #FED7D7; color: #C53030; }
.automation-message {
    background: var(--bg); padding: 12px 16px; border-radius: 8px;
    font-size: 14px; color: var(--text); white-space: pre-wrap; line-height: 1.5; margin-bottom: 12px;
}
.automation-footer {
    display: flex; gap: 20px; font-size: 12px; color: var(--text-light);
}
.automation-footer i { margin-right: 4px; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #CBD5E0; border-radius: 24px; transition: .25s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .25s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Automation form */
.automation-form .form-group { margin-bottom: 16px; }
.automation-form label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.automation-form .input-text { width: 100%; box-sizing: border-box; }
.automation-form textarea { resize: vertical; width: 100%; box-sizing: border-box; }
.item-search-box { position: relative; }
.item-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15);
    max-height: 240px; overflow-y: auto;
}
.item-search-result {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
    border-bottom: 1px solid var(--border); transition: background .15s;
}
.item-search-result:hover { background: var(--bg); }
.item-search-result.disabled { opacity: .5; cursor: default; }
.item-search-result img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.item-search-result strong { display: block; font-size: 13px; }
.item-search-result small { color: var(--text-light); font-size: 11px; }
.item-search-empty { padding: 12px; text-align: center; color: var(--text-light); font-size: 13px; }
.selected-items-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.selected-item-tag {
    display: flex; align-items: center; gap: 6px;
    background: #EBF8FF; color: #2B6CB0; padding: 6px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 500;
}
.selected-item-tag button {
    background: none; border: none; font-size: 16px; cursor: pointer; color: #2B6CB0;
    line-height: 1; padding: 0;
}
.selected-item-tag button:hover { color: #C53030; }
.no-items-hint { color: var(--text-light); font-size: 13px; font-style: italic; }

/* ===== AUTOMATIONS TABS — usa o padrão .tabs/.tab ===== */

/* ===== KEYWORD CHIPS ===== */
.keyword-chips-wrap {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    border: 2px solid var(--border); border-radius: 8px; padding: 8px 12px;
    min-height: 44px; cursor: text; transition: border-color var(--transition);
}
.keyword-chips-wrap:focus-within { border-color: var(--ml-blue); }
.keyword-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--ml-blue); color: #fff; padding: 4px 10px;
    border-radius: 16px; font-size: 12px; font-weight: 500;
}
.keyword-chip button {
    background: none; border: none; color: rgba(255,255,255,.8);
    font-size: 14px; cursor: pointer; padding: 0; line-height: 1;
}
.keyword-chip button:hover { color: #fff; }
.keyword-input {
    border: none; outline: none; font-size: 14px; flex: 1; min-width: 120px;
    background: transparent; padding: 2px 0;
}
.catchall-warning {
    display: flex; align-items: center; gap: 8px; margin-top: 8px;
    background: #FFF3E0; border: 1px solid #FFB74D; border-radius: 8px;
    padding: 8px 14px; font-size: 12px; color: #E65100; font-weight: 500;
}
.catchall-warning i { font-size: 14px; }
.auto-reply-keywords {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.auto-reply-keywords .kw-tag {
    background: #E3F2FD; color: #1565C0; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 500;
}
.auto-reply-keywords .kw-catchall {
    background: #FFF3E0; color: #E65100; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 500;
}

/* ==================== FINANCEIRO ====================*/
.fin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.fin-group-tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}
.fin-tab {
    padding: 6px 18px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-light);
    background: none;
    transition: all 0.15s;
}
.fin-tab.active {
    background: var(--ml-blue);
    color: #fff;
}
.fin-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.fin-card-chart .card-body,
.fin-card-donut .card-body {
    padding: 16px;
}
.fin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.fin-badge-charge { background: #FDE8EB; color: var(--danger); }
.fin-badge-bonus  { background: #E6F9EE; color: var(--success); }
.fin-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}
.fin-summary-row strong { font-size: 18px; }
@media (max-width: 768px) {
    .fin-grid { grid-template-columns: 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #A0AEC0; }
