/* Common Styles - Used across all pages */
@import url('variables.css');

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

body {
    font-family: var(--font-family-primary);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 {
    font-size: var(--font-size-4xl);
}
h2 {
    font-size: var(--font-size-3xl);
}
h3 {
    font-size: var(--font-size-2xl);
}
h4 {
    font-size: var(--font-size-xl);
}
h5 {
    font-size: var(--font-size-lg);
}
h6 {
    font-size: var(--font-size-base);
}

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--secondary-color);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.header-content h1 {
    margin: 0 0 2px 0;
    color: var(--text-dark);
    font-size: 20px;
    font-weight: var(--font-weight-bold);
}

.header-content p {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

/* Common Card Component */
.card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: var(--font-weight-semibold);
}

.card-body {
    padding: 16px 18px;
}

/* ==========================================
   SHARED STAT CARDS
   ========================================== */
.stats-row,
.expense-stats,
.comm-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.comm-stats-row {
    grid-template-columns: repeat(3, 1fr);
}

.expense-stats {
    grid-template-columns: repeat(2, 1fr);
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: #f3f4f6;
    color: #6b7280;
    flex-shrink: 0;
}

.stat-icon.occupied  { background: #dbeafe; color: #3b82f6; }
.stat-icon.available { background: #d1fae5; color: #047857; }
.stat-icon.service   { background: #fef3c7; color: #f59e0b; }
.stat-icon.revenue   { background: #d1fae5; color: #047857; }
.stat-icon.danger    { background: #fee2e2; color: #dc2626; }
.stat-icon.pending   { background: #fef3c7; color: #f59e0b; }
.stat-icon.approved  { background: #d1fae5; color: #047857; }

.stat-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 22px;
    font-weight: var(--font-weight-bold);
    color: var(--text-dark);
    line-height: 1.1;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1100px) {
    .stats-row,
    .expense-stats,
    .comm-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .stats-row,
    .expense-stats,
    .comm-stats-row {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   Skeleton Loaders
   Reusable shimmer placeholders for any async-loading content.
   Usage:
     <span class="skeleton skeleton-stat"></span>       stat numbers
     <span class="skeleton skeleton-text"></span>       a text line (full width)
     <span class="skeleton skeleton-text w-50"></span>  width modifiers (w-25..w-90)
     <span class="skeleton skeleton-badge"></span>      pill / status badge
     <span class="skeleton skeleton-circle"></span>     avatar (set width+height)
     <span class="skeleton skeleton-block"></span>      chart / large block (set height)
   For tables, repeat a <tr class="skeleton-row"> of <td><span class="skeleton skeleton-text"></span></td>.
   Any JS that later sets .textContent / .innerHTML on the host element removes
   the skeleton automatically -- no JS teardown needed.
   =================================================================== */
.skeleton {
    position: relative;
    display: inline-block;
    overflow: hidden;
    background-color: #e6e7e9;
    border-radius: var(--border-radius-md);
    color: transparent;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}
.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.6) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Shapes */
.skeleton-text {
    width: 100%;
    height: 0.72em;
    margin: 0.16em 0;
    border-radius: var(--border-radius-sm);
    vertical-align: middle;
}
.skeleton-stat {
    width: 84px;
    height: 1.05em;
    border-radius: var(--border-radius-sm);
    vertical-align: middle;
}
.skeleton-badge {
    width: 64px;
    height: 20px;
    border-radius: var(--border-radius-full);
    vertical-align: middle;
}
.skeleton-circle {
    border-radius: var(--border-radius-full);
}
.skeleton-block {
    display: block;
    width: 100%;
    height: 180px;
    border-radius: var(--border-radius-md);
}

/* Width modifiers for text lines */
.skeleton.w-25 { width: 25%; }
.skeleton.w-40 { width: 40%; }
.skeleton.w-50 { width: 50%; }
.skeleton.w-60 { width: 60%; }
.skeleton.w-75 { width: 75%; }
.skeleton.w-90 { width: 90%; }

.skeleton-row td {
    vertical-align: middle;
}

/* Drop-in skeleton for list / table loading containers (replaces a spinner).
   A stack of full-width shimmer bars; fills its parent so it works inside the
   existing centered .loading-spinner containers without any JS changes. */
.skeleton-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}
.skeleton-list .skeleton {
    display: block;
    width: 100%;
    height: 44px;
    border-radius: var(--border-radius-lg);
}
/* When a skeleton-list stands in for a spinner, neutralize the spinner's
   centering/typography so the bars span the full width. */
.loading-spinner:has(.skeleton-list) {
    display: block;
    padding: 4px 0;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton::after {
        animation: none;
    }
}

/* ==========================================
   SHARED FILTER BAR & VIEW TOGGLE
   ========================================== */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    margin-bottom: 12px;
    flex-wrap: wrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: space-between;
    align-items: center;
}

.ai-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 760px;
    margin: 0 0 12px;
    padding: 9px 12px;
    background: #faf9f6;
    border: 1px solid #ece8e1;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #78716c;
}

.ai-note svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--primary-color);
}

.view-toggle .left-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toggle-btn {
    padding: 7px 14px;
    background: var(--white);
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    transition: all var(--transition-fast);
}

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

.toggle-btn:hover:not(.active) {
    background: #f9fafb;
    border-color: #6b7280;
}

/* View All Link */
.link-view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    font-weight: var(--font-weight-medium);
    transition: color var(--transition-fast);
}

.link-view-all:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* No Data State */
.no-data {
    text-align: center;
    color: #6b7280;
    padding: 24px;
    font-size: 14px;
}

/* Empty State Card */
.empty-state-card {
    text-align: center;
    padding: var(--spacing-2xl);
    background: #f9fafb;
    border-radius: var(--border-radius-lg);
    border: 2px dashed #e5e7eb;
}

.empty-state-card h4 {
    margin: var(--spacing-md) 0;
    color: var(--text-dark);
}

.empty-state-card p {
    margin-bottom: var(--spacing-lg);
}

/* Payment Method Option */
.payment-method-option {
    display: block;
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
}

.payment-method-option input {
    display: none;
}

.payment-method-option .method-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border: 2px solid #e5e7eb;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.payment-method-option input:checked + .method-card {
    border-color: var(--primary-color);
    background: rgba(208, 167, 100, 0.05);
}

.payment-method-option .method-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.payment-method-option .method-info .badge {
    font-size: 10px;
    padding: 2px 6px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* Common Button Styles */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: background var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    position: relative;
    white-space: nowrap;
}

/* Loading state: hide text via visibility so button keeps its width */
.btn.is-loading .btn-text {
    visibility: hidden;
}

.btn.is-loading .btn-loading {
    display: inline-flex !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    pointer-events: none;
}

/* White spinner for colored (primary/danger/success) buttons */
.btn-primary .spinner,
.btn-danger .spinner,
.btn-success .spinner,
.btn-primary .spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* Filter Dropdown Styling */
.filter-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    background: var(--white);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(208, 167, 100, 0.1);
}

.requests-list h4 {
    color: var(--text-dark);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid #e5e7eb;
}

.btn-icon {
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    border-radius: var(--border-radius-sm, 4px);
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* Mouse focus stays quiet, but keyboard focus must show a visible ring (WCAG 2.4.7). */
.btn-icon:focus {
    outline: none;
    box-shadow: none;
}

.btn-icon:focus-visible {
    outline: 2px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(208, 167, 100, 0.3);
}

.btn-danger {
    background: #b91c1c;
    color: var(--text-light);
}

.btn-danger:hover:not(:disabled) {
    background: #991b1b;
}

.btn-success {
    background: #047857;
    color: var(--text-light);
}

.btn-success:hover:not(:disabled) {
    background: #047857;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    padding: 0;
    font-size: var(--font-size-sm);
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-large {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: var(--font-size-base);
}

/* Common Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal-backdrop);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn var(--transition-normal);
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius-xl);
    /* Wide enough for the two-column forms these modals actually hold. The old
       600px cap wrapped fields that had room to sit side by side, on screens with
       hundreds of pixels to spare. */
    max-width: 860px;
    width: min(92vw, 860px);
    max-height: 90vh;
    overflow-y: auto;
    /* Containing block for absolutely-positioned panels inside a modal (e.g. the
       tenant payment confirmation step). Without it those panels resolve against
       the fixed .modal and cover the whole viewport. */
    position: relative;
    z-index: var(--z-modal);
    animation: slideUp var(--transition-normal);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
}

.modal-close {
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: #6b7280;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: #f3f4f6;
    color: var(--text-dark);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-top: 1px solid #e5e7eb;
}

/* Confirm / alert / prompt dialog (async replacement for native window.confirm).
   Reuses the .modal-content look but lives on its own overlay so the global
   ModalManager handlers ignore it. A blocking confirm must sit above every other
   layer, matching native confirm(): above form modals (--z-modal 1050), and above
   the app's ad-hoc topmost chrome (MFA overlay 9999, Google Places autocomplete
   10000), so it can never be intercepted. Hence a value an order of magnitude
   above the app's maximum rather than a z-index token. */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    animation: fadeIn var(--transition-normal);
}

.confirm-dialog .confirm-dialog-content {
    max-width: 460px;
    width: 100%;
}

.confirm-dialog-message {
    margin: 0;
    color: #374151;
    font-size: var(--font-size-base);
    line-height: 1.6;
    white-space: pre-line;
}

.confirm-dialog-field {
    margin-top: var(--spacing-lg);
    margin-bottom: 0;
}

/* .form-group label's display: block outranks .checkbox-label's flex here, which
   left the box flush against its text. */
.confirm-dialog-field .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.confirm-dialog-field .input-error {
    border-color: #b91c1c;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

/* Common Form Styles */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: var(--font-weight-medium);
    color: #374151;
    font-size: var(--font-size-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-base);
    font-family: var(--font-family-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(208, 167, 100, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    color: var(--text-dark);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.filter-group label {
    font-size: var(--font-size-sm);
    color: #6b7280;
    font-weight: var(--font-weight-medium);
}

.filter-group select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    background: var(--white);
    min-width: 120px;
}

.search-group {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-group input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    padding-right: 40px;
    border: 1px solid #d1d5db;
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
}

.search-group .icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
}

/* Common Badge Styles */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}

.badge-primary {
    background: var(--primary-color);
    color: var(--text-light);
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fed7aa;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Lease status pills (badge badge-<lease.status>, labeled by leaseStatusLabel).
   They lived only in lease-details.css and unit-details.css, so every other page
   rendered the status as bare text. */
.badge-active {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #86efac;
}

.badge-expired {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

.badge-terminated {
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.badge-pending {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fcd34d;
}

.app-status {
    white-space: nowrap;
    border: 1px solid transparent;
    letter-spacing: 0.02em;
}

.app-status--invited,
.app-status--in_progress {
    background: #f5f5f4;
    color: #57534e;
    border-color: #e7e5e4;
}

.app-status--submitted,
.app-status--screening {
    background: #dbeafe;
    color: #1e40af;
    border-color: #bfdbfe;
}

.app-status--review_ready,
.app-status--pending {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.app-status--approved {
    background: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

.app-status--declined {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.app-status--withdrawn,
.app-status--expired {
    background: #fafaf9;
    color: #a8a29e;
    border-color: #e7e5e4;
}

/* Common Status Styles */
.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-active,
.status-assigned,
.status-in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-received {
    background: #dbeafe;
    color: #1e40af;
}

.status-pending,
.status-processing {
    background: #fef3c7;
    color: #92400e;
}

.stripe-processing-note {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #92400e;
    margin-top: 4px;
    padding: 2px 6px;
    background: #fef3c7;
    border-radius: 4px;
}

.status-cancelled,
.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.status-refunded,
.status-partial_refund {
    background: #e0e7ff;
    color: #3730a3;
}

/* Common Alert Styles */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid #047857;
}

.alert-warning {
    background: #fed7aa;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert strong {
    display: block;
    margin-bottom: var(--spacing-xs);
}

.billing-impact-note {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-lg);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.billing-impact-note[hidden] {
    display: none;
}

.billing-impact-note p {
    margin: 0;
}

.billing-impact-note a {
    color: inherit;
    font-weight: var(--font-weight-semibold);
}

.billing-impact-note.info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.billing-impact-note.error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

table th {
    text-align: left;
    padding: var(--spacing-md);
    background: #f9fafb;
    font-weight: var(--font-weight-semibold);
    color: #4b5563;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    border-bottom: 2px solid #e5e7eb;
}

table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid #f3f4f6;
}

table tbody tr:hover {
    background: #f9fafb;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

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

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

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

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}
.text-right {
    text-align: right;
}
.text-left {
    text-align: left;
}

.mt-0 {
    margin-top: 0;
}
.mt-1 {
    margin-top: var(--spacing-sm);
}
.mt-2 {
    margin-top: var(--spacing-md);
}
.mt-3 {
    margin-top: var(--spacing-lg);
}
.mt-4 {
    margin-top: var(--spacing-xl);
}

.mb-0 {
    margin-bottom: 0;
}
.mb-1 {
    margin-bottom: var(--spacing-sm);
}
.mb-2 {
    margin-bottom: var(--spacing-md);
}
.mb-3 {
    margin-bottom: var(--spacing-lg);
}
.mb-4 {
    margin-bottom: var(--spacing-xl);
}

.p-0 {
    padding: 0;
}
.p-1 {
    padding: var(--spacing-sm);
}
.p-2 {
    padding: var(--spacing-md);
}
.p-3 {
    padding: var(--spacing-lg);
}
.p-4 {
    padding: var(--spacing-xl);
}

.d-none {
    display: none;
}
.d-block {
    display: block;
}
.d-flex {
    display: flex;
}
.d-grid {
    display: grid;
}

.align-center {
    align-items: center;
}
.justify-center {
    justify-content: center;
}
.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: var(--spacing-sm);
}
.gap-2 {
    gap: var(--spacing-md);
}
.gap-3 {
    gap: var(--spacing-lg);
}

.w-100 {
    width: 100%;
}
.h-100 {
    height: 100%;
}

/* Container */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

@media (min-width: 576px) {
    .container {
        max-width: var(--container-sm);
    }
}

@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
    }
    .form-row-md {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: var(--container-lg);
    }
}

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

@media (min-width: 1400px) {
    .container {
        max-width: var(--container-xxl);
    }
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        gap: var(--spacing-lg);
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .hide-mobile {
        display: none;
    }
    .form-row {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: var(--font-size-3xl);
    }
    h2 {
        font-size: var(--font-size-2xl);
    }
    h3 {
        font-size: var(--font-size-xl);
    }

    /* Modal: near-fullscreen on mobile */
    .modal-content {
        width: 95%;
        max-height: 92vh;
        border-radius: var(--border-radius-lg);
    }

    .modal-header {
        padding: var(--spacing-md);
    }

    .modal-header h2 {
        font-size: var(--font-size-lg);
    }

    .modal-body {
        padding: var(--spacing-md);
    }

    .modal-close {
        width: 36px;
        height: 36px;
        font-size: var(--font-size-xl);
    }

    /* Card header: stack on mobile */
    .card-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: flex-start;
        padding: 12px 14px;
    }

    .card-header h3 {
        font-size: 14px;
    }

    .card-body {
        padding: var(--spacing-md);
    }

    /* Form fields */
    .form-group label {
        font-size: var(--font-size-sm);
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Buttons */
    .btn {
        font-size: var(--font-size-sm);
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .modal {
        align-items: flex-end;
    }

    .modal-content {
        width: 100%;
        max-height: 95vh;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        animation: slideUpModal 0.25s ease;
    }

    @keyframes slideUpModal {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .card-header {
        padding: 10px 12px;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none;
    }
}

/* Lease e-signature: signer rows in the create-lease modal */
.form-subsection {
    margin-top: 14px;
    padding: 14px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.form-subsection h4 {
    margin: 0 0 4px;
    font-size: 14px;
}
.signers-list {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.signer-row {
    display: grid;
    grid-template-columns: 1.4fr 1.6fr 0.9fr auto;
    gap: 8px;
    align-items: center;
}
.signer-row input,
.signer-row select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}
@media (max-width: 640px) {
    .signer-row {
        grid-template-columns: 1fr;
    }
}

/* Skip to content link: visually hidden until it receives keyboard focus */
.skip-link {
    position: absolute;
    top: -48px;
    left: 8px;
    z-index: var(--z-tooltip, 1070);
    padding: 0.625rem 1rem;
    background: var(--primary-color);
    color: var(--text-light);
    border-radius: var(--border-radius-md);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    transition: top var(--transition-fast);
}
.skip-link:focus {
    top: 8px;
    outline: 2px solid var(--text-light);
    outline-offset: 2px;
}

/* Error page (rendered inside the global layout, so it uses shared tokens and .btn classes) */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: var(--spacing-xl);
}
.error-container {
    text-align: center;
    max-width: 500px;
}
.error-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-lg);
}
.error-container h1 {
    font-size: 1.75rem;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
}
.error-container p {
    color: var(--text-muted);
    margin-bottom: var(--spacing-xl);
    line-height: 1.6;
}
.error-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

.icon {
    display: inline-block;
    vertical-align: -0.125em;
    flex-shrink: 0;
}

/* =========================================================
   TOUCH TARGET MINIMUM (44px)
   Lives here, not in a page stylesheet, so every page gets it: these controls
   appear on login, signup, tenant settings, and every manager table, and a
   14px icon in 4px of padding is a 22px target on a phone.
   ========================================================= */
@media (pointer: coarse) {
    .btn-small,
    .btn-link,
    .btn-icon,
    .filter-select,
    .modal-close,
    .password-toggle-btn {
        min-height: 44px;
    }

    .btn-small,
    .btn-icon,
    .modal-close,
    .password-toggle-btn {
        min-width: 44px;
    }

    .btn-link {
        padding: 10px 8px;
    }

    .btn-icon {
        padding: 10px;
    }

    /* Grow the hit area, never the artwork: the eye icon stays 14px. */
    .password-toggle-btn {
        padding: 4px 12px;
    }
}

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

.icon-spin {
    animation: icon-spin 0.75s linear infinite;
}

/* A checkbox or a radio is a control, not a field: the blanket rule above stretches
   every input to the full row, which in Chrome centers the box and pushes its label
   onto the next line. */
.form-group input[type='checkbox'],
.form-group input[type='radio'] {
    width: 16px;
    height: 16px;
    padding: 0;
    accent-color: var(--primary-color);
}

/* ==========================================
   ROW ACTION MENUS
   One "..." per row instead of a strip of glyphs. See public/js/utils/row-menu.js.
   ========================================== */
.row-menu {
    position: relative;
    display: inline-block;
}

/* The actions cell that holds one, on every list in the product. */
.cell-actions {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
}

.row-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0 0 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.row-menu-trigger:hover,
.row-menu.is-open .row-menu-trigger {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: var(--text-dark);
}

.row-menu-trigger:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

/* Fixed, and placed by row-menu.js: a table that scrolls sideways would otherwise
   clip the menu out of sight. */
.row-menu-items {
    position: fixed;
    z-index: 1200;
    min-width: 172px;
    padding: 6px;
    border: 1px solid #e8e5e0;
    border-radius: 10px;
    background: var(--white);
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
}

.row-menu-items[hidden] {
    display: none;
}

.row-menu-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: #374151;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.row-menu-item:hover:not(:disabled) {
    background: #f6f2e9;
    color: var(--primary-color);
}

.row-menu-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.row-menu-item.is-danger {
    color: #b91c1c;
}

.row-menu-item.is-danger:hover:not(:disabled) {
    background: #fef2f2;
    color: #991b1b;
}

.row-menu-item:disabled {
    color: #b6bcc5;
    cursor: not-allowed;
}

.receipt-flag {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
}

/* Named inline controls, for a single action that does not warrant a menu. */
.btn-inline,
.btn-inline-danger {
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    background: var(--white);
    color: #374151;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-inline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f6f2e9;
}

.btn-inline-danger {
    color: #b91c1c;
}

.btn-inline-danger:hover {
    border-color: #fecaca;
    background: #fef2f2;
}

.btn-tiny {
    padding: 4px 9px;
    font-size: 12px;
    line-height: 1.2;
}

/* A form-heavy modal (create lease, add unit, add tenant). It used to be defined
   only in dashboard.css and service-requests.css, so on every other page the class
   did nothing and the modal fell back to the base width. */
.modal-content.modal-large {
    max-width: 1040px;
    width: min(94vw, 1040px);
}

/* Create Lease modal. Matches the edit/renew lease modal design language, but
   the partial ships with the global layout on tenant and unit pages, so it is
   styled here rather than in lease-details.css. */
#createLeaseModal .modal-header {
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 2;
}

#createLeaseModal .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--white);
    z-index: 2;
    margin: var(--spacing-lg) calc(-1 * var(--spacing-lg)) calc(-1 * var(--spacing-lg));
}

#createLeaseModal .form-section {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
}

#createLeaseModal .form-section:has(+ .modal-footer) {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

#createLeaseModal .form-section h3 {
    display: inline-block;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 var(--spacing-lg) 0;
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-color);
}

#createLeaseModal .form-row {
    gap: var(--spacing-lg);
}

#createLeaseModal .form-group {
    margin-bottom: var(--spacing-md);
}

#createLeaseModal .form-help {
    font-size: 12px;
    margin-top: 4px;
}

#createLeaseModal .checkbox-label {
    font-weight: var(--font-weight-normal);
}

#createLeaseModal .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

#createLeaseModal .checkbox-label span {
    font-size: var(--font-size-sm);
    color: #374151;
}

#addUnitModal .form-section,
#editUnitModal .form-section {
    margin-bottom: var(--spacing-xl);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid #e5e7eb;
}

#addUnitModal .form-section:has(+ .modal-footer),
#editUnitModal .form-section:has(+ .modal-footer) {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

#addUnitModal .form-section h3,
#editUnitModal .form-section h3 {
    display: inline-block;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
    margin: 0 0 var(--spacing-lg) 0;
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-color);
}

#addUnitModal .form-section h3 .section-hint,
#editUnitModal .form-section h3 .section-hint {
    font-weight: var(--font-weight-normal);
}

#addUnitModal .amenities-grid,
#editUnitModal .amenities-grid {
    margin-bottom: var(--spacing-xs);
}

#addUnitModal .form-group,
#editUnitModal .form-group {
    margin-bottom: var(--spacing-md);
}

/* Section 8 block states, shared by the create modal here and the lease-details
   modals. Text carries the meaning as well as color. */
.section8-fields {
    margin-top: var(--spacing-md);
}

.section8-retry {
    margin-top: var(--spacing-sm);
}

.section8-sum {
    margin-top: var(--spacing-sm);
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 500;
    background: #f9fafb;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.section8-sum.is-ok {
    background: #ecfdf5;
    color: #047857;
    border-color: #86efac;
}

.section8-sum.is-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.signing-progress {
    margin: var(--spacing-md) 0 var(--spacing-lg);
    padding: var(--spacing-md);
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius-md);
    background: #f9fafb;
}

.signing-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.signing-progress-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #6b7280;
}

.signing-progress-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
}

.signing-progress-list {
    list-style: none;
    margin: 0 0 var(--spacing-sm);
    padding: 0;
}

.signing-progress-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 8px 0;
    border-bottom: 1px solid #eceef1;
}

.signing-progress-item:last-child {
    border-bottom: none;
}

.signing-progress-who {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
    color: var(--text-dark);
    min-width: 0;
}

.signing-progress-role {
    font-size: 12px;
    color: #6b7280;
}

.signing-progress-next {
    margin: 0 0 var(--spacing-sm);
    font-size: 13px;
    color: #4b5563;
}

@media (max-width: 640px) {
    .signing-progress-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
