:root {
    --primary: #1e3a5f;
    --primary-dark: #0f2744;
    --accent: #e67e22;
    --sidebar-width: 260px;
    --sidebar-bg: #0c2d48;
    --sidebar-hover: #1e3a5f;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f1f5f9;
    min-height: 100vh;
}

.wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header i { font-size: 1.75rem; color: var(--accent); flex-shrink: 0; }
.sidebar-station { font-size: 0.7rem; color: #94a3b8; font-weight: 400; }

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li.active a {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: #818cf8;
}

.sidebar-nav li a i { font-size: 1.1rem; width: 24px; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #f87171;
    text-decoration: none;
    font-size: 0.9rem;
}

.logout-btn:hover { color: #ef4444; }

/* Content */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    background: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

#sidebarToggle {
    font-size: 1.5rem;
    color: #64748b;
    text-decoration: none;
    padding: 0;
}

.main-content { padding: 1.5rem; }

/* Cards */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
}

.stat-card .stat-label {
    color: #64748b;
    font-size: 0.875rem;
}

/* Table */
.card-table {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.card-table .card-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table { margin-bottom: 0; }

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.table td { vertical-align: middle; }

/* Badges */
.badge-available { background: #dcfce7; color: #166534; }
.badge-occupied { background: #fee2e2; color: #991b1b; }
.badge-maintenance { background: #fef3c7; color: #92400e; }
.badge-reserved { background: #dbeafe; color: #1e40af; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-completed { background: #e0e7ff; color: #3730a3; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.badge-role-admin { background: #dbeafe; color: #1e40af; }
.badge-role-station_master { background: #fef3c7; color: #92400e; }
.badge-role-commercial_inspector { background: #e0e7ff; color: #3730a3; }

.sidebar-role { font-size: 0.65rem; color: var(--accent); }

/* RBAC permission matrix */
.rbac-group { border-top: 1px solid var(--border, #e5e7eb); }
.rbac-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
}
.rbac-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .75rem;
    padding: 1rem 1.25rem 1.25rem;
}
.rbac-item {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .75rem .85rem;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    margin: 0;
}
.rbac-item:hover { border-color: #93c5fd; box-shadow: 0 1px 4px rgba(37, 99, 235, .08); }
.rbac-item-body { display: flex; flex-direction: column; gap: .15rem; }
.rbac-item-body strong { font-size: .9rem; }
.rbac-item-body small { color: #64748b; line-height: 1.35; }
.rbac-slug { font-size: .68rem; color: #94a3b8; margin-top: .15rem; }
.rbac-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.sidebar-divider {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
}

.nav-tabs .nav-link { color: #475569; }
.nav-tabs .nav-link.active { color: var(--primary); font-weight: 600; }

.profile-avatar i { font-size: 5rem; color: var(--primary); }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0c2d48 0%, #1e3a5f 50%, #e67e22 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo i {
    font-size: 3rem;
    color: var(--primary);
}

.login-card .logo h2 {
    margin-top: 0.5rem;
    color: #1e293b;
    font-weight: 700;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .content { margin-left: 0; }
}

/* Modal */
.modal-header { border-bottom: 1px solid #e2e8f0; }
.modal-footer { border-top: 1px solid #e2e8f0; }

/* Action buttons */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #94a3b8;
}

.empty-state i { font-size: 3rem; margin-bottom: 1rem; }
