:root {
    --sidebar-width: 250px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 15px;
}

.wrapper { display: flex; min-height: 100vh; }

/* Sidebar - Simple */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h4 { margin: 0; font-size: 1.2rem; }
.sidebar-header small { opacity: 0.7; }

.sidebar-nav { list-style: none; padding: 0.5rem 0; margin: 0; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav li a.active { border-left: 3px solid var(--primary); }

.nav-section {
    padding: 1rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    color: #fff;
}

/* Main */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    max-height: 300px;
    overflow-y: auto;
    z-index: 200;
}

.search-results.show { display: block; }

.search-result-item {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: block;
}

.search-result-item:hover { background: var(--bg); }

.content-area { padding: 1.25rem; }

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
.page-header .subtitle { color: var(--muted); font-size: 0.9rem; }

/* Stat cards - big & clear */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card.primary .value { color: var(--primary); }
.stat-card.success .value { color: var(--success); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.danger .value { color: var(--danger); }

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

/* Site Map - KEY FEATURE */
.sitemap-container {
    background: var(--card);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.sitemap-legend {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-dot.available { background: #22c55e; }
.legend-dot.reserved { background: #eab308; }
.legend-dot.sold { background: #ef4444; }

.sitemap-grid {
    display: grid;
    gap: 8px;
    justify-content: start;
}

.plot-box {
    width: 110px;
    min-height: 90px;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid rgba(0,0,0,0.1);
    color: #fff;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.plot-box:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10;
}

.plot-box.available { background: #22c55e; }
.plot-box.reserved { background: #eab308; color: #1e293b; }
.plot-box.sold { background: #ef4444; }

.plot-box .plot-no { font-weight: 700; font-size: 0.85rem; }
.plot-box .plot-size { opacity: 0.9; }
.plot-box .plot-owner { font-size: 0.65rem; opacity: 0.85; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.quick-btn i { font-size: 1.2rem; }

/* Tables */
.table { color: var(--text); }
.table th { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.dataTables_wrapper { color: var(--text); }

/* Forms - simple & big */
.form-label { font-weight: 500; margin-bottom: 0.25rem; }
.form-control, .form-select {
    border-radius: 8px;
    border-color: var(--border);
    background: var(--card);
    color: var(--text);
    padding: 0.6rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.btn { border-radius: 8px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-lg-action {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Auth */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
}

.auth-container { width: 100%; max-width: 420px; padding: 1rem; }
.auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* Receipt */
.receipt-box {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    padding: 2rem;
    border: 1px solid #ddd;
}

@media print {
    .no-print { display: none !important; }
    .main-content { margin: 0; }
    .sidebar, .top-navbar { display: none; }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .plot-box { width: 90px; min-height: 75px; font-size: 0.65rem; }
}

/* Alert overdue */
.overdue-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

[data-theme="dark"] .overdue-alert {
    background: #450a0a;
    border-color: #7f1d1d;
}

.hint-text { font-size: 0.8rem; color: var(--muted); }
