:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

[data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3 { font-weight: 700; color: var(--text-main); }
.text-muted { color: var(--text-muted); font-size: 0.875rem; }

/* Layout Components */
.container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1200px; }
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

.card[onclick]:active, [style*="cursor: pointer"]:active {
    transform: scale(0.97) !important;
    opacity: 0.8;
    transition: transform 0.08s ease, opacity 0.08s ease;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
}

a[href*="action=edit"]:active, a[href*="edit_room"]:active, a[href*="edit_floor"]:active {
    opacity: 0.7;
    transform: scale(0.96);
}

.card:active { transform: scale(0.98); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    width: 100%;
    gap: 0.5rem;
    min-height: 44px;
    font-size: 0.95rem;
}

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

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }

.btn-cancel { background: transparent; border: 1px solid #e2e8f0; color: #64748b; }
.btn-cancel:hover { background: rgba(239,68,68,0.08); border-color: var(--danger); color: var(--danger); }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.form-actions .btn, .form-actions .btn-cancel { flex: 1; min-width: 120px; }

.btn-auto { width: auto; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; min-height: 44px; }
.btn-tab { width: auto; padding: 0.4rem 1rem; font-size: 0.8rem; white-space: nowrap; min-height: 44px; }

/* Form Controls */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-pending { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-progress { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-completed { background: rgba(16, 185, 129, 0.1); color: var(--success); }

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    gap: 0.25rem;
    flex: 1 0 auto;
    min-width: 56px;
    max-width: 80px;
    padding: 0.2rem 0.25rem;
    cursor: pointer;
    background: none;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--primary); }
.nav-item i { font-size: 1.2rem; }

/* Dashboard Grids */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stat-card {
    text-align: center;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); }

/* Animations */
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-slide-up { animation: slideUp 0.4s ease forwards; }

/* Skeleton loader */
.skeleton-body .card { position: relative; overflow: hidden; pointer-events: none; }
.skeleton-body .card::after {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    border-radius: inherit; z-index: 2;
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* Loading overlay */
#page-loader { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(255,255,255,0.85); align-items: center; justify-content: center; flex-direction: column; gap: 1rem; }
#page-loader.show { display: flex; }
#page-loader .spinner { width: 36px; height: 36px; border-width: 4px; border-color: var(--primary); border-right-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
#page-loader p { font-size: 0.85rem; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { pointer-events: none; opacity: 0.7; }

.unit-map-card:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
