:root {
    /* Mud Palette - Source of Truth */
    --mud-palette-background: #f8f8f8;
    --mud-palette-background-grey: #f1f1f1;
    --mud-palette-surface: #fff;
    --mud-palette-on-surface: #667788;
    --mud-palette-appbar: #546E7A;
    --mud-palette-on-appbar: #d4d4d4;
    --mud-palette-drawer: #fff;
    --mud-palette-on-drawer: #444;
    --mud-palette-text-default: #6a6a6a;
    --mud-palette-default: rgba(0, 0, 0, 0.54);
    --mud-palette-on-default: rgba(0, 0, 0, 0.87);
    --mud-palette-primary: #8ec7d8;
    --mud-palette-on-primary: #fff;
    --mud-palette-primary-lighten: #a8d7e4;
    --mud-palette-primary-darken: #7bb8c9;
    --mud-palette-primary-hover: rgba(142, 199, 216, 0.08);
    --mud-palette-secondary: #8e3e8d;
    --mud-palette-on-secondary: #fff;
    --mud-palette-success: #4caf50;
    --mud-palette-warning: #ff9800;
    --mud-palette-danger: #f44336;
    --mud-palette-dark: #272c34;
    --mud-palette-border-color-default: #e0e0e0;
    --mud-palette-border-radius-default: 5px;

    /* Functional Mappings */
    --primary: var(--mud-palette-primary);
    --primary-hover: var(--mud-palette-primary-darken);
    --bg-dark: var(--mud-palette-background);
    --bg-surface: var(--mud-palette-surface);
    --bg-card: var(--mud-palette-surface);
    --text-main: var(--mud-palette-text-default);
    --text-muted: var(--mud-palette-on-surface);
    --border-color: var(--mud-palette-border-color-default);
    --success: var(--mud-palette-success);
    --warning: var(--mud-palette-warning);
    --danger: var(--mud-palette-danger);
    --radius-default: var(--mud-palette-border-radius-default);

    --elevation-1: 0 1px 3px rgba(0, 0, 0, 0.1);
    --elevation-2: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --elevation-3: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 90vh;
    overflow-x: hidden;
}

/* Material Sharp Cards */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-default);
    /* Material corners */
    padding: 1.5rem;
    box-shadow: var(--elevation-1);
    transition: box-shadow 0.2s, transform 0.2s;
}

.glass-card:hover {
    box-shadow: var(--elevation-2);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 50;
    box-shadow: 1px 0 10px rgba(0, 0, 0, 0.05);
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text-main);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

/* Navigation */
.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-default);
    transition: all 0.2s;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

/* Authentication */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-dark);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* Form elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
    border-radius: 0;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    border-bottom-color: var(--primary);
    background: #fcfdfe;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--elevation-1);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--elevation-2);
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 4rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--elevation-3);
    border-radius: 50%;
    text-decoration: none;
    z-index: 100;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: var(--elevation-4);
    background: var(--primary-hover);
}

/* Table styling */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
    font-weight: 600;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.2s;
}

.clickable-row:hover {
    background: #f1f5f9;
}

/* Status badges */
.status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    display: inline-flex;
    align-items: center;
    background-color: color-mix(in srgb, var(--badge-color, var(--primary)), transparent 90%);
    color: var(--badge-color, var(--primary));
    border: 1px solid color-mix(in srgb, var(--badge-color, var(--primary)), transparent 85%);
}

/* WhatsApp-style Chat Layout */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: #e5ddd5;
    /* Classic WhatsApp background light */
    background-image: radial-gradient(#d4ccc4 1px, transparent 1px);
    background-size: 20px 20px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message-item {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.message-item.self {
    align-self: flex-end;
}

.message-item.other {
    align-self: flex-start;
}

.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: 0;
    box-shadow: var(--elevation-1);
    line-height: 1.6;
}

.message-item.self .message-bubble {
    background: #dcf8c6;
    color: #1e293b;
    border: 1px solid #c5e1a5;
}

.message-item.other .message-bubble {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.message-meta {
    font-size: 0.725rem;
    color: #64748b;
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.message-item.self .message-meta {
    justify-content: flex-end;
}

.message-item.other .message-meta {
    justify-content: flex-start;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    gap: 0.5rem;
}

.page-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.page-btn:hover:not(.disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f1f5f9;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Utilities */
.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mt-8 {
    margin-top: 2rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.ml-auto {
    margin-left: auto;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.w-full {
    width: 100%;
}

.max-w-800 {
    max-width: 800px;
}

.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--danger);
}

.bg-danger-light {
    background: rgba(239, 68, 68, 0.1);
}

.border-danger {
    border: 1px solid var(--danger);
}

.rounded-lg {
    border-radius: 0.5rem;
}

.p-4 {
    padding: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-decoration-none {
    text-decoration: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hidden {
    display: none !important;
}