:root {
  --bg: #050a11;
  --panel: #0b1421;
  --panel-2: #0e1a2b;
  --panel-3: #101e31;
  --line: rgba(148, 163, 184, .16);
  --text: #f8fafc;
  --muted: #93a4b8;
  --muted-2: #64748b;
  --blue: #0ea5e9;
  --blue-2: #2563eb;
  --blue-dark: #0b3b8f;
  --cyan: #46e6ff;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 60% -10%, rgba(14,165,233,.12), transparent 60%),
    radial-gradient(700px 500px at 95% 30%, rgba(37,99,235,.08), transparent 60%);
  z-index: 0;
}

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; padding: 24px 18px;
  background: rgba(7,17,31,.94); backdrop-filter: blur(24px);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; box-shadow: 0 8px 24px rgba(14,165,233,.18); }
.brand strong { display: block; letter-spacing: .18em; font-size: 16px; }
.brand span { display: block; color: var(--muted); font-size: 9px; letter-spacing: .18em; margin-top: 3px; }

.nav-list { display: grid; gap: 5px; margin-top: 22px; }
.nav-item {
  border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; text-align: left; transition: .2s ease;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(14,165,233,.18), rgba(37,99,235,.1)); color: #fff; border: 1px solid rgba(14,165,233,.18); }
.nav-icon { width: 19px; height: 19px; display: grid; place-items: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; padding: 14px 10px; border: 1px solid var(--line); border-radius: 14px; display: flex; gap: 10px; align-items: flex-start; }
.sidebar-footer strong { display: block; font-size: 12px; }
.sidebar-footer span { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 4px; box-shadow: 0 0 0 5px rgba(34,197,94,.1); }

.main { margin-left: 248px; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 86px; padding: 18px 30px 16px;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(180deg, rgba(5,10,17,.96), rgba(5,10,17,.78)); backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(148,163,184,.08);
}
.eyebrow { margin: 0 0 5px; font-size: 10px; color: var(--blue); letter-spacing: .19em; font-weight: 700; }
.topbar h1 { margin: 0; font-size: clamp(22px, 2.2vw, 31px); line-height: 1.1; letter-spacing: -.025em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn, .avatar-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  display: grid; place-items: center;
}
.icon-btn:hover, .avatar-btn:hover { border-color: rgba(14,165,233,.4); }
.avatar-btn { border-radius: 50%; background: linear-gradient(135deg, var(--blue-dark), #10233c); font-size: 12px; font-weight: 800; }

.view { padding: 24px 30px 46px; max-width: 1600px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-2-1 { grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); }

.card {
  background: linear-gradient(145deg, rgba(14,26,43,.96), rgba(8,17,29,.96)); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-pad { padding: 18px; }
.card-head { padding: 17px 18px 0; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px 18px; }

.metric { padding: 18px; position: relative; min-height: 132px; }
.metric::after { content: ""; position: absolute; width: 100px; height: 100px; right: -32px; top: -42px; border-radius: 50%; background: rgba(14,165,233,.07); }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.metric-value { font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -.045em; margin-top: 12px; }
.metric-foot { color: var(--muted); font-size: 11px; margin-top: 8px; }
.metric-foot strong { color: var(--text); }

.section-title { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin: 8px 0 14px; }
.section-title h2 { font-size: 17px; margin: 0; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 9px 12px; border-radius: 11px;
  font-size: 12px; font-weight: 700; transition: .2s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(14,165,233,.38); }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-2)); border-color: transparent; color: white; box-shadow: 0 10px 28px rgba(14,165,233,.15); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239,68,68,.08); color: #fecaca; border-color: rgba(239,68,68,.2); }
.btn-sm { padding: 7px 9px; font-size: 11px; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-btn { padding: 14px 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.025); color: var(--text); text-align: left; }
.quick-btn span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.quick-btn strong { font-size: 12px; }
.quick-btn:hover { border-color: rgba(14,165,233,.35); background: rgba(14,165,233,.05); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid rgba(148,163,184,.09); font-size: 12px; vertical-align: middle; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }

.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 8px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-blue { color: #7dd3fc; background: rgba(14,165,233,.09); }
.badge-green { color: #86efac; background: rgba(34,197,94,.09); }
.badge-amber { color: #fcd34d; background: rgba(245,158,11,.09); }
.badge-red { color: #fca5a5; background: rgba(239,68,68,.09); }
.badge-purple { color: #c4b5fd; background: rgba(139,92,246,.09); }
.badge-gray { color: #cbd5e1; background: rgba(148,163,184,.08); }

.progress { height: 7px; background: rgba(148,163,184,.1); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.money-pos { color: #86efac; }
.money-neg { color: #fca5a5; }
.money-muted { color: var(--muted); }

.list { display: grid; gap: 9px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 13px; background: rgba(255,255,255,.025); border: 1px solid rgba(148,163,184,.09); }
.list-item-main { min-width: 0; flex: 1; }
.list-item-main strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-main span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.list-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(14,165,233,.08); border: 1px solid rgba(14,165,233,.12); }

.timeline { display: grid; gap: 0; }
.timeline-item { display: grid; grid-template-columns: 64px 1fr; gap: 12px; min-height: 66px; }
.timeline-time { color: var(--muted); font-size: 11px; padding-top: 3px; }
.timeline-content { position: relative; border-left: 1px solid var(--line); padding: 0 0 18px 18px; }
.timeline-content::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); position: absolute; left: -4.5px; top: 4px; box-shadow: 0 0 0 5px rgba(14,165,233,.09); }
.timeline-content strong { font-size: 12px; display: block; }
.timeline-content span { color: var(--muted); font-size: 10px; display: block; margin-top: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { min-width: 220px; flex: 1; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); background: #08131f; color: var(--text); border-radius: 11px; padding: 10px 11px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: rgba(14,165,233,.55); box-shadow: 0 0 0 3px rgba(14,165,233,.08); }
.textarea { resize: vertical; min-height: 90px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.field label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }
.field-full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.finance-tabs { display: inline-flex; background: rgba(255,255,255,.035); border: 1px solid var(--line); padding: 4px; border-radius: 12px; }
.finance-tab { border: 0; color: var(--muted); background: transparent; padding: 8px 12px; border-radius: 9px; font-size: 11px; font-weight: 800; }
.finance-tab.active { color: white; background: rgba(14,165,233,.15); }

.bar-chart { height: 190px; display: flex; gap: 10px; align-items: end; padding-top: 18px; }
.bar-col { flex: 1; min-width: 26px; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.bar { width: min(36px, 72%); border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, var(--cyan), var(--blue-2)); min-height: 4px; position: relative; }
.bar.expense { background: linear-gradient(180deg, #fb7185, #dc2626); }
.bar-label { font-size: 9px; color: var(--muted); }
.bar-value { font-size: 9px; color: #dbeafe; }

#map { height: calc(100vh - 230px); min-height: 440px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #07111f; }
.leaflet-container { background: #07111f; font-family: inherit; }
.map-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.map-list { max-height: calc(100vh - 230px); overflow-y: auto; padding-right: 4px; }
.map-item { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); margin-bottom: 9px; }
.map-item strong { font-size: 12px; display: block; }
.map-item span { color: var(--muted); font-size: 10px; display: block; margin-top: 4px; }

.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 6px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.66); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(680px, 100%); max-height: 88vh; overflow-y: auto; background: #0a1523; border: 1px solid rgba(148,163,184,.22); border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.55); padding: 20px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; }

.toast { position: fixed; z-index: 90; right: 20px; bottom: 22px; max-width: 340px; background: #0f1d2e; border: 1px solid rgba(14,165,233,.28); border-radius: 13px; padding: 12px 14px; color: white; font-size: 12px; box-shadow: var(--shadow); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

.bottom-nav { display: none; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-2-1 { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  .map-list { max-height: 250px; }
  #map { height: 520px; min-height: 420px; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: 78px; }
  .topbar { min-height: 72px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .topbar h1 { font-size: 23px; }
  .view { padding: 15px 14px 28px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 118px; padding: 15px; }
  .metric-value { font-size: 24px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .card-head { padding: 15px 15px 0; }
  .card-body, .card-pad { padding: 14px 15px 15px; }
  .section-title { align-items: flex-start; }
  .section-title .btn { flex: 0 0 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 45; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 7px 5px; border: 1px solid rgba(148,163,184,.16); border-radius: 18px; background: rgba(8,17,29,.94); backdrop-filter: blur(20px); box-shadow: 0 18px 50px rgba(0,0,0,.45);
  }
  .bottom-nav .nav-item { flex-direction: column; gap: 2px; padding: 7px 2px; justify-content: center; border: 0; font-size: 9px; }
  .bottom-nav .nav-icon { font-size: 16px; height: 18px; }
  .bottom-nav .nav-item.active { background: rgba(14,165,233,.11); border: 0; }
  #map { height: 480px; }
  .modal { border-radius: 18px; padding: 16px; }
}

@media (max-width: 420px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .metric { min-height: 105px; }
  .topbar-actions .icon-btn { display: none; }
}
