/* ============================================================
   DESIGN TOKENS (CSS Variables)
   ============================================================ */
:root {
    /* Gray */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Blue */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;

    /* Emerald */
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-400: #34d399;
    --emerald-600: #059669;
    --emerald-700: #047857;

    /* Green */
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-600: #16a34a;
    --green-700: #15803d;
    --green-800: #166534;

    /* Red */
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --red-800: #991b1b;

    /* Yellow */
    --yellow-50: #fefce8;
    --yellow-700: #a16207;

    /* Amber */
    --amber-700: #b45309;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }
button { font-family: inherit; }
table { border-collapse: collapse; }
img, svg { display: block; }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.gap-1 { gap: 0.25rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.hidden { display: none !important; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.block { display: block; }
.relative { position: relative; }

.w-full { width: 100%; }
.min-h-screen { min-height: 100vh; }

.overflow-x-auto { overflow-x: auto; }
.overflow-hidden { overflow: hidden; }
.whitespace-nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.pointer-events-none { pointer-events: none; }

.transition { transition: all 0.2s; }
.transition-colors { transition: color 0.2s, background-color 0.2s, border-color 0.2s; }

/* ============================================================
   SPACING UTILITIES
   ============================================================ */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.mx-1 { margin-left: 0.25rem; margin-right: 0.25rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-8 { padding: 2rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pt-3 { padding-top: 0.75rem; }
.pl-4 { padding-left: 1rem; }

/* ============================================================
   TYPOGRAPHY UTILITIES
   ============================================================ */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-6xl { font-size: 3.75rem; line-height: 1; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.uppercase { text-transform: uppercase; }
.italic { font-style: italic; }

/* ============================================================
   COLOR UTILITIES
   ============================================================ */
.text-white { color: #fff; }
.text-gray-300 { color: var(--gray-300); }
.text-gray-400 { color: var(--gray-400); }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-gray-700 { color: var(--gray-700); }
.text-gray-800 { color: var(--gray-800); }
.text-blue-500 { color: var(--blue-500); }
.text-blue-600 { color: var(--blue-600); }
.text-blue-700 { color: var(--blue-700); }
.text-blue-800 { color: var(--blue-800); }
.text-emerald-400 { color: var(--emerald-400); }
.text-emerald-600 { color: var(--emerald-600); }
.text-emerald-700 { color: var(--emerald-700); }
.text-green-600 { color: var(--green-600); }
.text-green-700 { color: var(--green-700); }
.text-green-800 { color: var(--green-800); }
.text-red-500 { color: var(--red-500); }
.text-red-600 { color: var(--red-600); }
.text-red-700 { color: var(--red-700); }
.text-yellow-700 { color: var(--yellow-700); }
.text-amber-700 { color: var(--amber-700); }

.bg-white { background-color: #fff; }
.bg-gray-50 { background-color: var(--gray-50); }
.bg-gray-100 { background-color: var(--gray-100); }
.bg-gray-200 { background-color: var(--gray-200); }
.bg-blue-100 { background-color: var(--blue-100); }
.bg-green-100 { background-color: var(--green-100); }

/* ============================================================
   BORDER UTILITIES
   ============================================================ */
.border { border: 1px solid var(--gray-200); }
.border-b { border-bottom: 1px solid var(--gray-200); }
.border-t { border-top: 1px solid var(--gray-200); }
.border-r { border-right: 1px solid var(--gray-100); }

.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); }

.divide-y > * + * { border-top: 1px solid var(--gray-100); }
.last\:border-b-0:last-child { border-bottom: 0; }
.last\:border-r-0:last-child { border-right: 0; }
.last\:mb-0:last-child { margin-bottom: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Desktop-only / Mobile-only display */
.nav-desktop { display: none; }
.nav-mobile-only { display: block; }

@media (min-width: 768px) {
    .nav-desktop { display: flex !important; }
    .nav-mobile-only { display: none !important; }
    .md\:flex { display: flex; }
    .md\:hidden { display: none; }
    .md\:flex-row { flex-direction: row; }
    .md\:w-48 { width: 12rem; }
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.25rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--blue-600);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--blue-700);
}

.btn-secondary {
    background: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
}

.btn-danger {
    background: var(--red-600);
    color: #fff;
}
.btn-danger:hover:not(:disabled) {
    background: var(--red-700);
}

/* Small inline action buttons */
.btn-action {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action-blue {
    color: var(--blue-600);
    background: var(--blue-50);
}
.btn-action-blue:hover { background: var(--blue-100); }

.btn-action-red {
    color: var(--red-600);
    background: var(--red-50);
}
.btn-action-red:hover { background: var(--red-100); }

.btn-action-green {
    color: var(--emerald-700);
    background: var(--emerald-50);
}
.btn-action-green:hover { background: var(--emerald-100, #d1fae5); }

.btn-action-yellow {
    color: var(--amber-700, #b45309);
    background: var(--amber-50, #fffbeb);
}
.btn-action-yellow:hover { background: var(--amber-100, #fef3c7); }

.btn-action-gray {
    color: var(--gray-600);
    background: var(--gray-100);
}
.btn-action-gray:hover { background: var(--gray-200); }

/* Pagination buttons */
.btn-page {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid var(--gray-300);
    background: #fff;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.25rem;
}
.btn-page:hover { background: var(--gray-50); }

.btn-page-active {
    background: var(--blue-600);
    color: #fff;
    border-color: var(--blue-600);
}
.btn-page-active:hover { background: var(--blue-700); }

.btn-page:disabled {
    color: var(--gray-400);
    background: var(--gray-100);
    border-color: var(--gray-200);
    cursor: not-allowed;
}

/* ============================================================
   FORM INPUTS
   ============================================================ */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    line-height: 1.25rem;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.form-select-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    overflow: hidden;
}

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

.table thead {
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    line-height: 1rem;
}

.table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.2s;
}
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

.table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    line-height: 1rem;
}

.badge-green { background: var(--emerald-50); color: var(--emerald-700); }
.badge-blue { background: var(--blue-50); color: var(--blue-700); }
.badge-yellow { background: var(--yellow-50); color: var(--yellow-700); }
.badge-red { background: var(--red-50); color: var(--red-700); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Tooltip popup (hover) */
.tooltip-popup {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    font-size: 0.75rem;
    color: var(--gray-700);
    z-index: 50;
    line-height: 1.4;
}
.group:hover .tooltip-popup { display: block; }

/* Inline status badges (in tooltips) */
.badge-sm {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    line-height: 1rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.card-form {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.page-body {
    background: var(--gray-50);
    min-height: 100vh;
}

.page-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 1.5rem;
    line-height: 1.75rem;
}

/* ============================================================
   NAVIGATION HEADER
   ============================================================ */
.nav-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 40;
}

.nav-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 0.625rem 1rem;
}

.nav-brand {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

.nav-logo-icon {
    width: 2rem;
    height: 2rem;
    background: var(--blue-600);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Segmented nav control */
.nav-segment {
    display: flex;
    background: var(--gray-100);
    border-radius: 0.5rem;
    padding: 0.1875rem;
    gap: 0.125rem;
}

.nav-segment-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-500);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-segment-item:hover {
    color: var(--gray-700);
}

.nav-segment-active {
    background: #fff;
    color: var(--gray-800);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.nav-segment-active:hover {
    color: var(--gray-800);
}

.nav-segment-icon {
    width: 0.9375rem;
    height: 0.9375rem;
    flex-shrink: 0;
}

.nav-segment-mobile {
    width: 100%;
}

.nav-segment-mobile .nav-segment-item {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.nav-divider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--gray-200);
}

.nav-username {
    font-size: 0.8125rem;
    color: var(--gray-500);
}

.nav-logout-btn {
    font-size: 0.8125rem;
    color: var(--gray-400);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
}

.nav-logout-btn:hover {
    color: var(--red-600);
    background: var(--red-50);
}

.nav-mobile-toggle {
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.nav-mobile-toggle:hover { background: var(--gray-100); }

/* Mobile menu */
.mobile-menu {
    padding-top: 0.75rem;
    margin-top: 0.625rem;
    border-top: 1px solid var(--gray-100);
}

.mobile-menu-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    background: var(--gray-100);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 2rem;
    width: 100%;
    max-width: 24rem;
    text-align: center;
}

.login-logo {
    width: 4rem;
    height: 4rem;
    background: var(--blue-600);
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.login-error {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--red-50);
    border: 1px solid var(--red-200);
    border-radius: 0.5rem;
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state-icon {
    width: 4rem;
    height: 4rem;
    background: var(--gray-100);
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.empty-state-icon-sm {
    width: 3rem;
    height: 3rem;
    background: var(--emerald-50);
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

/* ============================================================
   403 ERROR PAGE
   ============================================================ */
.error-page-body {
    background: var(--gray-100);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
    line-height: 1.25rem;
}

.breadcrumb a {
    color: var(--blue-600);
    cursor: pointer;
    text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }

/* ============================================================
   UPLOAD ZONE (drag-and-drop)
   ============================================================ */
.upload-dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-dropzone:hover {
    border-color: var(--blue-400);
    background: var(--blue-50);
}
.upload-dropzone.drag-active {
    border-color: var(--blue-500);
    background: var(--blue-50);
}

.upload-icon {
    margin: 0 auto;
    height: 3rem;
    width: 3rem;
    color: var(--gray-400);
}

/* File preview */
.file-preview {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
    border: 1px solid var(--gray-200);
}

/* Progress bar */
.progress-bar-bg {
    width: 100%;
    background: var(--gray-200);
    border-radius: 9999px;
    height: 0.5rem;
}

.progress-bar-fill {
    background: var(--blue-600);
    height: 0.5rem;
    border-radius: 9999px;
    transition: width 0.3s;
}

/* ============================================================
   IMPORT RESULTS
   ============================================================ */
.result-success {
    background: var(--green-50);
    border: 1px solid var(--green-200);
    border-radius: 0.5rem;
    padding: 1rem;
}

.result-success .divide-y > * + * {
    border-color: var(--green-100);
}

.result-error {
    background: var(--red-50);
    border: 1px solid var(--red-200);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* ============================================================
   ICON SIZES
   ============================================================ */
.icon-xs { width: 0.875rem; height: 0.875rem; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-xl { width: 2rem; height: 2rem; }

/* ============================================================
   GRID (Apartment Floor Grid)
   ============================================================ */
.grid-table {
    overflow-x: auto;
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border: 1px solid var(--gray-200);
    position: relative;
}

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

.grid-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
}
.grid-table tbody tr:last-child {
    border-bottom: none;
}

.grid-floor-label {
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--gray-400);
    background: var(--gray-50);
    border-right: 1px solid var(--gray-200);
    min-width: 4.5rem;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 2;
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
}

.apartment-cell {
    position: relative;
    padding: 0.5rem 0.75rem;
    border-right: 1px solid var(--gray-100);
    min-width: 110px;
    vertical-align: top;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}
.apartment-cell:last-child { border-right: none; }

.apartment-cell.occupied {
    background: var(--emerald-100);
    border-color: var(--emerald-200);
}
.apartment-cell.vacant {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.resident-link {
    color: var(--blue-600);
    font-size: 0.75rem;
    text-decoration: none;
    display: block;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.125rem;
}
.resident-link:hover {
    color: var(--blue-800);
    text-decoration: underline;
}

.apartment-cell a,
.apartment-cell span {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--blue-600);
    color: #fff;
    padding: 0.5rem 1rem;
    text-decoration: none;
    font-weight: 500;
    z-index: 100;
    border-radius: 0 0 0.375rem 0;
}
.skip-link:focus { top: 0; }

*:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

/* ============================================================
   HTMX TRANSITIONS
   ============================================================ */
.htmx-swapping {
    opacity: 0;
    transition: opacity 150ms ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 150ms ease-in;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* ============================================================
   SCROLLABLE TABS (with fade edges)
   ============================================================ */
.tabs-scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.tabs-scroll-container::-webkit-scrollbar { display: none; }


/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-blue {
    border-color: rgba(37, 99, 235, 0.3);
    border-top-color: var(--blue-600);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 24rem;
}

.toast {
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: start;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

.toast.toast-success {
    background: var(--emerald-50);
    border: 1px solid var(--emerald-200);
    color: var(--emerald-700);
}

.toast.toast-error {
    background: var(--red-50);
    border: 1px solid var(--red-200);
    color: var(--red-800);
}

.toast.toast-info {
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    color: var(--blue-800);
}

.toast-icon { flex-shrink: 0; }
.toast-message { flex: 1; font-size: 0.875rem; font-weight: 500; }

.toast-close {
    flex-shrink: 0;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    background: none;
    border: none;
    color: inherit;
    padding: 0;
}
.toast-close:hover { opacity: 1; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ============================================================
   CONFIRM MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden { display: none; }

.modal-container {
    width: 100%;
    max-width: 28rem;
    margin: 1rem;
    animation: slideUp 0.2s ease-out;
}

.modal-content {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-body { padding: 1.5rem; }

.modal-message {
    color: var(--gray-700);
    font-size: 0.875rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background-color: var(--gray-50);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    outline: none;
}

.modal-btn-cancel {
    background-color: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.modal-btn-cancel:hover { background-color: var(--gray-50); }

.modal-btn-confirm {
    background-color: var(--blue-600);
    color: #fff;
}
.modal-btn-confirm:hover { background-color: var(--blue-700); }

.modal-btn-danger {
    background-color: var(--red-600);
    color: #fff;
}
.modal-btn-danger:hover { background-color: var(--red-700); }

.modal-container-lg {
    max-width: 32rem;
}

.btn-green {
    background: var(--emerald-600);
    color: #fff;
}
.btn-green:hover:not(:disabled) {
    background: var(--emerald-700);
}

/* ============================================================
   QUICK CREATE WIZARD
   ============================================================ */
.wizard-steps {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-400);
    transition: color 0.2s;
}

.wizard-step-active {
    color: var(--blue-600);
}

.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: var(--gray-200);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    transition: background 0.2s, color 0.2s;
}

.wizard-step-active .wizard-step-num {
    background: var(--blue-600);
    color: #fff;
}

.wizard-step-arrow {
    color: var(--gray-300);
    font-size: 1rem;
}

.summary-badge {
    margin-top: 0.75rem;
    padding: 0.625rem 1rem;
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--blue-700);
}

.wizard-preview {
    margin-top: 1rem;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    overflow: hidden;
}

.wizard-preview-title {
    padding: 0.5rem 0.875rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.wizard-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.wizard-preview-table th {
    padding: 0.375rem 0.875rem;
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--gray-400);
    text-transform: uppercase;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}

.wizard-preview-table td {
    padding: 0.3125rem 0.875rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

.wizard-preview-table tbody tr:last-child td {
    border-bottom: none;
}

.wizard-preview-table tfoot td {
    padding: 0.5rem 0.875rem;
    background: var(--blue-50);
    color: var(--blue-700);
    font-weight: 600;
    font-size: 0.8125rem;
    border-top: 1px solid var(--blue-200);
}

.wizard-preview-range {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--blue-700);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}
.modal-close-btn:hover { color: var(--gray-600); }

.modal-form {
    display: flex;
    flex-direction: column;
}

.modal-form-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-form-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding-top: 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

.form-static-value {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--gray-800);
    font-weight: 500;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(1rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   TAB STYLES
   ============================================================ */
/* Admin tabs (underline style) */
.tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    color: var(--gray-500);
    transition: all 0.2s;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover { color: var(--gray-700); }
.tab-active {
    border-bottom-color: var(--blue-600);
    color: var(--blue-600);
}

/* Building tabs (rounded button style) */
.building-tab {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: #fff;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
    cursor: pointer;
}
.building-tab:hover { background: var(--gray-100); }
.building-tab-active {
    background: var(--blue-600);
    color: #fff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    border-color: var(--blue-600);
}

/* Entrance tabs (pill style) */
.entrance-tab {
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--gray-100);
    color: var(--gray-600);
    white-space: nowrap;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}
.entrance-tab:hover { background: var(--gray-200); }
.entrance-tab-active {
    background: var(--blue-100);
    color: var(--blue-700);
}

/* ============================================================
   SCROLL SMOOTH (for entrance tabs)
   ============================================================ */
.scroll-smooth { scroll-behavior: smooth; }
.min-w-max { min-width: max-content; }

/* ============================================================
   GRID ENHANCEMENTS
   ============================================================ */
/* Zebra rows */
.grid-table tbody tr:nth-child(even) .apartment-cell {
    filter: brightness(0.98);
}
.grid-table tbody tr:hover td:not(.grid-floor-label) {
    filter: brightness(0.96);
}

/* Pre-filled status (blue) */
.apartment-cell.pre-filled {
    background: var(--blue-50);
    border-color: var(--blue-100);
}

/* Search highlight */
.apartment-cell.search-highlight {
    outline: 2px solid var(--blue-500);
    outline-offset: -2px;
    z-index: 1;
}
.apartment-cell.search-dimmed {
    opacity: 0.3;
}

/* Legend */
.grid-legend {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.grid-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.grid-legend-dot {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

/* Stats progress bar */
.stats-progress {
    width: 100%;
    height: 0.375rem;
    background: var(--gray-200);
    border-radius: 9999px;
    overflow: hidden;
}

.stats-progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s;
}

/* Fade scroll indicators for tabs */
.tabs-scroll-container.has-scroll-right {
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent);
    mask-image: linear-gradient(to right, black 85%, transparent);
}
.tabs-scroll-container.has-scroll-left {
    -webkit-mask-image: linear-gradient(to left, black 85%, transparent);
    mask-image: linear-gradient(to left, black 85%, transparent);
}
.tabs-scroll-container.has-scroll-both {
    -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
    mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
}

/* HTMX loading skeleton */
.grid-skeleton {
    display: none;
    padding: 1rem;
}

.htmx-request .grid-skeleton {
    display: block;
}

.htmx-request .grid-skeleton-target {
    display: none;
}

.skeleton-line {
    height: 0.75rem;
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    border-radius: 0.25rem;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Search input */
.grid-search-input {
    max-width: 14rem;
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    font-size: 0.8125rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.grid-search-input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.grid-search-wrap {
    position: relative;
}

.grid-search-icon {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    color: var(--gray-400);
    pointer-events: none;
}
