:root {
    --bg: #07131f;
    --panel: #0f1d2b;
    --card: #13283a;
    --muted: #9db0c4;
    --text: #eef7ff;
    --accent: #38bdf8;
    --accent2: #22c55e;
    --warn: #f59e0b;
    --bad: #ef4444;
    --border: rgba(255, 255, 255, .12);
    --shadow: 0 18px 50px rgba(0, 0, 0, .28)
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: var(--bg);
    color: var(--text)
}

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden
}

.side-panel {
    width: 430px;
    max-width: 92vw;
    background: linear-gradient(180deg, #102033, #07131f);
    border-right: 1px solid var(--border);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    transition: transform .32s ease, width .32s ease
}

.side-panel.collapsed {
    transform: translateX(-100%)
}

.panel-head {
    padding: 18px 18px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px
}

.eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: #7dd3fc
}

.panel-head h1,
.modal-head h2 {
    margin: 3px 0 0;
    font-size: 25px
}
.category-legend {
  position: absolute;
  right: 4px;
 top: 55px;
  z-index: 1000;
  width: 270px;
  max-height: 55vh;
  overflow: hidden;
  background: rgba(18, 30, 40, 0.94);
  backdrop-filter: blur(14px);
  color: #eef6ff;
  border-radius: 18px;
  box-shadow: 0 16px 45px rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 9px 8px;
}

.legend-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.legend-head button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: white;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.category-legend-body {
  padding: 4px 16px 16px;
  overflow-y: auto;
  max-height: calc(55vh - 55px);
}

.category-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.category-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: linear-gradient(135deg, #34d5f4, #087c8d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 23px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.category-name {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
}

.category-count {
  font-size: 17px;
  color: #c7d5e4;
  font-weight: 700;
}

.category-legend.collapsed .category-legend-body {
  display: none;
}

.category-legend.collapsed {
  width: auto;
}

@media (max-width: 768px) {
  .category-legend {
    right: 10px;
    bottom: 18px;
    width: 230px;
    max-height: 42vh;
  }

  .category-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
    border-radius: 13px;
  }

  .category-name,
  .category-count {
    font-size: 14px;
  }

  .legend-head h3 {
    font-size: 15px;
  }
}
.icon-btn {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .08);
    color: var(--text);
    border-radius: 12px;
    width: 38px;
    height: 38px;
    font-size: 22px;
    cursor: pointer
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .16)
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 8px 16px 14px
}

.metrics div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, .055)
}

.metrics b {
    display: block;
    font-size: 21px
}

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

.toolbar {
    padding: 0 16px 12px;
    display: grid;
    gap: 9px;
    grid-template-columns: 1fr 1fr
}

.toolbar input {
    grid-column: 1/-1
}

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

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--accent)
}

.cards {
    overflow: auto;
    padding: 0 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 11px
}

.project-card {
    border: 1px solid var(--border);
    background: linear-gradient(145deg, rgba(19, 40, 58, .95), rgba(8, 25, 40, .95));
    border-radius: 20px;
    padding: 13px;
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 12px;
    cursor: pointer;
    transition: .2s ease
}

.project-card:hover {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, .55)
}

.project-card.active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, .25), 0 16px 34px rgba(56, 189, 248, .12)
}

.thumb {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 27px;
    background: radial-gradient(circle at top left, #38bdf8, #0f766e 58%, #0f172a);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25)
}

.card-title {
    font-weight: 800;
    font-size: 14px;
    line-height: 1.25
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px
}

.pill {
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 8px;
    color: #dbeafe;
    background: rgba(255, 255, 255, .06)
}

.progress-line {
    height: 8px;
    background: #07131f;
    border-radius: 99px;
    overflow: hidden;
    margin-top: 9px
}

.progress-line span {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, #38bdf8, #22c55e)
}

.map-wrap {
    position: relative;
    flex: 1;
    min-width: 0
}

#map {
    height: 100%;
    width: 100%;
    background: #091827
}

.map-title {
    position: absolute;
    top: 3px;
    left: 6px;
    z-index: 700;
    background: rgba(7, 19, 31, .84);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px 16px;
    box-shadow: var(--shadow)
}

.map-title span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px
}

.chart-btn {
    position: absolute;
    right: 3px;
    top: 6px;
    z-index: 700;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #04374e, #04374e);
    color: white;
    font-weight: 800;
    padding: 13px 16px;
    box-shadow: var(--shadow);
    cursor: pointer
}

.chart-btn:disabled {
    filter: grayscale(1);
    opacity: .55;
    cursor: not-allowed
}

.legend {
    position: absolute;
    bottom: 20px;
    right: 4px;
    z-index: 700;
    background: rgba(7, 19, 31, .86);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 13px 14px;
    font-size: 12px;
    line-height: 1.8;
    box-shadow: var(--shadow)
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 7px
}

.good {
    background: var(--accent2)
}

.mid {
    background: var(--warn)
}

.low {
    background: var(--bad)
}

.open-panel-btn {
    display: none;
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 1200;
    border: 0;
    border-radius: 14px;
    background: #0f1d2b;
    color: #fff;
    padding: 12px 14px;
    box-shadow: var(--shadow);
    cursor: pointer
}

.custom-pin {
    width: 44px;
    height: 44px;
    border-radius: 16px 16px 16px 4px;
    transform: rotate(-45deg);
    display: grid;
    place-items: center;
    border: 3px solid #fff;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .35);
    transition: .2s
}

.custom-pin .pin-icon {
    transform: rotate(45deg);
    font-size: 22px
}

.pin-good {
    background: #22c55e
}

.pin-mid {
    background: #f59e0b
}

.pin-low {
    background: #ef4444
}

.selected-pin .custom-pin {
    transform: rotate(-45deg) scale(1.22);
    box-shadow: 0 0 0 6px rgba(56, 189, 248, .28), 0 16px 30px rgba(0, 0, 0, .45)
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(1, 7, 13, .72);
    backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    z-index: 2000;
    padding: 22px
}

.hidden {
    display: none
}

.modal-card {
    width: min(1120px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 26px;
    box-shadow: var(--shadow)
}

.modal-head {
    padding: 20px 22px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    border-bottom: 1px solid #dbe4ee
}

.modal-head .icon-btn {
    background: #e2e8f0;
    color: #0f172a
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px
}

.chart-box {
    min-height: 250px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .08)
}

.chart-box:last-child {
    grid-column: 1/-1
}
.gauge-row {
  display: flex;
  gap: 18px;
  width: 100%;
}

.gauge-box {
  flex: 1;
  min-width: 0;
  height: 260px;
}

@media (max-width: 700px) {
  .gauge-row {
    flex-direction: column;
  }

  .gauge-box {
    height: 240px;
  }
}
@media(max-width:900px) {
    .side-panel {
        position: absolute;
        height: 100%;
        width: 88vw
    }

    .open-panel-btn {
        display: block
    }

    .map-title {
        top: 72px;
        left: 12px;
        right: 12px
    }

    .chart-btn {
        top: auto;
        right: 12px;
        bottom: 118px
    }

    .legend {
        right: 12px;
        bottom: 16px
    }

    .chart-grid {
        grid-template-columns: 1fr
    }

    .chart-box:last-child {
        grid-column: auto
    }

    .toolbar {
        grid-template-columns: 1fr
    }

    .panel-head h1 {
        font-size: 22px
    }
}