/* Terra Sentinel v0.6 PRO — Styles */
:root {
  --bg: #0b1120;
  --bg2: #111c33;
  --panel: #111c33;
  --card: #ffffff;
  --card-bg: #ffffff;
  --muted: #64748b;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-light: #64748b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15,23,42,0.08);
  --kanban-bg: #f1f5f9;
  --input-bg: #ffffff;
  --hover-row: #f8fafc;
  --code-bg: #f8fafc;
}
[data-theme="dark"] {
  --bg: #0b1120;
  --bg2: #0f172a;
  --panel: #1e293b;
  --card: #1e293b;
  --card-bg: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --kanban-bg: #0f172a;
  --input-bg: #334155;
  --hover-row: #1e293b;
  --code-bg: #1e293b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: #f1f5f9; color: var(--text); font-size: 14px;
  transition: background 0.3s, color 0.3s;
}
[data-theme="dark"] body,
[data-theme="dark"] { background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button, .btn {
  padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: all 0.15s;
  background: var(--text); color: white; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { opacity: 0.85; transform: translateY(-1px); }
button.sm { padding: 5px 10px; font-size: 12px; }
button.outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
button.outline:hover { border-color: var(--accent); color: var(--accent); }
button.success { background: var(--success); }
button.warning { background: var(--warning); }
button.danger { background: var(--danger); }
button.accent { background: var(--accent); }
input, select, textarea {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; width: 100%; background: var(--input-bg); color: var(--text);
  transition: border 0.15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,233,0.15); }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-light); border-bottom: 2px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--hover-row); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-low { background: #dcfce7; color: #166534; }
.badge-med { background: #fef9c3; color: #854d0e; }
.badge-high { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .badge-low { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-med { background: #713f12; color: #fde68a; }
[data-theme="dark"] .badge-high { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-info { background: #1e3a5f; color: #93c5fd; }
.score-bar { display: flex; gap: 4px; align-items: center; }
.score-fill { height: 6px; border-radius: 3px; transition: width 0.3s; }
.score-legal { background: var(--danger); }
.score-commercial { background: var(--accent); }
.score-solar { background: var(--warning); }
.score-total { background: var(--success); }

/* Layout */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg); color: white; padding: 24px 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: background 0.3s;
}
.sidebar .logo { padding: 0 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar .logo h1 { font-size: 20px; font-weight: 700; }
.sidebar .logo p { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.sidebar-search { padding: 10px 12px; }
.sidebar-search input {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
  color: white; font-size: 12px; border-radius: 8px; padding: 8px 12px; width: 100%;
}
.sidebar-search input::placeholder { color: #64748b; }
.sidebar-search input:focus { border-color: var(--accent); background: rgba(255,255,255,0.12); }
.sidebar nav { flex: 1; padding: 8px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: #cbd5e1; font-size: 13px; font-weight: 500; transition: all 0.15s;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,0.06); color: white; }
.sidebar nav a .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar .user-section {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: #94a3b8;
}
.sidebar .user-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar .user-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.main-content { padding: 24px; overflow-y: auto; max-height: 100vh; }
.page { display: none; }
.page.active { display: block; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); transition: background 0.3s; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); transition: background 0.3s; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }
.filter-bar button { flex-shrink: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ml-auto { margin-left: auto; }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.pagination button { min-width: 32px; height: 32px; padding: 0 8px; justify-content: center; font-size: 12px; }
.pagination button.active { background: var(--accent); color: white; }
.pagination .page-info { font-size: 12px; color: var(--text-light); margin: 0 8px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius); padding: 24px;
  max-width: 560px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); transition: background 0.3s;
}
.modal h2 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.modal label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text-light); }
.modal .form-group { margin-bottom: 12px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--text); color: white;
  padding: 12px 20px; border-radius: 10px; font-size: 13px; z-index: 2000;
  opacity: 0; transform: translateY(20px); transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Map */
#map { height: calc(100vh - 48px); border-radius: var(--radius); }

/* ===== KANBAN ===== */
.kanban-board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; overflow-x: auto; min-height: 60vh; }
.kanban-col {
  background: var(--kanban-bg); border-radius: var(--radius); padding: 12px;
  min-width: 180px; min-height: 200px;
  transition: background 0.3s;
}
.kanban-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kanban-header h3 { font-size: 13px; font-weight: 600; }
.kanban-header .count {
  background: var(--text); color: white; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
}
.kanban-header.won .count { background: var(--success); }
.kanban-header.lost .count { background: var(--danger); }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: var(--card); border-radius: 8px; padding: 10px 12px; cursor: grab;
  box-shadow: var(--shadow); border-left: 3px solid var(--accent);
  transition: all 0.15s; font-size: 12px;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.kanban-card.dragging { opacity: 0.4; transform: rotate(3deg); }
.kanban-card .k-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kanban-card .k-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 8px; }
.kanban-card .k-value { font-weight: 700; color: var(--success); }
.kanban-card .k-contact { color: var(--accent); }
.kanban-col.drag-over { background: var(--accent); opacity: 0.15; }
.kanban-card .k-actions { margin-top: 6px; display: flex; gap: 4px; }
.kanban-card .k-actions button { font-size: 10px; padding: 2px 6px; }

/* ===== INLINE EDIT ===== */
.inline-edit {
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
  border: 1.5px solid transparent; transition: all 0.15s;
  display: inline-block; min-width: 30px;
}
.inline-edit:hover { border-color: var(--accent); background: rgba(14,165,233,0.06); }
.inline-edit.editing { border-color: var(--accent); background: white; cursor: text; }
.inline-edit input, .inline-edit select {
  border: none; padding: 0; margin: 0; font: inherit; background: transparent;
  width: auto; min-width: 60px; outline: none; color: var(--text);
}
[data-theme="dark"] .inline-edit.editing { background: var(--input-bg); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; border: 1.5px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.admin-tab { display: none; }
.admin-tab.active { display: block; }

/* ===== THEME TOGGLE ===== */
.theme-toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.theme-toggle input { opacity: 0; width: 0; height: 0; }
.theme-toggle .slider {
  position: absolute; cursor: pointer; inset: 0; background: rgba(255,255,255,0.15);
  border-radius: 20px; transition: 0.3s; display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1;
}
.theme-toggle input:checked + .slider { background: #fbbf24; }
.theme-toggle .slider::before { content: '🌙'; }
.theme-toggle input:checked + .slider::before { content: '☀️'; }

/* ===== NOTIF BADGE ===== */
.notif-badge {
  background: var(--danger); color: white; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 99px; min-width: 18px; text-align: center;
}

/* ===== NOTIFICATION SEVERITY ===== */
.sev-INFO { background: #dbeafe; color: #1e40af; }
.sev-WARNING { background: #fef9c3; color: #854d0e; }
.sev-ERROR { background: #fee2e2; color: #991b1b; }
.sev-CRITICAL { background: #fecaca; color: #7f1d1d; }
[data-theme="dark"] .sev-INFO { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .sev-WARNING { background: #713f12; color: #fde68a; }
[data-theme="dark"] .sev-ERROR { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .sev-CRITICAL { background: #450a0a; color: #fca5a5; }

/* ===== PIPELINE FUNNEL ===== */
.pipeline-funnel { display: flex; gap: 4px; align-items: flex-end; padding: 8px 0; }
.funnel-bar {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: 6px 6px 0 0;
  font-size: 11px; font-weight: 600; color: white; transition: height 0.3s;
  position: relative; min-height: 30px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
}
.funnel-bar .f-count { font-size: 18px; font-weight: 800; line-height: 1; }
.funnel-bar .f-label { font-size: 9px; opacity: 0.85; margin-top: 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; z-index: 100; width: 280px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 12px; }
  .filter-bar { flex-direction: column; }
  .filter-bar input, .filter-bar select { width: 100%; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
}
@media (max-width: 480px) {
  .kanban-board { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}
