:root {
  --sidebar-bg: #1a2637;
  --sidebar-border: #243347;
  --accent: #2ecc71;
  --accent-dark: #27ae60;
  --danger: #e74c3c;
  --danger-dark: #c0392b;
  --text: #2c3e50;
  --text-light: #ecf0f1;
  --text-muted: #94a3b8;
  --bg: #f0f2f5;
  --highlight: #fffde7;
  --highlight-border: #f59e0b;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --sidebar-width: 290px;
}

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

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); }

a { color: inherit; text-decoration: none; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s ease;
  white-space: nowrap; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid rgba(255,255,255,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: #fff; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46,204,113,0.12); }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== LOGIN ===== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f1923 0%, #1a2637 50%, #0f2027 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; width: 380px; box-shadow: var(--shadow-lg); }
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.login-title { font-size: 24px; font-weight: 700; text-align: center; color: var(--text); line-height: 1.3; margin-bottom: 8px; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

/* ===== DASHBOARD HEADER ===== */
.dash-header { position: sticky; top: 0; z-index: 100; background: var(--sidebar-bg); border-bottom: 1px solid var(--sidebar-border); padding: 0 24px; height: 60px; }
.dash-header-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; max-width: 1280px; margin: 0 auto; }
.dash-logo { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; color: var(--text-light); }
.dash-actions { display: flex; align-items: center; gap: 10px; }

/* ===== DASHBOARD MAIN ===== */
.dashboard-body { background: var(--bg); min-height: 100vh; }
.dash-main { max-width: 1280px; margin: 0 auto; padding: 32px 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.map-card { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); display: flex; flex-direction: column; transition: box-shadow 0.2s, transform 0.2s; }
.map-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-body { padding: 20px; flex: 1; }
.card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.3; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; }
.badge-records { background: rgba(46,204,113,0.12); color: var(--accent-dark); white-space: nowrap; }
.card-meta { display: flex; flex-direction: column; gap: 8px; }
.card-meta-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-muted); }
.meta-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.auto-delete-input { width: auto; padding: 3px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 80px 24px; }
.empty-icon { margin-bottom: 20px; }
.empty-state h2 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 24px; font-size: 15px; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 12px; padding: 28px; max-width: 440px; width: 90%; box-shadow: var(--shadow-lg); }
.modal-box h3 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-box p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 12px 20px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 14px; z-index: 2000; }

/* ===== UPLOAD ===== */
.upload-body { background: var(--bg); min-height: 100vh; }
.upload-main { max-width: 580px; margin: 40px auto; padding: 0 24px; }
.upload-card { background: var(--card-bg); border-radius: 12px; padding: 36px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.upload-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.upload-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; line-height: 1.5; }
.upload-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 20px; text-align: center; transition: border-color 0.2s, background 0.2s; cursor: default; }
.drop-zone.dragover { border-color: var(--accent); background: rgba(46,204,113,0.05); }
.drop-zone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-zone-inner p { font-size: 14px; color: var(--text-muted); }
.drop-zone-inner span { font-size: 12px; color: var(--text-muted); }
.drop-hint { font-size: 12px !important; color: var(--text-muted); }
.file-info { font-size: 13px; color: var(--accent-dark); font-weight: 500; margin-top: 8px; padding: 8px 12px; background: rgba(46,204,113,0.08); border-radius: 6px; }
.processing-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.processing-box { background: #fff; border-radius: 16px; padding: 40px; text-align: center; max-width: 380px; box-shadow: var(--shadow-lg); }
.processing-box h3 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; }
.processing-box p { color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(46,204,113,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MAP PAGE ===== */
.map-body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
.map-layout { display: grid; grid-template-columns: var(--sidebar-width) 1fr; height: 100vh; overflow: hidden; }
.map-layout.sidebar-hidden { grid-template-columns: 0 1fr; }

/* SIDEBAR */
.sidebar { background: var(--sidebar-bg); overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--sidebar-border); transition: width 0.25s ease; }
.sidebar-hidden .sidebar { width: 0; }
.sidebar-inner { width: var(--sidebar-width); overflow-y: auto; flex: 1; padding-bottom: 20px; }
.sidebar-inner::-webkit-scrollbar { width: 4px; }
.sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.sidebar-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--sidebar-border); display: flex; align-items: center; justify-content: space-between; }
.sidebar-logo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--text-light); }
.sidebar-back { font-size: 12px; color: var(--text-muted); transition: color 0.15s; }
.sidebar-back:hover { color: var(--text-light); }
.sidebar-section { padding: 14px 16px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-map-info { padding: 14px 16px; }
.map-title { font-size: 15px; font-weight: 700; color: var(--text-light); margin-bottom: 4px; }
.map-subtitle { font-size: 12px; color: var(--text-muted); }

.filter-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.filter-title { font-size: 13px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em; }
.filter-group { margin-bottom: 12px; }
.filter-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 5px; }
.filter-input { width: 100%; padding: 6px 10px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; color: var(--text-light); font-size: 13px; }
.filter-input:focus { outline: none; border-color: var(--accent); }
.filter-input::placeholder { color: rgba(255,255,255,0.3); }
.filter-select { width: 100%; padding: 6px 10px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; color: var(--text-light); font-size: 13px; min-height: 34px; }
.filter-select option { background: #1a2637; }
.filter-select[multiple] { min-height: 80px; }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range span { color: var(--text-muted); font-size: 12px; }
.date-range .filter-input { flex: 1; }
.checkbox-group { display: flex; flex-direction: column; gap: 5px; }
.checkbox-group label { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-light); cursor: pointer; }
.checkbox-group input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent); }
.filter-actions { display: flex; gap: 8px; padding-top: 8px; }
.filter-actions .btn { flex: 1; }

/* MAP MAIN */
.map-main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--border); gap: 10px; flex-shrink: 0; }
.toolbar-left { display: flex; align-items: center; gap: 10px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.record-badge { background: rgba(46,204,113,0.12); color: var(--accent-dark); padding: 3px 12px; border-radius: 100px; font-size: 13px; font-weight: 600; }
.geocode-warn { background: rgba(245,158,11,0.1); color: #b45309; padding: 3px 12px; border-radius: 100px; font-size: 12px; font-weight: 500; }
#map-container { flex: 1; min-height: 0; z-index: 1; }
.leaflet-container { height: 100% !important; }

/* TABLE SECTION */
.table-section { height: 280px; display: flex; flex-direction: column; border-top: 2px solid var(--border); background: #fff; flex-shrink: 0; }
.table-toolbar { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: #f8fafc; }
.table-toolbar .page-info { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.table-toolbar .btn { padding: 3px 10px; font-size: 12px; }
.table-toolbar .btn.active { background: var(--accent); color: #fff; }
.table-scroll { flex: 1; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.data-table th { position: sticky; top: 0; background: var(--sidebar-bg); color: var(--text-light); padding: 7px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; z-index: 10; }
.data-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.data-table tr:hover td { background: #f8fafc; }
.data-table tr.highlighted td { background: var(--highlight) !important; outline: 2px solid var(--highlight-border); outline-offset: -1px; }
.status-complete { color: var(--accent-dark); font-weight: 600; }
.status-ua { color: var(--danger); font-weight: 600; }
.edit-input { padding: 3px 7px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px; width: 100%; min-width: 80px; }
