:root {
    --primary: #1e40af;
    --primary-hover: #1e3a8a;
    --accent: #f59e0b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --sidebar-bg: #1e3a5f;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 8px;
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { font-weight: 600; margin-bottom: 0.5rem; color: #0f172a; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout Shell */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand h2 { color: white; margin: 0; font-size: 1.25rem; }
.emoji-logo { font-size: 1.5rem; }

.sidebar-nav { flex: 1; padding: 20px 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav .nav-item {
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s, color 0.2s;
}
.sidebar-nav .nav-item:hover, .sidebar-nav .nav-item.active {
    background-color: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    border-left: 4px solid var(--accent);
}
.sidebar-nav .nav-item:not(.active) { border-left: 4px solid transparent; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.875rem;
}
.user-info { margin-bottom: 12px; font-weight: 500; }

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 24px;
    min-width: 0; /* for flex charts */
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
}
.stat-card {
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
}
.stat-card-title { font-size: 0.875rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.stat-card-value { font-size: 1.875rem; font-weight: 700; margin-top: 8px; }

/* Grid Layouts */
.grid { display: grid; gap: 20px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

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

/* Badges */
.badge {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 4px 8px; font-size: 0.75rem; font-weight: 600;
    border-radius: 9999px; line-height: 1; white-space: nowrap;
}
.badge-alert {
    background-color: var(--danger);
    color: white;
    min-width: 20px; height: 20px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
}
/* Status Colors */
.badge-status-Aberto { background-color: #dbeafe; color: #1e40af; }
.badge-status-Embarcado { background-color: #dcfce7; color: #166534; }
.badge-status-Fechado { background-color: #f1f5f9; color: #475569; }
.badge-status-Cancelado { background-color: #fee2e2; color: #991b1b; }

/* Urgency Colors */
.urgency-urgente { background-color: #fee2e2; border-left: 4px solid var(--danger); }
.urgency-atencao { background-color: #fef3c7; border-left: 4px solid var(--warning); }
.urgency-normal { background-color: #dcfce7; border-left: 4px solid var(--success); }

.badge-urgency-urgente { background-color: var(--danger); color: white; }
.badge-urgency-atencao { background-color: var(--warning); color: white; }
.badge-urgency-normal { background-color: var(--success); color: white; }

/* Tables */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.875rem; }
th, td { padding: 12px; border-bottom: 1px solid var(--border-color); }
th { background-color: #f8fafc; font-weight: 600; color: var(--text-muted); }
tr:hover td { background-color: #f1f5f9; }

/* Forms */
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-size: 0.875rem; font-weight: 500; }
input, select, textarea {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px; font-family: inherit; font-size: 0.875rem;
    transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; font-size: 0.875rem; font-weight: 500;
    border-radius: 6px; border: none; cursor: pointer;
    transition: all 0.2s; text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); text-decoration: none; color: white;}
.btn-secondary { background-color: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background-color: #cbd5e1; text-decoration: none; }
.btn-danger { background-color: var(--danger); color: white; }
.btn-danger:hover { background-color: #b91c1c; text-decoration: none; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-card { width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--text-muted);
}
.hidden { display: none !important; }

/* Login Page */
#login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #e2e8f0; }
.login-card { width: 100%; max-width: 400px; padding: 40px; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 1.5rem; color: var(--primary); }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 24px; }

/* Toasts */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius); color: white;
    box-shadow: var(--shadow-md); font-size: 0.875rem;
    animation: slideIn 0.3s ease-out;
}
.toast.success { background-color: var(--success); }
.toast.error { background-color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.spinner {
    border: 3px solid rgba(0,0,0,0.1); width: 24px; height: 24px;
    border-radius: 50%; border-left-color: var(--primary);
    animation: spin 1s linear infinite; display: inline-block;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Filter Bar */
.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar > div { flex: 1; min-width: 150px; }
.filter-bar .form-group { margin-bottom: 0; }
