/* Global styles */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f5f7fb;
    color: #1f2933;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #1e293b;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.sidebar-logo {
    font-size: 1.5rem;
}

.sidebar-title {
    font-weight: 600;
    margin-left: 0.25rem;
}

.sidebar.collapsed .sidebar-title {
    display: none;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: #e5e7eb;
    cursor: pointer;
    font-size: 1.1rem;
}

.sidebar-nav {
    padding: 0.5rem 0.5rem 1rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    color: #cbd5f5;
    margin-bottom: 0.25rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.nav-item:hover {
    background: rgba(148, 163, 184, 0.2);
    transform: translateX(2px);
}

.nav-item.active {
    background: #6366f1;
    color: #f9fafb;
}

.nav-icon {
    width: 1.5rem;
    text-align: center;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.breadcrumbs {
    font-size: 0.9rem;
    color: #6b7280;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-name {
    font-weight: 500;
}

.content {
    padding: 1.5rem;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Cards & layout */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 1024px) {
    .grid-4, .grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

.card {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1rem 1.1rem;
    box-shadow: 0 10px 15px -10px rgba(15, 23, 42, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-kpi {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.muted {
    font-size: 0.8rem;
    color: #6b7280;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.1s ease, transform 0.05s ease;
}

.btn-primary {
    background: #4f46e5;
    color: #f9fafb;
}

.btn-primary:hover {
    background: #4338ca;
    box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.7);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: #374151;
}

.btn-ghost:hover {
    background: #e5e7eb;
}

.btn-sm {
    padding: 0.25rem 0.7rem;
    font-size: 0.8rem;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th,
.table td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8rem;
    color: #6b7280;
}

.table tr:hover td {
    background: #f3f4ff;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-outline {
    border: 1px solid #e5e7eb;
    color: #4b5563;
    background: #f9fafb;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #4b5563;
}

.form-control,
.form-select,
textarea.form-control {
    padding: 0.45rem 0.6rem;
    border-radius: 0.45rem;
    border: 1px solid #d1d5db;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
}

/* Toast notifications */
.toast {
    position: fixed;
    right: 1.2rem;
    bottom: 1.2rem;
    min-width: 220px;
    max-width: 320px;
    background: #111827;
    color: #f9fafb;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.85rem;
    box-shadow: 0 20px 40px -20px rgba(15, 23, 42, 0.8);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-success {
    background: #065f46;
}

.toast-error {
    background: #b91c1c;
}

.hidden {
    display: none;
}

/* Spinner overlay */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty states */
.empty-state {
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: #6b7280;
}

.empty-state-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

/* Login page */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #eef2ff 0, #e5e7eb 60%, #f9fafb 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 1.75rem 1.75rem;
    box-shadow: 0 18px 45px -24px rgba(15, 23, 42, 0.8);
}

.auth-header {
    text-align: center;
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: #6b7280;
}

.auth-role-select {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.role-pill {
    flex: 1;
    text-align: center;
    padding: 0.35rem 0.1rem;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.role-pill.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #f9fafb;
}

.auth-footer {
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
}

/* Messages list */
.message-list {
    max-height: 340px;
    overflow: auto;
}

.message-item {
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    margin-bottom: 0.35rem;
    background: #f9fafb;
}

.message-item.unread {
    background: #eef2ff;
}

.message-meta {
    font-size: 0.7rem;
    color: #6b7280;
    margin-bottom: 0.15rem;
}

.message-body {
    font-size: 0.8rem;
}

