/* ---------------- Base ---------------- */
:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  color: #fff; font-weight: 700; font-size: 18px;
}
.brand .logo { font-size: 24px; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: #94a3b8; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; color: #cbd5e1; font-size: 14px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; font-size: 11px; color: #64748b; padding: 10px; }

.main { flex: 1; padding: 26px 32px; max-width: 1400px; overflow-x: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ---------------- Cards / grid ---------------- */
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 26px; font-weight: 700; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .value.ok { color: var(--ok); }
.kpi .value.danger { color: var(--danger); }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--brand-2); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }

/* ---------------- Forms ---------------- */
label.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: #334155; }
label.field span.req { color: var(--danger); }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: none; align-items: flex-start; justify-content: center; z-index: 1000;
  padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); overflow: hidden;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- Map ---------------- */
#map { height: 460px; width: 100%; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }

/* ---------------- Misc ---------------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.hidden { display: none !important; }
.row-actions { display: flex; gap: 4px; }
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert-item.warn { background: #fef3c7; color: #92400e; }
.alert-item.danger { background: #fee2e2; color: #991b1b; }
.alert-item.info { background: #dbeafe; color: #1e40af; }
.alert-item .ico { font-size: 18px; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff;
  padding: 13px 20px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: all 0.25s; z-index: 2000; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }
.summary-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.summary-line:last-child { border-bottom: none; }
.summary-line strong { font-size: 15px; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.mini-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
