/*
 * AssetPipe Design System v3.0 - Miningo Edition
 * Forest Green + Gold color palette inspired by land & property
 * Primary: #1A4D3A (Forest), Accent: #C9A84C (Gold)
 */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ========================================================================
   1. CSS Custom Properties (Miningo Design Tokens)
   ======================================================================== */

:root {
    /* ---- Miningo Color Palette ---- */
    --forest-dark: #0D291E;
    --forest: #1A4D3A;
    --forest-light: #2D6A52;
    --forest-lighter: #3D8568;
    
    --gold: #C9A84C;
    --gold-light: #E8D5A3;
    --gold-dark: #A0842E;
    --gold-pale: #F5ECD6;
    
    --parchment: #F8F1E3;
    --parchment-dark: #EEE7D9;
    --beige: #DDD7C9;
    --beige-light: #E8E4DA;
    
    --rust: #8B4513;
    --warm-gray: #5C5752;
    --cool-gray: #6B7280;

    /* ---- Background Colors ---- */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;
    --surface-elevated: #FFFFFF;

    /* --- Text --- */
    --text-primary: #1A2332;
    --text-secondary: #4A5568;
    --text-tertiary: #6B7280;
    --text-muted: #9CA3AF;
    --text-on-dark: #F8F1E3;

    /* --- Accent / Semantic (Mapped to Miningo) --- */
    --accent-primary: #1A4D3A;
    --accent-primary-hover: #0D291E;
    --accent-gis: #1A4D3A;
    --accent-gis-hover: #0D291E;
    --accent-geo: #C9A84C;
    --accent-geo-hover: #A0842E;
    --accent-warning: #D97706;
    --accent-warning-hover: #B45309;
    --accent-danger: #DC2626;
    --accent-danger-hover: #B91C1C;
    --accent-success: #059669;
    --accent-success-hover: #047857;
    --accent-gold: #C9A84C;

    /* --- Status backgrounds --- */
    --status-available-bg: rgba(5, 150, 105, 0.1);
    --status-available-text: #059669;
    --status-available-border: #059669;

    --status-validated-bg: rgba(5, 150, 105, 0.15);
    --status-validated-text: #059669;
    --status-validated-border: #059669;

    --status-pending-bg: rgba(59, 130, 246, 0.1);
    --status-pending-text: #3B82F6;
    --status-pending-border: #3B82F6;

    --status-captured-bg: rgba(217, 119, 6, 0.1);
    --status-captured-text: #D97706;
    --status-captured-border: #D97706;

    --status-rejected-bg: rgba(220, 38, 38, 0.1);
    --status-rejected-text: #DC2626;
    --status-rejected-border: #DC2626;

    --status-blocked-bg: rgba(107, 114, 128, 0.1);
    --status-blocked-text: #6B7280;
    --status-blocked-border: #6B7280;

    /* --- Spacing (8px base) --- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* --- Border --- */
    --border-subtle: 1px solid #DDD7C9;
    --border-moderate: 1px solid #C9A84C;
    --border-strong: 1px solid #1A4D3A;
    --border-default: 1px solid #E2E8F0;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;
    --border-radius-full: 9999px;
    --border-radius-pill: 9999px;

    /* --- Shadows --- */
    --shadow-sm: 0 1px 2px rgba(13, 41, 30, 0.05);
    --shadow-md: 0 4px 6px rgba(13, 41, 30, 0.07);
    --shadow-lg: 0 10px 15px rgba(13, 41, 30, 0.1);
    --shadow-xl: 0 20px 25px rgba(13, 41, 30, 0.15);
    --shadow-gold: 0 4px 12px rgba(201, 168, 76, 0.3);

    /* --- Transitions --- */
    --transition-fast: 150ms ease;
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);

    /* --- Layout --- */
    --navbar-height: 64px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --container-max: 1400px;

    /* --- Z-index layers --- */
    --z-sidebar: 50;
    --z-navbar: 100;
    --z-dropdown: 200;
    --z-modal-backdrop: 300;
    --z-modal: 400;
    --z-toast: 500;
}


/* ========================================================================
   2. Reset & Base
   ======================================================================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: #F6F5F1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-geo);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--accent-geo-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent iOS zoom on input focus */
input, select, textarea {
    font-size: 16px;
}


/* ========================================================================
   3. Typography
   ======================================================================== */

.text-hero {
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h1, .text-h1 {
    font-family: 'Playfair Display', serif;
    font-size: 36px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

h2, .text-h2 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

h3, .text-h3 {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h4, .text-h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.text-body {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-secondary);
}

.text-small {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
}

.text-micro {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.02em;
    color: var(--text-tertiary);
}

.text-label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.text-data {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.text-mono {
    font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

.text-italic-accent {
    font-style: italic;
    color: var(--accent-gold);
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-success { color: var(--accent-gis); }
.text-warning { color: var(--accent-warning); }
.text-danger { color: var(--accent-danger); }


/* ========================================================================
   4. Layout
   ======================================================================== */

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.app-layout {
    display: flex;
    min-height: calc(100vh - var(--navbar-height));
    padding-top: var(--navbar-height);
}

.main-content {
    flex: 1;
    min-width: 0; /* Prevent flex overflow */
    padding: var(--space-6);
}

.has-sidebar .main-content {
    margin-left: var(--sidebar-width);
}

/* Page header pattern */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.page-header h1 {
    margin: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Grid utilities */
.grid {
    display: grid;
    gap: var(--space-6);
}

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

/* Flex utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }


/* ========================================================================
   5. Navbar
   ======================================================================== */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-primary);
    border-bottom: var(--border-subtle);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    z-index: var(--z-navbar);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
}

.navbar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--forest);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: var(--gold);
}

.navbar-spacer {
    flex: 1;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.navbar-notification-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--border-radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.navbar-notification-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--accent-danger);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}
.navbar-user:hover {
    background: var(--bg-tertiary);
}

.navbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.navbar-user-info {
    display: flex;
    flex-direction: column;
}

.navbar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.navbar-user-role {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* User dropdown */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-2);
    background: var(--surface-elevated);
    border: var(--border-default);
    border-radius: var(--border-radius-md);
    min-width: 200px;
    padding: var(--space-2) 0;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: var(--z-dropdown);
}
.user-dropdown.is-open {
    display: block;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.user-dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.user-dropdown-divider {
    height: 1px;
    background: var(--bg-tertiary);
    margin: var(--space-2) 0;
}


/* ========================================================================
   6. Sidebar
   ======================================================================== */

.sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    width: 260px;
    height: calc(100vh - 64px);
    background: #FFFFFF;
    border-right: 1px solid #E5E7EB;
    display: flex;
    flex-direction: column;
    z-index: 90;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: var(--space-4);
}

.sidebar-section {
    padding: var(--space-3) var(--space-4);
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-dark);
    padding: var(--space-2) var(--space-4);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--gold-pale);
    padding-bottom: var(--space-3);
}

/* Estate context row — shows the active estate at sidebar-nav scale.
   Sits below the top-level nav and above the per-product nav. The
   whole row is one clickable target that opens the Cmd/K switcher,
   so it doubles as the switch affordance. Visually restrained so it
   doesn't compete with the product switcher card above it. */
.sidebar-estate-ctx {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: var(--space-3) var(--space-2) var(--space-2);
    padding: 8px 10px;
    background: var(--gold-pale, #FFFBEB);
    border: 1px solid rgba(201, 168, 76, 0.25);
    border-radius: 10px;
    color: var(--forest-dark, #0F2D22);
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}
.sidebar-estate-ctx:hover {
    background: #FEF3C7;
    border-color: rgba(201, 168, 76, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15,23,42,0.06);
}
.sidebar-estate-ctx-cover {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 7px;
    background: linear-gradient(135deg, #1A4D3A 0%, #0F2D22 100%);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.sidebar-estate-ctx-initial {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 17px;
    font-weight: 500;
    color: rgba(255,255,255,0.92);
}
.sidebar-estate-ctx-body {
    flex: 1;
    min-width: 0;
}
.sidebar-estate-ctx-eyebrow {
    font-size: 9px;
    font-weight: 700;
    color: #8A6A12;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.1;
}
.sidebar-estate-ctx-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--forest-dark, #0F2D22);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-estate-ctx-switch {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: #8A6A12;
    opacity: 0.65;
    transition: opacity 0.15s;
}
.sidebar-estate-ctx:hover .sidebar-estate-ctx-switch {
    opacity: 1;
}

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

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--forest);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    margin-right: var(--space-2);
}
.sidebar-nav-item:hover {
    color: var(--forest-dark);
    background: var(--gold-pale);
    border-left-color: var(--gold-light);
}
.sidebar-nav-item.is-active {
    color: var(--forest-dark);
    font-weight: 600;
    background: var(--gold-pale);
    /* Border edge takes the active-product accent when available,
       falls back to gold for any legacy sidebar branch. */
    border-left-color: var(--p-accent, var(--gold));
}
.sidebar-nav-item.is-active i,
.sidebar-nav-item.is-active svg {
    color: var(--gold-dark);
}

/* Active product accent strip — sits along the right edge of the sidebar
   as a subtle "you are here" cue. Per-product colour. */
.sidebar {
    border-right: 1px solid #E5E7EB;
    box-shadow: inset -3px 0 0 var(--p-accent, transparent);
}

.sidebar-nav-item i,
.sidebar-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--warm-gray);
}

.sidebar-nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--border-radius-pill);
    background: var(--gold-pale);
    color: var(--gold-dark);
}

/* ────────────────────────────────────────────────────────────────────────
   Product switcher (Atlassian-style) — top of the sidebar
   ──────────────────────────────────────────────────────────────────────── */

.ps-switcher {
    margin: 14px 12px 6px;
    background: linear-gradient(135deg, #0F2918 0%, #0A1B11 100%);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(255,255,255,0.08);
}
.ps-switcher:hover { border-color: rgba(255,255,255,0.18); }
.ps-switcher-row { display: flex; align-items: center; gap: 10px; }
.ps-switcher-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ps-switcher-body { flex: 1; min-width: 0; }
.ps-switcher-name {
    font-size: 13px; font-weight: 800;
    color: #fff; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ps-switcher-tag {
    font-size: 10px; color: rgba(255,255,255,0.55);
    font-weight: 600;
    margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ps-switcher-drop {
    position: absolute;
    top: calc(100% + 4px);
    left: 6px; right: 6px;
    background: #0F1A14;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 6px;
    display: none;
    z-index: 200;
    box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.ps-switcher.is-open .ps-switcher-drop { display: block; }
.ps-switcher-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #fff;
    transition: background 0.12s;
}
.ps-switcher-option:hover { background: rgba(255,255,255,0.06); }
.ps-switcher-option.is-active { background: rgba(6,182,212,0.12); }

/* ────────────────────────────────────────────────────────────────────────
   Product pills (other licensed + available upsells)
   ──────────────────────────────────────────────────────────────────────── */

.ps-product-pills {
    display: flex; flex-direction: column; gap: 4px;
    padding: 0 12px;
    margin-bottom: 8px;
}
.ps-product-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    text-decoration: none;
    color: var(--forest);
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.12s;
}
.ps-product-pill:hover {
    background: var(--gold-pale);
    border-color: rgba(201,168,76,0.25);
    transform: translateX(2px);
}
.ps-product-pill-muted { opacity: 0.7; }
.ps-product-pill-muted:hover { opacity: 1; }
.ps-pill-mark {
    width: 24px; height: 24px;
    border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ps-pill-body { flex: 1; min-width: 0; }
.ps-pill-name {
    font-size: 12px; font-weight: 700;
    line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--forest-dark);
    display: flex; align-items: center; gap: 5px;
}
.ps-pill-tag {
    font-size: 10px;
    color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin-top: 1px;
}
.ps-pill-badge {
    font-size: 8px; font-weight: 800;
    padding: 1px 5px;
    border-radius: 999px;
    background: var(--gold-pale);
    color: var(--gold-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ========================================================================
   7. Buttons
   ======================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover {
    background: var(--forest-dark);
    box-shadow: var(--shadow-gold);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: var(--border-moderate);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--accent-gis);
    color: white;
}
.btn-success:hover:not(:disabled) {
    background: var(--accent-gis-hover);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}
.btn-danger:hover:not(:disabled) {
    background: var(--accent-danger-hover);
}

.btn-warning {
    background: var(--accent-warning);
    color: var(--bg-primary);
}

.btn-ghost {
    background: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-ghost:hover:not(:disabled) {
    background: rgba(30, 30, 30, 0.9);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 13px;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: 16px;
}

.btn-icon {
    padding: var(--space-2);
    width: 36px;
    height: 36px;
}

.btn-block {
    width: 100%;
}

/* Big field action button (80% width, prominent) */
.btn-field-action {
    width: 80%;
    margin: 0 auto;
    padding: var(--space-4) var(--space-6);
    font-size: 16px;
    font-weight: 700;
    border-radius: var(--border-radius-md);
    display: flex;
}


/* ========================================================================
   8. Cards
   ======================================================================== */

.card {
    background: var(--bg-primary);
    border: var(--border-subtle);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: var(--space-4);
}

.card-header {
    padding: var(--space-4);
    border-bottom: var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-footer {
    padding: var(--space-4);
    border-top: var(--border-subtle);
}

/* Stat card (dashboard metrics) */
.stat-card {
    background: var(--bg-primary);
    border: var(--border-subtle);
    border-top: 3px solid var(--gold);
    border-radius: var(--border-radius-md);
    padding: var(--space-4) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 100px;
}
.stat-card-value {
    font-family: 'Playfair Display', serif;
    font-size: 36px;
    font-weight: 600;
    line-height: 1;
    color: var(--forest);
}
.stat-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.stat-card-link {
    font-size: 13px;
    color: var(--gold);
    margin-top: auto;
}

.stat-card.accent-warning { border-top-color: var(--accent-warning); }
.stat-card.accent-danger { border-top-color: var(--accent-danger); }
.stat-card.accent-geo { border-top-color: var(--forest); }
.stat-card.accent-gold { border-top-color: var(--gold); }
.stat-card.accent-forest { border-top-color: var(--forest); }
.stat-card.accent-rust { border-top-color: var(--rust); }

/* Data card (stand card in lists) */
.stand-card {
    background: var(--bg-tertiary);
    border: var(--border-subtle);
    border-left: 4px solid var(--text-muted);
    border-radius: var(--border-radius-sm);
    padding: var(--space-4);
    transition: background var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
}
.stand-card:hover {
    background: var(--surface-elevated);
    color: inherit;
}

/* Status-colored left border for stand cards */
.stand-card[data-status="available"] { border-left-color: var(--status-available-border); }
.stand-card[data-status="validated"] { border-left-color: var(--status-validated-border); }
.stand-card[data-status="pending_capture"],
.stand-card[data-status="pending_qa"] { border-left-color: var(--status-pending-border); }
.stand-card[data-status="captured"] { border-left-color: var(--status-captured-border); }
.stand-card[data-status="rejected"] { border-left-color: var(--status-rejected-border); }
.stand-card[data-status="blocked"] { border-left-color: var(--status-blocked-border); }


/* ========================================================================
   9. Status Badges
   ======================================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--border-radius-full);
    white-space: nowrap;
    text-transform: capitalize;
}

.status-badge-available {
    background: #ECFDF5;
    color: #059669;
    border: 1px solid #A7F3D0;
}

.status-badge-validated {
    background: #D1FAE5;
    color: #047857;
    border: 1px solid #6EE7B7;
}

.status-badge-pending_qa {
    background: #FEF3C7;
    color: #D97706;
    border: 1px solid #FCD34D;
}

.status-badge-rejected {
    background: #FEE2E2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.status-badge-blocked {
    background: #F3F4F6;
    color: #6B7280;
    border: 1px solid #D1D5DB;
}

.status-badge-captured {
    background: #DBEAFE;
    color: #2563EB;
    border: 1px solid #BFDBFE;
}

/* Deeds office status badges */
.status-badge-not_submitted {
    background: rgba(100, 100, 100, 0.1);
    color: var(--text-muted);
}
.status-badge-with_agent {
    background: var(--status-pending-bg);
    color: var(--status-pending-text);
}
.status-badge-at_deeds_office {
    background: var(--status-captured-bg);
    color: var(--status-captured-text);
}
.status-badge-verified {
    background: var(--status-validated-bg);
    color: var(--status-validated-text);
}


/* ========================================================================
   10. Forms
   ======================================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.form-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label-required::after {
    content: " *";
    color: var(--accent-danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: var(--border-moderate);
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--gold);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23737373'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-checkbox-group {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.form-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}

.form-error {
    font-size: 13px;
    color: var(--accent-danger);
}

/* Inline form row */
.form-row {
    display: flex;
    gap: var(--space-4);
}
.form-row > .form-group {
    flex: 1;
}

/* File upload zone */
.file-upload-zone {
    border: 2px dashed #C9A84C;
    border-radius: var(--border-radius-md);
    padding: var(--space-8);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--bg-secondary);
}
.file-upload-zone:hover,
.file-upload-zone.is-dragover {
    border-color: var(--forest);
    background: rgba(26, 77, 58, 0.04);
}

.file-upload-zone input[type="file"] {
    display: none;
}


/* ========================================================================
   11. Tables
   ======================================================================== */

.table-wrapper {
    overflow-x: auto;
    border: var(--border-subtle);
    border-radius: var(--border-radius-md);
}

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

.data-table thead {
    background: var(--bg-tertiary);
    border-bottom: var(--border-moderate);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: var(--border-subtle);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}


/* ========================================================================
   12. Flash Messages / Alerts
   ======================================================================== */

.flash-container {
    position: fixed;
    top: calc(var(--navbar-height) + var(--space-4));
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 420px;
}

.flash-message {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-lg);
    animation: flash-slide-in 0.3s ease-out;
    border-left: 3px solid;
    background: var(--surface-elevated);
    color: var(--text-primary);
}

.flash-message-info { border-left-color: var(--accent-geo); }
.flash-message-success { border-left-color: var(--accent-gis); }
.flash-message-warning { border-left-color: var(--accent-warning); }
.flash-message-error { border-left-color: var(--accent-danger); }

.flash-message-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
}

@keyframes flash-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


/* ========================================================================
   13. Modal
   ======================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: none;
}
.modal-backdrop.is-open { display: flex; align-items: center; justify-content: center; }

.modal,
.modal-content {
    background: var(--bg-primary);
    border: var(--border-default);
    border-radius: var(--border-radius-md);
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    padding: var(--space-4) var(--space-6);
    border-bottom: var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}


/* ========================================================================
   14. Progress Bars
   ======================================================================== */

.progress-bar {
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: var(--border-radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gis) 0%, var(--accent-success) 100%);
    border-radius: var(--border-radius-full);
    transition: width 0.3s ease;
}

.progress-bar-fill.warning { background: var(--accent-warning); }
.progress-bar-fill.danger { background: var(--accent-danger); }


/* ========================================================================
   15. Empty States
   ======================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    color: var(--text-tertiary);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    opacity: 0.3;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: var(--space-6);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}


/* ========================================================================
   16. Map Styles
   ======================================================================== */

.map-container {
    width: 100%;
    height: 400px;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: var(--border-subtle);
    background: var(--bg-tertiary);
}

.map-container-full {
    height: calc(100vh - var(--navbar-height));
    border-radius: 0;
    border: none;
}

/* Override Leaflet controls for light theme */
.leaflet-control-zoom a {
    background: white !important;
    color: var(--text-primary) !important;
    border-color: #E5E7EB !important;
}

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.85) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
}
.leaflet-control-attribution a {
    color: var(--text-tertiary) !important;
}

/* Map floating panel */
.map-panel {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid #E5E7EB;
    border-radius: var(--border-radius-md);
    padding: var(--space-4);
    z-index: 500;
    min-width: 240px;
    box-shadow: var(--shadow-lg);
}


/* ========================================================================
   17. Skeleton / Loading
   ======================================================================== */

.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
    position: relative;
    overflow: hidden;
}
.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-2);
}
.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-3);
}
.skeleton-card {
    height: 120px;
}


/* ========================================================================
   18. GPS Accuracy Indicator
   ======================================================================== */

.accuracy-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.accuracy-good {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-gis);
}
.accuracy-acceptable {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
}
.accuracy-poor {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-danger);
}


/* ========================================================================
   19. Responsive
   ======================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.is-open {
        transform: translateX(0);
    }

    .has-sidebar .main-content {
        margin-left: 0;
    }

    .navbar-user-info {
        display: none;
    }
}

/* Mobile */
@media (max-width: 640px) {
    :root {
        --space-6: 16px;
    }

    .text-hero { font-size: 32px; }
    h1, .text-h1 { font-size: 28px; }
    h2, .text-h2 { font-size: 22px; }

    .container {
        padding: 0 var(--space-4);
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
    }

    .btn-field-action {
        width: 100%;
    }

    .data-table {
        font-size: 13px;
    }
    .data-table th,
    .data-table td {
        padding: var(--space-2) var(--space-3);
    }

    /* Hide non-critical table columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}


/* ========================================================================
   20. Utility Classes
   ======================================================================== */

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.hidden { display: none !important; }

/* ========================================================================
   14. Contextual Help Tooltips
   ======================================================================== */

.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(26, 77, 58, 0.08);
    color: var(--forest-light);
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    position: relative;
    vertical-align: middle;
    margin-left: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.help-tip:hover {
    background: rgba(26, 77, 58, 0.15);
    color: var(--forest);
}
.help-tip::after {
    content: attr(data-help);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--forest-dark);
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    white-space: normal;
    width: max-content;
    max-width: 260px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.help-tip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--forest-dark);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 9999;
}
.help-tip:hover::after,
.help-tip:hover::before {
    opacity: 1;
    visibility: visible;
}
.help-tip.help-tip-right::after {
    left: auto;
    right: 0;
    transform: none;
}
.help-tip.help-tip-left::after {
    left: 0;
    right: auto;
    transform: none;
}

/* ========================================================================
   15. Onboarding Wizard Modal
   ======================================================================== */

.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 41, 30, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}
.onboarding-modal {
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 24px 64px rgba(0,0,0,0.25);
    max-width: 560px;
    width: 100%;
    overflow: hidden;
    animation: onboardSlideUp 0.3s ease;
}
@keyframes onboardSlideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
.onboarding-header {
    background: linear-gradient(135deg, var(--forest) 0%, var(--forest-light) 100%);
    color: #fff;
    padding: var(--space-8) var(--space-6) var(--space-6);
    text-align: center;
}
.onboarding-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px 0;
}
.onboarding-header p {
    font-size: 14px;
    opacity: 0.85;
    margin: 0;
}
.onboarding-body {
    padding: var(--space-6);
}
.onboarding-steps {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin-bottom: var(--space-5);
}
.onboarding-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    transition: all 0.2s;
}
.onboarding-step-dot.is-active {
    background: var(--forest);
    transform: scale(1.2);
}
.onboarding-step-dot.is-done {
    background: var(--accent-gis);
}
.onboarding-step {
    display: none;
}
.onboarding-step.is-active {
    display: block;
}
.onboarding-step-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    margin: 0 auto var(--space-4);
}
.onboarding-step h3 {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    margin: 0 0 var(--space-2) 0;
    color: var(--text-primary);
}
.onboarding-step p {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
    margin: 0;
}
.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-top: var(--border-subtle);
}
.onboarding-footer .btn { min-width: 100px; justify-content: center; }
