/* ============================================================
   DESIGN TOKENS — Policy 2.0 Compliant
   ============================================================ */
:root {
    /* Global palette */
    --primary-dark:      #1C2529;
    --primary-accent:    #A1D1B1;
    --color-brand:       var(--primary-dark);
    --color-brand-light: #EDF7F0;
    --color-brand-dark:  #101719;

    /* Surfaces (60% canvas, 30% secondary) */
    --color-canvas:        #F5F7F6;                 /* Light Background */
    --color-surface:       #FFFFFF;                 /* Card / Panel */
    --color-surface-muted: #F7FAF8;                 /* Card Header / Table Header */
    --color-overlay:       var(--primary-dark);     /* Shadowed Green */

    /* Text */
    --color-text-primary:   #1C2529;
    --color-text-secondary: #647174;
    --color-text-muted:     #647174;
    --color-text-inverse:   hsl(0, 0%, 100%);

    /* Borders (10% Contrast Rule Applied) */
    --color-border:        #E1E8E4;             /* Visible edge */
    --color-border-strong: #AABCB2;            /* Focused edge */

    /* Multi-layered Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.09), 0 4px 8px rgba(0, 0, 0, 0.05);

    /* Border Radius Scale (Nesting Rule) */
    --radius-xs:   4px;
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   18px;
    --radius-2xl:  24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 100ms ease;
    --transition-base: 180ms ease;
    --transition-slow: 320ms ease;

    /* Type Scale */
    --text-xs:   11px;
    --text-sm:   13px;
    --text-base: 15px;
    --text-md:   17px;
    --text-lg:   20px;
    --text-xl:   24px;
    --text-2xl:  30px;
    --text-3xl:  40px;

    /* Layout Components */
    --sidebar-width: 280px;
    --header-height: 72px;
}

[data-theme="dark"] {
    --primary-dark:      #0b1317;
    --primary-accent:    #10b981;
    --color-brand:       #34d399;
    --color-brand-light: rgba(52, 211, 153, 0.14);
    --color-brand-dark:  #059669;

    --color-canvas:        #0b121e;
    --color-surface:       #15202e;
    --color-surface-muted: #1c2a3d;
    --color-overlay:       #080d15;

    --color-text-primary:   #FFFFFF;
    --color-text-secondary: #cbd5e1;
    --color-text-muted:     #94a3b8;
    --color-text-inverse:   #FFFFFF;

    --color-border:        #243346;
    --color-border-strong: #384c66;
}

/* --- Semantic Stat Card Icon Classes (Dual-Theme Compatible) --- */
.stat-icon--primary {
    background: var(--color-brand-light);
    color: var(--primary-dark);
}
.stat-icon--success {
    background: #dcfce7;
    color: #15803d;
}
.stat-icon--danger {
    background: #fee2e2;
    color: #b91c1c;
}
.stat-icon--warning {
    background: #fef3c7;
    color: #b45309;
}
.stat-icon--info {
    background: #e0f2fe;
    color: #0369a1;
}

[data-theme="dark"] .stat-icon--primary {
    background: rgba(56, 189, 248, 0.16);
    color: #38bdf8;
}
[data-theme="dark"] .stat-icon--success {
    background: rgba(34, 197, 94, 0.16);
    color: #4ade80;
}
[data-theme="dark"] .stat-icon--danger {
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
}
[data-theme="dark"] .stat-icon--warning {
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
}
[data-theme="dark"] .stat-icon--info {
    background: rgba(14, 165, 233, 0.16);
    color: #38bdf8;
}

/* --- Dark Theme Overrides: All Primary & Headings are Pure White --- */
[data-theme="dark"] body,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] .page-title,
[data-theme="dark"] .panel__header h3,
[data-theme="dark"] .stat-value,
[data-theme="dark"] .user-name,
[data-theme="dark"] .sidebar-brand,
[data-theme="dark"] .sidebar-brand span,
[data-theme="dark"] .dash-map-name,
[data-theme="dark"] .data-table td,
[data-theme="dark"] .data-table td strong,
[data-theme="dark"] .data-table td a,
[data-theme="dark"] .field-label,
[data-theme="dark"] .user-modal-header h3,
[data-theme="dark"] .logout-modal-content h2,
[data-theme="dark"] .finance-section-heading h2,
[data-theme="dark"] .finance-table-heading h2,
[data-theme="dark"] strong,
[data-theme="dark"] b {
    color: #FFFFFF !important;
}

[data-theme="dark"] .sidebar {
    background-color: #080d15;
    border-right: 1px solid #1c2a3d;
}

[data-theme="dark"] .sidebar-brand {
    color: #FFFFFF !important;
    border-bottom: 1px solid #1c2a3d;
}

[data-theme="dark"] .sidebar-nav a {
    color: #cbd5e1;
}

[data-theme="dark"] .sidebar-nav a:hover,
[data-theme="dark"] .sidebar-subnav a:hover {
    color: #FFFFFF !important;
    background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .sidebar-nav > ul > li.active > a {
    background-color: rgba(16, 185, 129, 0.22) !important;
    color: #6ee7b7 !important;
    border: 1px solid rgba(52, 211, 153, 0.45) !important;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .sidebar-subnav a {
    color: #94a3b8;
}

[data-theme="dark"] .sidebar-subnav a.active {
    background-color: rgba(16, 185, 129, 0.22) !important;
    color: #6ee7b7 !important;
}

[data-theme="dark"] .sidebar-nav .logout-item a {
    color: #94a3b8;
}

[data-theme="dark"] .sidebar-nav .logout-item a:hover {
    background-color: rgba(239, 68, 68, 0.15);
    color: #fca5a5 !important;
}

[data-theme="dark"] .stat-label {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .stat-footer {
    color: #94a3b8 !important;
}

[data-theme="dark"] .data-table th {
    color: #cbd5e1 !important;
    background-color: var(--color-surface-muted) !important;
}

[data-theme="dark"] .u-muted,
[data-theme="dark"] small.u-muted {
    color: #94a3b8 !important;
}

[data-theme="dark"] .button--outline {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .button--outline:hover {
    background-color: rgba(52, 211, 153, 0.2);
    border-color: #34d399 !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .button--icon {
    background: var(--color-surface);
    color: #FFFFFF !important;
    border-color: var(--color-border);
}

[data-theme="dark"] .button--icon:hover {
    border-color: var(--color-brand);
    background: var(--color-brand-light);
    color: #34d399 !important;
}

[data-theme="dark"] .button--primary {
    background-color: #10b981 !important;
    color: #042013 !important;
    font-weight: 700;
}

[data-theme="dark"] .button--primary:hover {
    background-color: #34d399 !important;
    color: #042013 !important;
}

[data-theme="dark"] .status-tag {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .status-tag--available {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
    border-color: rgba(34, 197, 94, 0.45) !important;
}

[data-theme="dark"] .status-tag--reserved {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
    border-color: rgba(245, 158, 11, 0.45) !important;
}

[data-theme="dark"] .status-tag--sold {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
}

[data-theme="dark"] .status-tag--blocked {
    background-color: rgba(100, 116, 139, 0.2) !important;
    color: #e2e8f0 !important;
    border-color: rgba(100, 116, 139, 0.45) !important;
}

[data-theme="dark"] .status-tag--success {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #4ade80 !important;
    border-color: rgba(34, 197, 94, 0.45) !important;
}

[data-theme="dark"] .status-tag--warning {
    background-color: rgba(245, 158, 11, 0.2) !important;
    color: #fbbf24 !important;
    border-color: rgba(245, 158, 11, 0.45) !important;
}

[data-theme="dark"] .status-tag--danger {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
}

[data-theme="dark"] .monitoring-controls {
    background-color: var(--color-surface) !important;
    border-color: var(--color-border) !important;
}

[data-theme="dark"] .field-input,
[data-theme="dark"] .field-select,
[data-theme="dark"] .field-textarea {
    background-color: #0b121e !important;
    border-color: #243346 !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .field-input::placeholder,
[data-theme="dark"] .field-textarea::placeholder {
    color: #64748b !important;
}

[data-theme="dark"] .dash-map-item {
    background: #1c2a3d !important;
    border-color: #243346 !important;
}

[data-theme="dark"] .dash-map-item:hover {
    background: #23344b !important;
    border-color: #34d399 !important;
}

[data-theme="dark"] .dash-map-name {
    color: #FFFFFF !important;
}

[data-theme="dark"] .dash-map-sub {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .dash-map-time {
    color: #94a3b8 !important;
}

[data-theme="dark"] .dash-map-link {
    color: #FFFFFF !important;
}

[data-theme="dark"] .dash-map-link:hover {
    color: #FFFFFF !important;
    text-decoration: underline;
}

[data-theme="dark"] .dash-map-link--primary {
    color: #34d399 !important;
}

[data-theme="dark"] .dash-map-link--primary:hover {
    color: #6ee7b7 !important;
}

[data-theme="dark"] .user-info {
    background-color: #15202e !important;
    border-color: #243346 !important;
}

[data-theme="dark"] .user-modal-dialog {
    background: #15202e !important;
    border-color: #243346 !important;
}

[data-theme="dark"] .app-toast {
    background: #15202e !important;
    border-color: #243346 !important;
    color: #FFFFFF !important;
}

[data-theme="dark"] .app-toast-message {
    color: #FFFFFF !important;
}

/* --- Global Reset & Animation Layer --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: var(--text-base);
    background-color: var(--color-canvas);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    min-width: 0;
}

img,
svg {
    max-width: 100%;
}

/* --- Application-Owned SVG Icon System --- */
.icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-block;
    vertical-align: -0.15em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.button .icon,
.sidebar-nav a .icon {
    margin-right: 0.35rem;
}

.button--icon .icon,
.password-toggle .icon,
.logout-modal-close .icon {
    margin-right: 0;
}

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

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

/* --- Form Input Icon Wrap System --- */
.input-icon-wrap {
    position: relative;
    display: block;
}

.input-icon-wrap > .icon,
.input-icon-wrap > svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color 150ms ease;
}

.input-icon-wrap:focus-within > .icon,
.input-icon-wrap:focus-within > svg {
    color: var(--color-brand);
}

button, a, [role="button"], .panel, .button, .status-tag {
    transition: 
        color var(--transition-base),
        background-color var(--transition-base),
        border-color var(--transition-base),
        box-shadow var(--transition-base),
    transform 120ms ease,
        opacity var(--transition-base);
}

h1 { font-size: var(--text-2xl); font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); font-weight: 700; line-height: 1.3; }

a { color: var(--color-brand); text-decoration: none; }
a:hover { color: var(--color-brand-dark); }

/* --- App Shell (Sidebar & Navbar) --- */
.app-container {
    display: flex;
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-overlay);
    position: fixed;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: var(--header-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: var(--text-md);
    color: var(--color-text-inverse);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: var(--radius-xs);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-nav ul { list-style: none; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: hsl(215, 20%, 70%);
    font-size: var(--text-sm);
    font-weight: 600;
}

.sidebar-nav a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-inverse);
}

.sidebar-nav > ul > li.active > a {
    background-color: var(--primary-accent);
    color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(161, 209, 177, 0.25);
}

.sidebar-subnav {
    padding: 0.25rem 0 0.25rem 1.25rem;
}

.sidebar-subnav a {
    padding: 0.45rem 1rem;
    color: hsl(215, 20%, 70%);
    font-size: var(--text-xs);
}

.sidebar-subnav a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-text-inverse);
}

.sidebar-subnav a.active {
    background-color: var(--primary-accent);
    color: var(--primary-dark);
}

.sidebar-nav .logout-item a {
    color: var(--color-text-muted);
}

.sidebar-nav .logout-item a:hover {
    background-color: rgba(161, 209, 177, 0.14);
    color: var(--primary-accent);
}

.has-open-dialog { overflow: hidden; }

.logout-modal[hidden] { display: none; }

.logout-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.logout-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 37, 41, 0.58);
    backdrop-filter: blur(4px);
}

.logout-modal-panel {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    width: min(100%, 480px);
    padding: 1.5rem;
    border: 1px solid rgba(161, 209, 177, 0.45);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: 0 20px 60px rgba(28, 37, 41, 0.28);
    animation: logoutModalIn 160ms ease-out;
}

@keyframes logoutModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.logout-modal-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-brand-light);
    color: var(--primary-dark);
}

.logout-modal-eyebrow {
    margin: 0 0 .25rem;
    color: var(--color-brand);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.logout-modal-content h2 { margin: 0; font-size: var(--text-lg); }
.logout-modal-content p:last-child { margin-top: .45rem; color: var(--color-text-secondary); font-size: var(--text-sm); }

.logout-modal-actions {
    grid-column: 2;
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    margin-top: .35rem;
}

.button--logout-confirm {
    background: var(--primary-dark);
    color: var(--color-text-inverse);
    border-color: var(--primary-dark);
}

.button--logout-confirm:hover { background: var(--color-brand-dark); color: var(--color-text-inverse); }

.logout-modal-close {
    position: absolute;
    top: .7rem;
    right: .7rem;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
}

.logout-modal-close:hover { background: var(--color-brand-light); color: var(--primary-dark); }

@media (max-width: 520px) {
    .logout-modal-panel { grid-template-columns: 1fr; padding: 1.25rem; }
    .logout-modal-actions { grid-column: 1; display: grid; grid-template-columns: 1fr 1fr; }
    .logout-modal-actions .button { width: 100%; padding-inline: .65rem; }
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: calc(100% - var(--sidebar-width));
}

.page-header {
    height: var(--header-height);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    background: var(--color-canvas);
    border: 1px solid var(--color-border);
}

.avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    border: 2px solid var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.content-wrapper {
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
}

/* --- Cards (Nesting Rule Applied) --- */
.panel {
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.panel:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.panel__header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-surface-muted);
}

.panel__body { padding: 1.5rem; }

/* --- Data Tables --- */
.table-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.table-header .actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    padding: 1rem 1.5rem;
    background-color: var(--color-surface-muted);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-secondary);
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 1rem 1.5rem;
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

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

/* --- Forms (Policy 2.0 Compliant) --- */
.field-group { margin-bottom: 1.5rem; }

.field-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
}

.field-input, .field-select, .field-textarea {
    width: 100%;
    min-height: 42px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    line-height: 1.4;
    font-family: inherit;
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    transition: all var(--transition-base);
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    outline: none;
    border-color: var(--primary-accent);
    box-shadow: 0 0 0 4px rgba(161, 209, 177, 0.35);
}

.field-textarea {
    min-height: 120px;
    resize: vertical;
}

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

/* --- Buttons --- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 40px;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--text-sm);
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.button i,
.button .fa,
.button .fas,
.button .far,
.button .fab {
    font-size: 0.9em;
    line-height: 1;
}

.button--primary {
    background-color: var(--color-brand);
    color: var(--color-text-inverse);
    box-shadow: 0 4px 12px rgba(28, 37, 41, 0.22);
    border: none;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.button--primary:hover {
    background-color: var(--primary-accent);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(28, 37, 41, 0.2);
}

.button--primary:active,
.button--outline:active,
.button--icon:active {
    transform: translateY(0);
    box-shadow: none;
}

.button--outline {
    background-color: transparent;
    border-color: var(--color-border-strong);
    color: var(--color-text-primary);
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.button--outline:hover {
    border-color: var(--primary-accent);
    background-color: var(--color-brand-light);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(28, 37, 41, 0.08);
}

.button:disabled,
button:disabled,
.button.disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--primary-dark);
    cursor: pointer;
    transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.button--icon:not(.u-danger):not(.button--delete):hover {
    border-color: var(--primary-accent);
    background: var(--color-brand-light);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.button--icon.u-danger:hover,
.button--icon.button--delete:hover {
    transform: translateY(-1px);
}

/* --- Badges (Visible Border Rule) --- */
.status-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.status-tag--success { 
    background-color: hsl(142, 76%, 95%); 
    color: hsl(142, 76%, 15%); 
    border-color: hsl(142, 76%, 80%); 
}

.status-tag--danger { 
    background-color: hsl(0, 84%, 97%); 
    color: hsl(0, 84%, 30%); 
    border-color: hsl(0, 84%, 85%); 
}

.status-tag--warning { 
    background-color: hsl(38, 92%, 95%); 
    color: hsl(38, 92%, 25%); 
    border-color: hsl(38, 92%, 80%); 
}

/* Project Specific Badges */
.status-tag--available {
    background-color: hsl(142, 76%, 95%);
    color: hsl(142, 76%, 15%);
    border-color: hsl(142, 76%, 80%);
}
.status-tag--reserved {
    background-color: hsl(38, 92%, 95%);
    color: hsl(38, 92%, 25%);
    border-color: hsl(38, 92%, 80%);
}
.status-tag--sold {
    background-color: hsl(0, 84%, 97%);
    color: hsl(0, 84%, 30%);
    border-color: hsl(0, 84%, 85%);
}
.status-tag--blocked { 
    background-color: hsl(210, 40%, 96%); 
    color: var(--color-text-secondary); 
    border-color: var(--color-border); 
}

/* --- Project Grid --- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-brand-light);
}

/* --- Layout Utility --- */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; align-items: center; }
.u-mt-4 { margin-top: 1rem; }
.u-mb-4 { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }

/* Premium Elements */
.icon-box {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-brand-light);
    color: var(--color-brand);
    font-size: var(--text-md);
}

/* Shared content patterns used by legacy and module-specific views. */
.filter-header {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

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

.dialog-panel {
    max-width: min(600px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

/* --- Responsive Layout --- */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 232px;
    }

    .main-content {
        margin-left: var(--sidebar-width);
        max-width: calc(100% - var(--sidebar-width));
        min-width: 0;
    }

    .page-header {
        padding: 0 1.25rem;
    }

    .content-wrapper {
        padding: 1.25rem;
        min-width: 0;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
    }

    .table-header .actions {
        width: 100%;
        justify-content: flex-start;
    }

    .project-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .app-container {
        display: flex;
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        order: 2;
        width: 100%;
        height: auto;
        min-height: 0;
    }

    .sidebar-brand {
        height: 60px;
        padding: 0 1rem;
    }

    .sidebar-nav {
        padding: 0.65rem 0.75rem;
        overflow-x: auto;
    }

    .sidebar-nav ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.35rem;
    }

    .sidebar-nav a {
        min-height: 42px;
        padding: 0.65rem 0.75rem;
        gap: 0.55rem;
        font-size: var(--text-xs);
    }

    .sidebar-nav .logout-item {
        grid-column: 1 / -1;
    }

    .main-content {
        display: contents;
        margin-left: 0;
        min-width: 0;
    }

    .page-header {
        order: 1;
        height: 60px;
        padding: 0 1rem;
    }

    .page-title {
        max-width: calc(100vw - 5rem);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: var(--text-lg);
    }

    .user-info {
        padding: 0.25rem;
    }

    .content-wrapper {
        order: 3;
        padding: 1rem;
    }

    .grid-2,
    .stats-grid,
    .project-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .panel__body,
    .panel__header {
        padding: 1rem;
    }

    .field-group {
        margin-bottom: 1.15rem;
    }

    .field-input,
    .field-select,
    .field-textarea,
    .button {
        min-height: 42px;
    }

    .data-table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
    }

    .filter-header {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }

    .subdivision-container {
        padding: 1rem !important;
        border-radius: var(--radius-lg) !important;
    }

    .lot-grid {
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .lot-card {
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    h1 { font-size: var(--text-xl); }
    h2 { font-size: var(--text-lg); }
    h3 { font-size: var(--text-md); }

    .sidebar-nav ul {
        grid-template-columns: 1fr;
    }

    .sidebar-nav .logout-item {
        grid-column: auto;
    }

    .content-wrapper {
        padding: 0.75rem;
    }

    .button {
        padding: 0.625rem 0.9rem;
    }

    .flex-between {
        gap: 0.75rem;
        flex-wrap: wrap;
    }
}

/* ============================================================
   DIALOG & NAVIGATION INTERACTION STATES
   ============================================================ */
[data-ui-modal][hidden],
[data-nav-toggle][hidden],
#appSidebar[hidden] {
    display: none;
}

.has-open-dialog {
    overflow: hidden;
}

[data-ui-modal] {
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
}

[data-ui-modal] [data-ui-panel],
[data-ui-modal] [role="dialog"] {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
}

.navigation-toggle {
    flex-shrink: 0;
    gap: .5rem;
    min-height: 44px;
    margin-right: .75rem;
}

.navigation-toggle .icon {
    width: 1.25rem;
    height: 1.25rem;
}

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

/* ============================================================
   SYSTEM-WIDE NOTIFICATIONS & MODAL DIALOGS
   ============================================================ */
.user-modal[hidden] {
    display: none !important;
}

.user-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.user-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 37, 41, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.user-modal-dialog {
    position: relative;
    width: min(100%, 480px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(28, 37, 41, 0.3);
    animation: premModalIn 180ms ease-out;
    overflow: hidden;
    z-index: 1;
}

.user-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-surface-muted);
}

.user-modal-body {
    padding: 1.5rem;
}

.user-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@keyframes premModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast Notifications */
.app-toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 420px;
    width: calc(100% - 3rem);
    pointer-events: none;
}

.app-toast {
    pointer-events: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(28, 37, 41, 0.12), 0 2px 6px rgba(28, 37, 41, 0.06);
    padding: 0.95rem 1.15rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    animation: premToastIn 220ms ease-out forwards;
    transition: opacity 200ms ease, transform 200ms ease;
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
}

.app-toast--success {
    border-left: 4px solid hsl(142, 76%, 35%);
}

.app-toast--error {
    border-left: 4px solid hsl(0, 84%, 55%);
}

.app-toast--info {
    border-left: 4px solid var(--primary-dark);
}

.app-toast--warning {
    border-left: 4px solid #D97706;
}

.app-toast-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.app-toast--success .app-toast-icon {
    color: hsl(142, 76%, 35%);
    background: hsl(142, 76%, 95%);
}

.app-toast--error .app-toast-icon {
    color: hsl(0, 84%, 45%);
    background: hsl(0, 84%, 97%);
}

.app-toast--warning .app-toast-icon {
    color: #92400E;
    background: #FEF3C7;
}

.app-toast--info .app-toast-icon {
    color: var(--color-brand);
    background: var(--color-brand-light);
}

.app-toast-icon .icon {
    width: 16px;
    height: 16px;
}

.app-toast-content {
    flex: 1;
    min-width: 0;
}

.app-toast-message {
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    line-height: 1.45;
    word-break: break-word;
}

.app-toast-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.app-toast-close:hover {
    color: var(--color-text-primary);
    background-color: var(--color-canvas);
}

.app-toast-close .icon {
    width: 14px;
    height: 14px;
}

@keyframes premToastIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --- Accessibility: Screen-reader only utility --- */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}


