/* ==========================================================================
   Rent Manager - Design System
   Style: Modern SaaS (Stripe/Vercel inspired)
   ========================================================================== */

/* ========================================================================
   CSS CUSTOM PROPERTIES
   ======================================================================== */

:root {
    color-scheme: light;

    /* Pico CSS compatibility aliases */
    --pico-border-radius: 12px;
    --pico-card-background-color: #ffffff;
    --pico-card-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --pico-card-sectioning-background-color: #fafbfc;
    --pico-muted-border-color: #e5e7eb;
    --pico-muted-color: #9ca3af;
    --pico-color: #111827;
    --pico-primary: #4f46e5;
    --pico-primary-background: #4f46e5;
    --pico-secondary-background: #fafbfc;
    --pico-secondary-hover-background: #e5e7eb;
    --pico-code-background-color: #fafbfc;
    --pico-ins-color: #10b981;
    --pico-del-color: #ef4444;
    --pico-form-element-disabled-background-color: #fafbfc;

    /* Typography */
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Font sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Z-index scale */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-tooltip: 1060;

    /* Container */
    --container-max: 1200px;
    --container-padding: 1.5rem;

    /* Sidebar */
    --sidebar-width: 208px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --sidebar-section-label: rgba(17, 24, 39, 0.3);
    --sidebar-link: rgba(17, 24, 39, 0.7);
    --sidebar-link-hover-bg: rgba(250, 251, 252, 0.5);
    --sidebar-link-hover-text: #111827;
    --sidebar-link-active-bg: rgba(79, 70, 229, 0.1);
    --sidebar-link-active-text: #4f46e5;

    /* ===== LIGHT THEME (default) ===== */

    /* Accent */
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-light: #ccfbf1;
    --accent-text: #115e59;

    /* Primary - indigo */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-active: #3730a3;
    --primary-light: rgba(79, 70, 229, 0.1);
    --primary-text: #4f46e5;

    /* Page */
    --bg-page: #fafbfc;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-card-section: #fafbfc;
    --bg-subtle: #f3f4f6;
    --bg-muted: #e5e7eb;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-lighter: #9ca3af;
    --text-link: #4f46e5;
    --text-link-hover: #4338ca;

    /* Borders */
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --border-strong: #9ca3af;

    /* Status colors */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --success-text: #059669;
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --warning-text: #d97706;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --danger-text: #dc2626;
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);
    --info-text: #2563eb;

    /* Dropdown */
    --dropdown-bg: #ffffff;
    --dropdown-text: #374151;
    --dropdown-hover: #f3f4f6;
    --dropdown-border: #e5e7eb;
    --dropdown-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Table */
    --table-stripe: rgba(0, 0, 0, 0.015);
    --table-hover: rgba(0, 0, 0, 0.03);
    --table-border: #e5e7eb;
    --table-header-bg: rgba(0, 0, 0, 0.02);

    /* Form */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-border-focus: #4f46e5;
    --input-text: #111827;
    --input-placeholder: #9ca3af;
    --input-disabled-bg: #f3f4f6;

    /* Focus ring */
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.2);
    --focus-ring-color: #4f46e5;

    /* Money */
    --money-income: #10b981;
    --money-expense: #ef4444;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    color-scheme: dark;

    /* Pico CSS compatibility aliases (dark) */
    --pico-card-background-color: #1e293b;
    --pico-card-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --pico-card-sectioning-background-color: #162032;
    --pico-muted-border-color: #334155;
    --pico-muted-color: #64748b;
    --pico-color: #f1f5f9;
    --pico-primary: #818cf8;
    --pico-primary-background: #4f46e5;
    --pico-secondary-background: #162032;
    --pico-secondary-hover-background: #334155;
    --pico-code-background-color: #162032;
    --pico-ins-color: #34d399;
    --pico-del-color: #f87171;
    --pico-form-element-disabled-background-color: #1e293b;

    --sidebar-bg: #0f172a;
    --sidebar-border: #1e293b;
    --sidebar-section-label: rgba(241, 245, 249, 0.25);
    --sidebar-link: rgba(241, 245, 249, 0.6);
    --sidebar-link-hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-link-hover-text: #f1f5f9;
    --sidebar-link-active-bg: rgba(129, 140, 248, 0.15);
    --sidebar-link-active-text: #818cf8;

    --accent: #2dd4bf;
    --accent-hover: #14b8a6;
    --accent-light: rgba(45, 212, 191, 0.15);
    --accent-text: #2dd4bf;

    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-active: #4f46e5;
    --primary-light: rgba(129, 140, 248, 0.15);
    --primary-text: #a5b4fc;

    --bg-page: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #243347;
    --bg-card-section: #162032;
    --bg-subtle: #162032;
    --bg-muted: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-lighter: #475569;
    --text-link: #818cf8;
    --text-link-hover: #a5b4fc;

    --border: #334155;
    --border-hover: #475569;
    --border-strong: #64748b;

    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --danger-text: #fca5a5;
    --info: #60a5fa;
    --info-light: rgba(96, 165, 250, 0.15);
    --info-text: #93c5fd;

    --dropdown-bg: #1e293b;
    --dropdown-text: #e2e8f0;
    --dropdown-hover: #334155;
    --dropdown-border: #334155;
    --dropdown-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);

    --table-stripe: rgba(255, 255, 255, 0.02);
    --table-hover: rgba(255, 255, 255, 0.05);
    --table-border: #334155;
    --table-header-bg: rgba(255, 255, 255, 0.03);

    --input-bg: #162032;
    --input-border: #475569;
    --input-border-focus: #818cf8;
    --input-text: #f1f5f9;
    --input-placeholder: #64748b;
    --input-disabled-bg: #1e293b;

    --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.3);
    --focus-ring-color: #818cf8;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);

    --money-income: #34d399;
    --money-expense: #f87171;
}


/* ========================================================================
   RESET & BASE
   ======================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-page);
    min-height: 100vh;
}

/* Page load animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

main {
    animation: fadeInUp 0.3s ease-out;
}


/* ========================================================================
   TYPOGRAPHY
   ======================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.05em; }

p {
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

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

a:hover {
    color: var(--text-link-hover);
    text-decoration: underline;
}

strong, b { font-weight: 600; }
small { font-size: var(--text-sm); }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-6) 0;
}


/* ========================================================================
   LAYOUT
   ======================================================================== */

.container {
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--container-padding);
    padding-right: var(--container-padding);
}

article {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: none;
}

article > header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

article > header h3 {
    margin-bottom: 0;
}

article > header small {
    color: var(--text-muted);
}


/* ========================================================================
   SIDEBAR NAVIGATION
   ======================================================================== */

/* App layout: sidebar + main */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Desktop sidebar */
.app-sidebar {
    display: none;
    flex-direction: column;
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: var(--z-fixed);
    overflow: hidden;
}

@media (min-width: 1024px) {
    .app-sidebar { display: flex; }
}

/* Sidebar logo */
.sidebar-logo {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo a {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo a:hover {
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    width: 16px;
    height: 16px;
    color: #ffffff;
}

.sidebar-logo-text {
    font-weight: 700;
    font-size: var(--text-base);
    color: var(--text-primary);
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    padding: 20px 8px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 4px;
}

.sidebar-section-label {
    display: block;
    padding: 0 10px;
    margin-top: 16px;
    margin-bottom: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-section-label);
}

.sidebar-section:first-child .sidebar-section-label {
    margin-top: 0;
}

.sidebar-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    font-size: var(--text-sm);
    font-weight: 400;
    border-radius: 6px;
    transition: all var(--transition-fast);
    color: var(--sidebar-link) !important;
    text-decoration: none !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    background: var(--sidebar-link-hover-bg);
    color: var(--sidebar-link-hover-text) !important;
    text-decoration: none !important;
}

.sidebar-link.active {
    background: var(--sidebar-link-active-bg);
    color: var(--sidebar-link-active-text) !important;
    font-weight: 500;
}

.sidebar-link svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg {
    opacity: 1;
}

/* Sidebar footer (user section) */
.sidebar-footer {
    padding: 8px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    transition: background var(--transition-fast);
    color: var(--text-primary);
}

.sidebar-user:hover {
    background: var(--bg-subtle);
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--bg-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-avatar span {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 10px;
    color: var(--text-muted);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    width: 100%;
    border-radius: 6px;
    font-size: var(--text-sm);
    color: var(--danger) !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.sidebar-logout:hover {
    background: var(--danger-light) !important;
    color: var(--danger) !important;
}

.sidebar-logout svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Theme toggle in sidebar */
.sidebar-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 10px;
    width: 100%;
    border-radius: 6px;
    font-size: var(--text-sm);
    color: var(--text-muted) !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.sidebar-theme-toggle:hover {
    background: var(--bg-subtle) !important;
    color: var(--text-primary) !important;
}

.sidebar-theme-toggle svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Mobile top bar */
.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: 44px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(8px);
    background: rgba(var(--bg-card), 0.95);
}

@media (max-width: 1023px) {
    .mobile-topbar { display: flex; }
}

.mobile-topbar-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none !important;
    background: none !important;
    cursor: pointer;
    color: var(--text-primary) !important;
    transition: background var(--transition-fast);
    padding: 0 !important;
}

.mobile-menu-btn:hover {
    background: var(--bg-subtle) !important;
}

.mobile-menu-btn svg {
    width: 16px;
    height: 16px;
}

/* Mobile drawer sidebar */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.mobile-drawer-overlay.open {
    display: block;
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-drawer.open {
    transform: translateX(0);
}

.mobile-drawer-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none !important;
    background: none !important;
    cursor: pointer;
    color: var(--text-primary) !important;
    transition: background var(--transition-fast);
    padding: 0 !important;
}

.mobile-drawer-close:hover {
    background: var(--bg-subtle) !important;
}

.mobile-drawer-close svg {
    width: 16px;
    height: 16px;
}

/* Main content area */
.app-main {
    flex: 1;
    min-width: 0;
}

@media (min-width: 1024px) {
    .app-main {
        padding-left: var(--sidebar-width);
    }
}

.app-content {
    padding: 16px;
    max-width: var(--container-max);
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .app-content {
        padding: 20px;
    }
}

/* Logo (legacy) */
.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    height: 32px;
    border-radius: var(--radius-sm);
}

/* Legacy header (hidden when sidebar is used) */
header.app-header {
    display: none;
}


/* ========================================================================
   SKIP LINK
   ======================================================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: 10000;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
    font-weight: 600;
    font-family: var(--font-heading);
    transition: top var(--transition-slow);
}

.skip-link:focus,
.skip-link:focus-visible {
    top: 0;
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}


/* ========================================================================
   CARDS
   ======================================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    box-shadow: none;
}


/* ========================================================================
   BUTTONS
   ======================================================================== */

button, [role="button"], input[type="submit"], input[type="button"] {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: var(--text-sm);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}

button:focus-visible,
[role="button"]:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}

/* Primary button */
button:not([class*="btn-"]):not(.theme-toggle):not(.burger-icon):not(.modal-close):not([class*="filter"]),
input[type="submit"]:not([class*="btn-"]) {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

button:not([class*="btn-"]):not(.theme-toggle):not(.burger-icon):not(.modal-close):not([class*="filter"]):hover,
input[type="submit"]:not([class*="btn-"]):hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-primary {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    background: var(--primary-active) !important;
    border-color: var(--primary-active) !important;
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-subtle) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}

.btn-secondary:hover {
    background: var(--bg-muted) !important;
    border-color: var(--border-hover) !important;
    color: var(--text-primary) !important;
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-danger {
    background: var(--danger) !important;
    color: #ffffff !important;
    border-color: var(--danger) !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
}

.btn-danger:active {
    background: #991b1b !important;
    border-color: #991b1b !important;
    transform: scale(0.98);
}

.btn-success {
    background: var(--success) !important;
    color: #ffffff !important;
    border-color: var(--success) !important;
}

.btn-success:hover {
    background: #15803d !important;
    border-color: #15803d !important;
}

.btn-success:active {
    background: #166534 !important;
    border-color: #166534 !important;
    transform: scale(0.98);
}

.btn-warning {
    background: var(--warning) !important;
    color: #ffffff !important;
    border-color: var(--warning) !important;
}

.btn-warning:hover {
    background: #b45309 !important;
    border-color: #b45309 !important;
}

.btn-muted {
    background: #64748b !important;
    color: #ffffff !important;
    border-color: #64748b !important;
}

.btn-muted:hover {
    background: #475569 !important;
    border-color: #475569 !important;
}

.btn-elba {
    background: #7c3aed !important;
    color: #ffffff !important;
    border-color: #7c3aed !important;
    padding: 6px 14px;
}

.btn-elba:hover {
    background: #6d28d9 !important;
    border-color: #6d28d9 !important;
}

/* Size variants */
.btn-sm {
    padding: 6px 14px;
    font-size: var(--text-xs);
}

.btn-xs {
    padding: 3px 8px;
    font-size: 0.7rem;
}

/* Link styled as button */
a[role="button"] {
    text-decoration: none !important;
}

a[role="button"].secondary {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border-color: var(--border);
}

a[role="button"].secondary:hover {
    background: var(--bg-muted);
    border-color: var(--border-hover);
}

a[role="button"]:active {
    transform: scale(0.98);
}


/* ========================================================================
   FORMS
   ======================================================================== */

label {
    display: block;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
textarea,
select {
    font-family: var(--font-body);
    font-size: var(--text-base);
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--input-text);
    width: 100%;
    margin-bottom: var(--space-4);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--input-border-focus);
    box-shadow: var(--focus-ring);
}

input:disabled,
textarea:disabled,
select:disabled {
    background: var(--input-disabled-bg);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Select arrow */
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 36px;
}

/* Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}

/* Small text under inputs */
small {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: -0.75rem;
    margin-bottom: var(--space-4);
}

/* Form group */
.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    margin-bottom: var(--space-1);
}

/* Form grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

/* Inline forms */
.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-inline input,
.form-inline select,
.form-inline button,
.form-inline label,
.form-inline .form-group,
.form-inline a[role="button"] {
    margin-bottom: 0;
}

/* Delete forms */
.delete-form {
    display: inline;
}

/* Inline forms - with aligned inputs */
.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.inline-form input {
    margin-bottom: 0;
}

/* Small input */
.input-sm {
    padding: 6px 10px;
    font-size: var(--text-sm);
    height: auto;
}

/* OTP input */
.otp-input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-family: var(--font-mono);
}

/* Filter inputs */
.filter-row input,
.filter-row select {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    margin-bottom: 4px;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Permissions grid */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    border: 1px solid transparent;
}

.checkbox-label:hover {
    background: var(--dropdown-hover);
    border-color: var(--border);
}

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

/* Office checkboxes grid (legacy simple view) */
#offices-list:not(.office-grid) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
}

.office-row {
    margin: 0;
}

.office-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    border: 1px solid transparent;
    font-size: var(--text-sm);
}

.office-checkbox:hover {
    background: var(--dropdown-hover);
    border-color: var(--border);
}

.office-checkbox input[type="checkbox"] {
    margin: 0;
}

.office-checkbox:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-text);
}

/* Card forms */
.card-form {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.card-form-narrow {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.card-form-wide {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* OCR upload */
.ocr-upload {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border);
    text-align: center;
    transition: border-color var(--transition-fast);
}

.ocr-upload:hover {
    border-color: var(--primary);
}


/* ========================================================================
   TABLES
   ======================================================================== */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--table-header-bg);
    padding: 12px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--table-hover);
}

tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

tbody tr:nth-child(even):hover {
    background-color: var(--table-hover);
}

/* Table footer (totals) */
tfoot td {
    font-weight: 600;
    border-top: 2px solid var(--border);
    border-bottom: none;
    background: var(--table-header-bg);
    color: var(--text-primary);
    font-family: var(--font-heading);
}

/* Table links */
table a {
    font-weight: 500;
}

table a:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Table action buttons */
td a[role="button"],
td button,
td form {
    display: inline-block;
    width: auto;
    margin: 0 2px 0 0;
    vertical-align: middle;
}

td form {
    margin: 0;
}

/* Column widths */
.col-checkbox { width: 40px; }
.col-actions { width: 100px; text-align: right; }
.col-date { width: 100px; }
.col-narrow { width: 70px; }
.col-xml { width: 50px; }

@media (max-width: 768px) {
    table {
        font-size: var(--text-xs);
    }

    th, td {
        padding: 8px 10px;
    }
}


/* ========================================================================
   BADGES
   ======================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

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

.badge-secondary {
    background: var(--bg-subtle);
    color: var(--text-secondary);
}

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

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

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

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

.badge-muted {
    background: #64748b;
    color: white;
}


/* ========================================================================
   ALERTS
   ======================================================================== */

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    border-left: 4px solid transparent;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger-text);
    border-left-color: var(--danger);
}

.alert-success {
    background: var(--success-light);
    color: var(--success-text);
    border-left-color: var(--success);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-text);
    border-left-color: var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-text);
    border-left-color: var(--info);
}

/* Pico-compatible role="alert" */
[role="alert"] {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    border-left: 4px solid var(--danger);
    background: var(--danger-light);
    color: var(--danger-text);
}


/* ========================================================================
   PAGINATION
   ======================================================================== */

.pagination {
    display: flex;
    gap: 8px;
    margin-top: var(--space-5);
    justify-content: center;
    align-items: center;
}

.pagination-info {
    padding: 6px 14px;
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-family: var(--font-heading);
}

.pagination a:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}


/* ========================================================================
   PAGE HEADER
   ======================================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.page-header h2 {
    margin-bottom: 0;
}

.page-header a[role="button"],
.page-header button {
    margin-bottom: 0;
    width: auto;
}


/* ========================================================================
   SECTION HEADER
   ======================================================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2,
.section-header h3 {
    margin: 0;
}

.section-header a[role="button"],
.section-header button {
    margin-bottom: 0;
}

.section-divider {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}


/* ========================================================================
   FILTER TABS
   ======================================================================== */

.filter-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.filter-tab {
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 500;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.filter-tab:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
    text-decoration: none;
}

.filter-tab.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.filter-tab:active {
    transform: scale(0.97);
}

.filter-tab.active:active {
    background: var(--primary-hover);
}

.filter-tab:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4em;
    padding: 0 0.4em;
    font-size: 0.8em;
    font-weight: 600;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.1);
    margin-left: 0.25rem;
}

.filter-tab.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
}

.filter-tab-draft.active {
    background: var(--badge-secondary-bg, #6b7280);
    color: var(--badge-secondary-text, white);
}

.filter-tab-signed.active {
    background: var(--primary);
    color: white;
}

.filter-tab-sent.active {
    background: #f59e0b;
    color: white;
}

.filter-tab-paid.active {
    background: #22c55e;
    color: white;
}

.filter-tab-overdue.active {
    background: #ef4444;
    color: white;
}

.filter-tab-cancelled.active {
    background: #6b7280;
    color: white;
}


/* ========================================================================
   DETAIL ROWS
   ======================================================================== */

.detail-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}

.detail-label {
    width: 160px;
    flex-shrink: 0;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.detail-value {
    flex: 1;
    color: var(--text-primary);
}


/* ========================================================================
   EMPTY STATE
   ======================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-8);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3.5rem;
    line-height: 1;
    margin-bottom: var(--space-6);
    display: block;
    opacity: 0.5;
}

.empty-state-title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-3) 0;
}

.empty-state-description {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin: 0 0 var(--space-6) 0;
    line-height: 1.5;
}

.empty-state-action {
    margin-top: var(--space-6);
    display: inline-block;
}

@media (max-width: 768px) {
    .empty-state {
        padding: var(--space-8) var(--space-4);
    }

    .empty-state-icon {
        font-size: 2.5rem;
        margin-bottom: var(--space-4);
    }

    .empty-state-title {
        font-size: var(--text-base);
    }
}


/* ========================================================================
   ACTIONS
   ======================================================================== */

.actions {
    display: flex;
    gap: 10px;
    margin-top: var(--space-5);
    align-items: center;
}

/* Push danger actions (delete) to the right */
.actions .delete-form,
.actions .btn-danger {
    margin-left: auto;
}

.actions button,
.actions a[role="button"],
.actions form {
    margin-bottom: 0;
}

.actions-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions-inline a[role="button"],
.actions-inline button,
.actions-inline form {
    margin: 0;
    width: auto;
}


/* ========================================================================
   BULK ACTIONS
   ======================================================================== */

.bulk-actions {
    display: none;
    align-items: center;
    gap: var(--space-4);
    padding: 12px var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.bulk-actions.show {
    display: flex;
}

.bulk-actions span {
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-heading);
}

.bulk-actions button,
.bulk-actions a[role="button"] {
    margin: 0;
}


/* ========================================================================
   INFO BOXES
   ======================================================================== */

.info-box {
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}

.info-box-muted {
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.info-box-blue {
    padding: 20px;
    background: var(--info-light);
    border-radius: var(--radius-md);
    border: 1px solid var(--primary-light);
}

.info-box-sync {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}


/* ========================================================================
   MODALS
   ======================================================================== */

/* Native <dialog> element styles */
dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: min(600px, 90vw);
    width: 100%;
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    background: var(--bg-card);
    animation: dialogFadeIn 0.2s ease-out;
    overflow: hidden;
}

@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: backdropFadeIn 0.2s ease-out;
}

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

dialog > article {
    margin-bottom: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

dialog > article > header {
    position: relative;
}

dialog .modal-close {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border: none !important;
    background: none !important;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted) !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0;
    line-height: 1;
    border-radius: var(--radius-pill);
    transition: all var(--transition-fast);
    box-shadow: none !important;
    outline: none;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

dialog .modal-close:hover {
    color: var(--text-primary) !important;
    background: var(--bg-muted) !important;
}

dialog .modal-close:active {
    transform: translateY(-50%) scale(0.92);
}

dialog .modal-close:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}

.modal,
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
}

.modal-content {
    background: var(--bg-card);
    max-width: 420px;
    margin: 100px auto;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    position: relative;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
}

.modal-close {
    position: absolute;
    right: 12px;
    top: 12px;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    width: auto;
    padding: 4px;
    margin: 0;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-subtle);
}


/* ========================================================================
   ANALYTICS
   ======================================================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.premises-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

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


/* ========================================================================
   MONEY FORMATTING
   ======================================================================== */

.money {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.money-income {
    color: var(--money-income);
}

.money-expense {
    color: var(--money-expense);
}


/* ========================================================================
   CODE
   ======================================================================== */

.code-block {
    background: var(--bg-subtle);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: var(--text-sm);
    border: 1px solid var(--border);
}

code {
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875em;
}


/* ========================================================================
   FOOTER
   ======================================================================== */

footer.app-footer {
    margin-top: var(--space-10);
    padding: var(--space-5) 20px;
    text-align: center;
    color: var(--text-lighter);
    font-size: var(--text-xs);
}

footer.app-footer .version {
    font-family: var(--font-mono);
    color: var(--text-lighter);
}


/* ========================================================================
   LOADING STATES
   ======================================================================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

button.loading,
a[role="button"].loading,
input[type="submit"].loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed;
}

button.loading::before,
a[role="button"].loading::before,
input[type="submit"].loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

button.loading.btn-sm::before,
a[role="button"].loading.btn-sm::before,
input[type="submit"].loading.btn-sm::before {
    width: 12px;
    height: 12px;
    margin-right: 6px;
}

form.loading input:not([type="submit"]),
form.loading select,
form.loading textarea {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
    background-color: var(--input-disabled-bg);
}


/* ========================================================================
   NEW YEAR DECORATIONS
   ======================================================================== */

.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
    display: none;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: #fff;
    font-size: 1rem;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    animation: snowfall linear infinite;
    opacity: 0.8;
}

@keyframes snowfall {
    0% { transform: translateY(-20px) rotate(0deg); }
    100% { transform: translateY(100vh) rotate(360deg); }
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 8s; animation-delay: 0s; font-size: 0.8rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 12s; animation-delay: 1s; font-size: 1.2rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 2s; font-size: 0.9rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 0.5s; font-size: 1rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 9s; animation-delay: 3s; font-size: 1.1rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 11s; animation-delay: 1.5s; font-size: 0.7rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 13s; animation-delay: 2.5s; font-size: 1.3rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 8s; animation-delay: 4s; font-size: 0.85rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 10s; animation-delay: 0.8s; font-size: 1rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 15s; animation-delay: 2s; font-size: 0.95rem; }

/* Garland */
.garland {
    position: relative;
    height: 20px;
    background: linear-gradient(to bottom, #1e293b 0%, transparent 100%);
    overflow: hidden;
    display: none;
    justify-content: space-around;
    align-items: flex-start;
    padding: 0 20px;
}

.garland-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: relative;
    top: -2px;
    animation: glow 1.5s ease-in-out infinite;
}

.garland-light::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 6px;
    background: #333;
}

.garland-light:nth-child(5n+1) { background: #ff4444; box-shadow: 0 0 10px #ff4444, 0 0 20px #ff4444; animation-delay: 0s; }
.garland-light:nth-child(5n+2) { background: #44ff44; box-shadow: 0 0 10px #44ff44, 0 0 20px #44ff44; animation-delay: 0.3s; }
.garland-light:nth-child(5n+3) { background: #4444ff; box-shadow: 0 0 10px #4444ff, 0 0 20px #4444ff; animation-delay: 0.6s; }
.garland-light:nth-child(5n+4) { background: #ffff44; box-shadow: 0 0 10px #ffff44, 0 0 20px #ffff44; animation-delay: 0.9s; }
.garland-light:nth-child(5n+5) { background: #ff44ff; box-shadow: 0 0 10px #ff44ff, 0 0 20px #ff44ff; animation-delay: 1.2s; }

@keyframes glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.garland::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg, #333 0px, #333 30px, transparent 30px, transparent 32px);
    z-index: -1;
}


/* ========================================================================
   DASHBOARD
   ======================================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-6);
}

.dashboard-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-6) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none !important;
    color: inherit;
    transition: all var(--transition-base);
    box-shadow: none;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
    color: inherit;
    text-decoration: none !important;
}

.dashboard-card-icon {
    font-size: 2rem;
    margin-bottom: var(--space-2);
    line-height: 1;
}

.dashboard-card-title {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
    text-align: center;
}

.dashboard-card-value {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.dashboard-card-subtitle {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}


/* ========================================================================
   PREMISE CARDS (Dashboard analytics)
   ======================================================================== */

.premise-card {
    display: block;
    padding: var(--space-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none !important;
    color: inherit;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-xs);
}

.premise-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
    color: inherit;
    text-decoration: none !important;
}

.premise-card h4 {
    margin: 0 0 var(--space-2) 0;
    font-size: var(--text-lg);
    color: var(--text-primary);
}

.premise-card .address {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.premise-card .area {
    margin: var(--space-2) 0 0 0;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-row .label {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.stat-row .value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: 600;
}

.stat-row .value.income { color: var(--money-income); }
.stat-row .value.expense { color: var(--money-expense); }
.stat-row .value.net-positive { color: var(--primary); }
.stat-row .value.net-negative { color: var(--money-expense); }


/* ========================================================================
   LOGIN PAGE
   ======================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(13, 148, 136, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(17, 24, 39, 0.03) 0%, transparent 50%);
}

[data-theme="dark"] .login-page {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(129, 140, 248, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(45, 212, 191, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(15, 23, 42, 0.3) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}

.login-card h2 {
    text-align: center;
    margin-bottom: var(--space-6);
    font-size: var(--text-2xl);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-6);
}

.login-logo img {
    height: 48px;
    border-radius: var(--radius-md);
}

.login-logo .sidebar-logo-icon {
    margin: 0 auto;
}


/* ========================================================================
   UTILITY CLASSES - TEXT
   ======================================================================== */

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.whitespace-nowrap { white-space: nowrap; }
.no-text-decoration { text-decoration: none; }

/* Text colors */
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-success-light { color: var(--success); }
.text-warning { color: var(--warning); }
.text-warning-light { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-danger-light { color: var(--danger); }
.text-info { color: var(--info); }
.text-gray-500 { color: var(--text-muted); }
.text-gray-600 { color: var(--text-secondary); }
.text-gray-700 { color: var(--text-primary); }
.text-custom-muted { color: var(--text-muted); }
.text-lighter { color: var(--text-lighter); }
.text-primary-link { color: var(--primary); font-weight: 500; }
.text-primary-dark { color: var(--primary-hover); }
.text-orange { color: #ea580c; }


/* ========================================================================
   UTILITY CLASSES - BACKGROUNDS
   ======================================================================== */

.bg-gray-light { background: var(--bg-subtle); }
.bg-gray-lighter { background: var(--bg-muted); }
.bg-blue-light { background: var(--info-light); }
.bg-green-light { background: var(--success-light); }
.bg-success { background: var(--success); }
.bg-success-light { background: var(--success); }
.bg-warning { background: var(--warning); }
.bg-warning-light { background: var(--warning); }
.bg-danger { background: var(--danger); }
.bg-primary { background: var(--primary); }
.bg-primary-light { background: var(--primary); }


/* ========================================================================
   UTILITY CLASSES - BORDERS
   ======================================================================== */

.border-light { border: 1px solid var(--border); }
.border-medium { border: 1px solid var(--border-hover); }
.border-blue { border: 1px solid var(--primary); }
.border-success { border: 1px solid var(--success); }
.border-warning { border: 1px solid var(--warning); }
.border-danger { border: 1px solid var(--danger); }
.rounded { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.border-left-none { border-left: none; }
.border-left-2 { border-left: 2px solid var(--border); }
.border-bottom-light { border-bottom: 2px solid var(--border); }
.border-bottom-none { border-bottom: none; }
.border-dashed { border: 2px dashed var(--border); }


/* ========================================================================
   UTILITY CLASSES - SPACING
   ======================================================================== */

.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-16 { margin-top: 1rem; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-40 { margin-top: 40px; }
.mt-48 { margin-top: 3rem; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-5 { margin-bottom: 5px; }
.mb-8 { margin-bottom: 0.5rem; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-15 { margin-bottom: 15px; }
.mb-16 { margin-bottom: 1rem; }
.mb-20 { margin-bottom: 20px; }
.mb-25 { margin-bottom: 25px; }
.mb-30 { margin-bottom: 30px; }
.mr-4 { margin-right: 4px; }
.ml-10 { margin-left: 10px; }
.ml-15 { margin-left: 15px; }
.ml-20 { margin-left: 20px; }
.ml-24 { margin-left: 24px; }

.p-10 { padding: 10px; }
.p-15 { padding: 15px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.p-40 { padding: 40px; }
.pt-16 { padding-top: 1rem; }
.pb-8 { padding-bottom: 8px; }
.pb-10 { padding-bottom: 10px; }
.pl-12 { padding-left: 12px; }


/* ========================================================================
   UTILITY CLASSES - LAYOUT
   ======================================================================== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-between { display: flex; justify-content: space-between; }
.flex-end { display: flex; justify-content: flex-end; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-start { align-items: flex-start; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.gap-4 { gap: 4px; }
.gap-5 { gap: 5px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }


/* ========================================================================
   UTILITY CLASSES - DIMENSIONS
   ======================================================================== */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-80 { width: 80px; }
.w-200 { width: 200px; }

.max-w-180 { max-width: 180px; }
.max-w-200 { max-width: 200px; }
.max-w-300 { max-width: 300px; }
.max-w-400 { max-width: 400px; }
.max-w-500 { max-width: 500px; }
.max-w-600 { max-width: 600px; }
.max-w-700 { max-width: 700px; }

.min-w-120 { min-width: 120px; }
.min-w-150 { min-width: 150px; }
.min-w-200 { min-width: 200px; }
.min-w-250 { min-width: 250px; }
.min-w-300 { min-width: 300px; }


/* ========================================================================
   UTILITY CLASSES - MISC
   ======================================================================== */

.position-relative { position: relative; }
.overflow-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.max-h-300 { max-height: 300px; }
.cursor-pointer { cursor: pointer; }
.inline-block { display: inline-block; }
.d-block { display: block; }
.white-space-pre-line { white-space: pre-line; }


/* ========================================================================
   UTILITY CLASSES - GRIDS
   ======================================================================== */

.grid { display: grid; }

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

.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-auto-fit-sm {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.grid-auto-fit-md {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-auto-fit-lg {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}


/* ========================================================================
   HISTORY TABLE (Contracts detail page)
   ======================================================================== */

.history-table { width: 100%; }
.history-table th, .history-table td { padding: 10px; }
.history-table .date-col { width: 120px; }
.history-table .service-col { width: 30%; }
.history-table .action-col { width: 120px; }

.history-badge {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    font-family: var(--font-heading);
}

.history-badge-initial { background: var(--info-light); color: var(--info-text); }
.history-badge-add { background: var(--success-light); color: var(--success-text); }
.history-badge-change { background: var(--warning-light); color: var(--warning-text); }
.history-badge-remove { background: var(--danger-light); color: var(--danger-text); }

.old-value { color: var(--text-muted); text-decoration: line-through; }
.arrow { color: var(--text-muted); margin: 0 5px; }


/* ========================================================================
   GENERAL FOCUS STYLES
   ======================================================================== */

main a:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
    border-radius: 2px;
}


/* ========================================================================
   CONTRACTS FILTER (inline styles replacement)
   ======================================================================== */

.contracts-filter {
    margin-bottom: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: flex-start;
    flex-wrap: wrap;
    border: 1px solid var(--border);
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-field {
    min-width: 180px;
    max-width: 250px;
}

.filter-field select {
    margin-bottom: 0;
    padding: 8px 12px;
    height: auto;
    font-size: var(--text-sm);
}


/* ========================================================================
   PAYMENT FILTER
   ======================================================================== */

.payment-filter {
    margin-bottom: var(--space-6);
    padding: var(--space-4);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.filter-dates {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-dates input[type="date"] {
    margin-bottom: 0;
}

.filter-date-field {
    min-width: 150px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-actions button,
.filter-actions a[role="button"] {
    margin-bottom: 0;
}

.quick-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-filters button {
    margin-bottom: 0;
}

/* ========================================================================
   CONTRACT FORM WIZARD
   ======================================================================== */

/* Stepper */
.wizard-stepper {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-8);
    padding: 0 var(--space-2);
}

.wizard-step-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
    white-space: nowrap;
}

.wizard-step-item:hover {
    background: var(--bg-subtle);
}

.wizard-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 600;
    background: var(--bg-muted);
    color: var(--text-muted);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.wizard-step-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition-base);
}

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

.wizard-step-item.active .wizard-step-label {
    color: var(--text-primary);
    font-weight: 600;
}

.wizard-step-item.completed .wizard-step-num {
    background: var(--success);
    color: #fff;
}

.wizard-step-item.completed .wizard-step-label {
    color: var(--text-secondary);
}

.wizard-step-connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 var(--space-2);
    min-width: 20px;
    transition: background var(--transition-base);
}

.wizard-step-connector.completed {
    background: var(--success);
}

/* Wizard panels */
.wizard-panel {
    display: none;
    animation: wizardFadeIn 0.25s ease;
}

.wizard-panel.active {
    display: block;
}

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

/* Wizard navigation */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.wizard-nav-left,
.wizard-nav-right {
    display: flex;
    gap: var(--space-3);
}

/* Office cards */
.office-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}

.office-card {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-card);
}

.office-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.office-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.office-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.office-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.office-card-number {
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-primary);
}

.office-card-check {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    background: var(--bg-card);
    flex-shrink: 0;
}

.office-card-check svg {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.office-card.selected .office-card-check {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.office-card.selected .office-card-check svg {
    opacity: 1;
}

.office-card-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.office-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.no-tariff-hint {
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
}

.office-card-tenant {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
}

.tenant-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-weight: 500;
}

.tenant-badge.occupied {
    background: var(--warning-light);
    color: var(--warning-text);
}

.tenant-badge.free {
    background: var(--success-light);
    color: var(--success-text);
}

/* Validation warnings */
.validation-hint {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-top: var(--space-3);
    background: var(--warning-light);
    color: var(--warning-text);
    border-left: 3px solid var(--warning);
}

.validation-hint.info {
    background: var(--info-light);
    color: var(--info-text);
    border-left-color: var(--info);
}

.validation-hint.success {
    background: var(--success-light);
    color: var(--success-text);
    border-left-color: var(--success);
}

/* ========================================================================
   RENT LEDGER
   ======================================================================== */

/* Year summary card */
.ledger-year-summary {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-5) var(--space-6);
    margin-bottom: var(--space-6);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-subtle) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.ledger-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ledger-summary-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-lighter);
    font-family: var(--font-heading);
    font-weight: 500;
}

.ledger-summary-value {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
}

.ledger-summary-divider {
    width: 1px;
    height: 40px;
    background: var(--border);
    flex-shrink: 0;
}

/* Month collapsible group */
.ledger-month {
    margin-bottom: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: margin-bottom var(--transition-fast), box-shadow var(--transition-fast);
}

.ledger-month[open] {
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.ledger-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-subtle);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color var(--transition-fast);
}

.ledger-month-header::-webkit-details-marker {
    display: none;
}

.ledger-month-header::marker {
    content: "";
}

.ledger-month-header:hover {
    background: var(--bg-muted);
}

.ledger-month-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Chevron indicator */
.ledger-month-title::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M6 4l4 4-4 4' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    transition: transform var(--transition-fast);
}

.ledger-month[open] .ledger-month-title::before {
    transform: rotate(90deg);
}

[data-theme="dark"] .ledger-month-title::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M6 4l4 4-4 4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.ledger-month-name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.ledger-month-year {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.ledger-month-count {
    font-size: var(--text-xs);
    color: var(--text-lighter);
    background: var(--bg-muted);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    transition: all var(--transition-fast);
}

.ledger-month[open] .ledger-month-count {
    background: var(--primary-light);
    color: var(--primary-text);
}

.ledger-month-totals {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.ledger-month-totals .money {
    font-size: var(--text-sm);
}

.ledger-month-body {
    padding: 0;
}

.ledger-month-body table {
    margin-bottom: 0;
}

.ledger-month-body thead th {
    position: sticky;
    top: 0;
    background: var(--table-header-bg);
    z-index: 2;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-lighter);
    font-weight: 600;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
}

.ledger-month-body th:first-child,
.ledger-month-body td:first-child {
    padding-left: var(--space-4);
}

.ledger-month-body th:last-child,
.ledger-month-body td:last-child {
    padding-right: var(--space-4);
}

.ledger-month-body tbody tr:nth-child(even) {
    background: var(--table-stripe);
}

.ledger-month-body tfoot td {
    border-top: 2px solid var(--border);
    background: var(--bg-subtle);
    font-size: var(--text-sm);
}

/* Partial days indicator */
.ledger-days {
    font-variant-numeric: tabular-nums;
}

.ledger-days--partial {
    color: var(--warning-text);
    background: var(--warning-light);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 500;
}

/* Editable rows */
.ledger-row-editable {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.ledger-row-editable:hover {
    background: var(--primary-light) !important;
}

.ledger-row-editable:active {
    background: var(--bg-muted) !important;
}

/* Manual amount indicator */
.ledger-manual {
    color: var(--warning-text);
    font-weight: 600;
}

.ledger-manual::after {
    content: "*";
    margin-left: 2px;
    font-size: var(--text-xs);
    vertical-align: super;
}

/* Money cells in ledger table */
.ledger-month-body td.money {
    font-variant-numeric: tabular-nums;
    font-family: var(--font-heading);
    font-weight: 500;
}

/* Edit form */
.ledger-edit-header {
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.ledger-edit-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
}

.ledger-edit-office {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--text-xl);
    color: var(--text-primary);
}

.ledger-edit-period {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.ledger-edit-tenant {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.ledger-edit-calculated {
    font-family: var(--font-mono);
    font-size: var(--text-base);
    color: var(--text-secondary);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
    font-weight: 500;
}

.ledger-edit-form .form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
}

.ledger-edit-form .form-actions-right {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.input-with-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.input-with-hint input {
    flex: 1;
}

.input-hint {
    font-size: var(--text-sm);
    color: var(--text-muted);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .ledger-year-summary {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-4);
        padding: var(--space-4);
    }

    .ledger-summary-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
    }

    .ledger-summary-divider {
        width: 100%;
        height: 1px;
    }

    .ledger-month-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .ledger-month-totals {
        margin-left: 24px;
    }

    .ledger-month-body {
        overflow-x: auto;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .wizard-stepper {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
    }

    .wizard-step-connector {
        display: none;
    }

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

