﻿@import url("https://cdn.web-fonts.ge/fonts/bpg-mrgvlovani-caps/css/bpg-mrgvlovani-caps.min.css");

:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --panel: #eef3f8;
  --text: #17202f;
  --muted: #647186;
  --line: #d9e1ea;
  --accent: #0c73e8;
  --accent-strong: #0758b9;
  --teal: #0aa889;
  --gold: #c08a2d;
  --success: #0f8f61;
  --warning: #bf7a00;
  --danger: #cc3d3d;
  --potential: #6e55ca;
  --shadow: 0 20px 60px rgba(25, 42, 70, 0.14);
  --radius: 8px;
  --sidebar: #111827;
  --sidebar-text: #f7fafc;
  --sidebar-muted: #9aa7b8;
  font-family: "BPG Mrgvlovani Caps", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  color-scheme: dark;
  --bg: #0f141b;
  --surface: rgba(21, 29, 39, 0.88);
  --surface-solid: #151d27;
  --panel: #101922;
  --text: #eef4fb;
  --muted: #a6b3c5;
  --line: #2c3948;
  --accent: #4c9aff;
  --accent-strong: #87bfff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  --sidebar: #0b1118;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(12, 115, 232, 0.16), transparent 32rem),
    radial-gradient(circle at 84% 18%, rgba(10, 168, 137, 0.12), transparent 28rem),
    linear-gradient(135deg, var(--bg), #edf3f9 55%, var(--bg));
  color: var(--text);
}

body.dark {
  background:
    radial-gradient(circle at top left, rgba(76, 154, 255, 0.14), transparent 34rem),
    linear-gradient(135deg, var(--bg), #141b24 55%, var(--bg));
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}

.login-art {
  position: relative;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  background:
    linear-gradient(rgba(12, 19, 30, 0.62), rgba(12, 19, 30, 0.28)),
    url("https://images.unsplash.com/photo-1519003722824-194d4455a60c?auto=format&fit=crop&w=1600&q=80") center/cover;
  color: white;
}

.login-art::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(6, 10, 18, 0.85));
}

.brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: transparent;
  object-fit: contain;
  padding: 0;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.24));
}

.login-copy {
  position: relative;
  z-index: 1;
  max-width: 640px;
}

.login-copy h1 {
  margin: 0 0 18px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 18px;
  line-height: 1.7;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background:
    linear-gradient(180deg, rgba(18, 27, 42, 0.96), rgba(10, 16, 25, 0.98)),
    var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  padding: 2px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button,
.mobile-nav button {
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: var(--radius);
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav button {
  color: var(--sidebar-muted);
}

.nav button.active,
.nav button:hover {
  color: #fff;
  background: linear-gradient(90deg, rgba(12, 115, 232, 0.26), rgba(10, 168, 137, 0.12));
  box-shadow: inset 3px 0 0 var(--accent);
}

.user-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  color: var(--sidebar-muted);
  font-size: 13px;
}

.sidebar-logout {
  width: 100%;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  cursor: pointer;
}

.sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.14);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.page-title h1 {
  margin: 0;
  font-size: 28px;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.btn.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 24px rgba(12, 115, 232, 0.22);
}

.btn.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.icon {
  width: 40px;
  padding: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: liftIn 0.24s ease both;
}

@keyframes liftIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.panel,
.map-shell,
.data-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -24px;
  width: 94px;
  height: 94px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(12, 115, 232, 0.12), rgba(10, 168, 137, 0.12));
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(340px, 0.9fr);
  gap: 14px;
}

.dashboard-stack {
  display: grid;
  gap: 14px;
}

.dashboard-secondary-grid {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.dashboard-secondary-grid.admin-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-secondary-grid.viewer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-equal-panel {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-height: 360px;
}

.scroll-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

.map-shell {
  overflow: hidden;
}

#map,
#customerMap {
  min-height: 540px;
  width: 100%;
  background: var(--panel);
}

.fallback-map-frame {
  width: 100%;
  min-height: 540px;
  border: 0;
  display: block;
}

.fallback-map-list {
  position: absolute;
  right: 14px;
  top: 72px;
  z-index: 5;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100% - 28px));
}

.fallback-pin {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.fallback-pin strong,
.fallback-pin span {
  display: block;
}

.fallback-pin span {
  color: var(--muted);
  font-size: 12px;
}

#customerMap {
  min-height: 260px;
}

.map-tools {
  position: absolute;
  z-index: 500;
  top: 14px;
  left: 58px;
  right: 14px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.map-tools > * {
  pointer-events: auto;
}

.map-wrap {
  position: relative;
}

.dashboard-stack .map-wrap #map {
  min-height: clamp(560px, 58vh, 760px);
}

.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.16s ease, transform 0.16s ease;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  color: var(--muted);
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pagination-actions .btn {
  min-width: 40px;
  padding-left: 12px;
  padding-right: 12px;
}

.page-ellipsis {
  padding: 0 2px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.status.active {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.status.inactive {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.status.potential {
  color: var(--potential);
  background: color-mix(in srgb, var(--potential) 13%, transparent);
}

.chart-list,
.recent-list,
.quick-grid {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #15a36f);
}

.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  background: color-mix(in srgb, var(--surface-solid) 78%, transparent);
}

.recent-copy,
.recent-copy strong,
.recent-copy span {
  display: block;
  min-width: 0;
}

.recent-copy strong {
  color: var(--text);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recent-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.recent-item .status {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 6px 8px;
  font-size: 11px;
}

.quick-grid {
  grid-template-columns: repeat(2, 1fr);
}

.customer-workspace {
  display: grid;
  gap: 14px;
}

.customer-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.customer-summary article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--accent) 4%, var(--surface-solid)));
  box-shadow: var(--shadow);
}

.customer-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.customer-summary strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
}

.table-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.mysql-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mysql-grid .wide,
.mysql-panel {
  grid-column: 1 / -1;
}

.api-list {
  display: grid;
  gap: 10px;
}

.api-list code {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel);
  color: var(--accent-strong);
}

.modal,
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}

.modal.open,
.drawer.open {
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, 0.54);
}

.modal-card {
  position: relative;
  width: min(940px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: 14px auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.modal-head,
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-solid);
}

.modal-head h2,
.drawer-head h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 18px;
}

.coordinate-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(520px, 100%);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.detail-grid {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.detail-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.detail-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: none;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
  animation: liftIn 0.22s ease both;
}

.mobile-nav {
  display: none;
}

.mobile-theme-switch {
  display: none;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-solid);
  color: var(--text);
}

.marker-pin {
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.marker-pin span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform: rotate(45deg);
}

@media (max-width: 1120px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .customer-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-secondary-grid.admin-grid,
  .dashboard-secondary-grid.viewer-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 48vh;
    padding: 28px;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 14px;
    padding-bottom: 86px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }

  .page-title {
    min-width: 0;
    padding-right: 12px;
  }

  .mobile-theme-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .metrics,
  .customer-summary,
  .filters,
  .form-grid,
  .coordinate-panel,
  .mysql-grid {
    grid-template-columns: 1fr;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination-actions {
    justify-content: flex-start;
  }

  #map {
    min-height: 620px;
  }

  .map-tools {
    left: 12px;
    flex-direction: column;
  }

  .mobile-nav {
    position: fixed;
    z-index: 900;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
  }

  .mobile-nav.admin-mobile-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .mobile-nav.viewer-mobile-nav {
    left: 50%;
    right: auto;
    width: min(390px, calc(100% - 20px));
    transform: translateX(-50%);
    grid-template-columns: repeat(3, 1fr);
  }

  .mobile-nav button {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 10px 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .mobile-nav button.active {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
  }
}
