:root {
    --bg-main: #0a0d14;
    --bg-card: #121824;
    --bg-card-hover: #182233;
    --bg-glass: rgba(18, 24, 36, 0.75);
    --border-color: #1e293b;
    --border-highlight: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px -5px rgba(59, 130, 246, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 10% 10%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
}

.app-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 14px 28px;
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.35);
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-tag {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-cyan);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(6, 182, 212, 0.3);
    font-weight: 600;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-status-pills {
    display: flex;
    gap: 12px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.green { background-color: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }
.status-dot.yellow { background-color: var(--accent-amber); box-shadow: 0 0 8px var(--accent-amber); }
.status-dot.blue { background-color: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    color: #fff;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, var(--accent-blue));
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.45);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-highlight);
}
.btn-secondary:hover {
    background: #334155;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 10px;
}
.btn-ghost:hover {
    color: var(--text-primary);
}

.btn-icon {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.btn-icon:hover {
    background: #334155;
}

/* Main Container */
.main-container {
    max-width: 1440px;
    margin: 24px auto;
    padding: 0 28px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.kpi-card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

.kpi-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    position: absolute;
    top: 18px;
    right: 20px;
}
.kpi-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.kpi-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.kpi-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.kpi-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }

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

.kpi-value {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -1px;
}

.kpi-footer {
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

/* Content Panel */
.content-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

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

.panel-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0f1523;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    color: var(--text-secondary);
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 13px;
    width: 240px;
}

.filter-tabs {
    display: flex;
    background: #0f1523;
    border-radius: var(--radius-sm);
    padding: 3px;
    border: 1px solid var(--border-color);
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background: #1e293b;
    color: #fff;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    background: #0d121c;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: var(--bg-card-hover);
}

.cell-order {
    font-weight: 600;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
}

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

.cell-danfe {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    background: #0c1017;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-shipped { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-out_for_delivery { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-delivered { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-none { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }

/* Account / Company Badges */
.badge-account {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
}

.badge-account.badge-rj {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-account.badge-es {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

/* Dots for Company Tabs */
.dot-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.dot-rj { background-color: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.dot-es { background-color: #a855f7; box-shadow: 0 0 6px rgba(168, 85, 247, 0.6); }

.account-filter-btn.active[data-account="rj"] {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}
.account-filter-btn.active[data-account="es"] {
    background: rgba(168, 85, 247, 0.2);
    color: #c084fc;
}

.tracking-link {
    color: var(--accent-cyan);
    text-decoration: none;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tracking-link:hover {
    text-decoration: underline;
}

/* Log Panel */
.log-panel {
    max-height: 380px;
}

.log-stream {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: #0a0d14;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: #0f1523;
    border-left: 3px solid var(--border-color);
}
.log-entry.info { border-left-color: var(--accent-blue); }
.log-entry.success { border-left-color: var(--accent-emerald); }
.log-entry.warning { border-left-color: var(--accent-amber); }
.log-entry.error { border-left-color: var(--accent-rose); }

.log-time {
    color: var(--text-muted);
    font-size: 11px;
    min-width: 75px;
}

.log-text {
    color: var(--text-primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.open {
    display: flex;
}

.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 650px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
}
.modal-close:hover { color: #fff; }

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.code-textarea {
    width: 100%;
    background: #0a0d14;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #38bdf8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 12px;
    outline: none;
    resize: vertical;
}

.modal-footer {
    padding: 14px 24px;
    background: #0d121c;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background: #1e293b;
    border-left: 4px solid var(--accent-blue);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease forwards;
}
.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-rose); }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.text-right { text-align: right; }
.loading-cell { text-align: center; padding: 40px 0; color: var(--text-muted); }

.cell-danfe-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.25);
    color: var(--accent-cyan);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.cell-danfe-badge:hover {
    background: rgba(6, 182, 212, 0.18);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
}
.cell-danfe-badge .copy-hint {
    opacity: 0.6;
    font-size: 10px;
}
.cell-danfe-badge:hover .copy-hint {
    opacity: 1;
}

/* Informar em Rota Button & Modal Styles */
.btn-route-blue {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.45);
    color: #38bdf8;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 4px;
}
.btn-route-blue:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.55);
    transform: translateY(-1px);
}
.btn-route-blue:active {
    transform: translateY(0);
}

.btn-route {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.3));
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    margin-right: 6px;
}
.btn-route:hover {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border-color: #10b981;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}
.btn-route:active {
    transform: translateY(0);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.form-input {
    background: #0a0d14;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #f8fafc;
    font-size: 13px;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.25);
}
.form-hint {
    font-size: 11px;
    color: var(--text-muted);
}
.route-order-summary {
    background: #0a0d14;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.route-preview-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
}

