:root {
  --green: #00845f;
  --green-dark: #00664d;
  --green-soft: #e7f6f1;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #d9e2e7;
  --bg: #f5f8fa;
  --panel: #ffffff;
  --red: #dc2626;
  --orange: #e66a00;
  --blue: #2563eb;
  --purple: #7c3aed;
  --shadow: 0 18px 40px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

html,
body {
  overflow-x: hidden;
}

button,
select,
a {
  font: inherit;
}

button,
select {
  border: 0;
}

button,
a.primary {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.platform {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 184px minmax(760px, 1fr) 316px;
}

.platform.no-inspector {
  grid-template-columns: 184px minmax(0, 1fr);
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand {
  height: 92px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  height: 42px;
  border: 2px solid var(--green);
  color: var(--green);
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.brand strong {
  display: block;
  font-size: 12px;
  line-height: 1.16;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.nav {
  padding: 16px 0;
}

.nav button {
  position: relative;
  width: 100%;
  min-height: 64px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: center;
  text-align: left;
  background: transparent;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.25;
}

.nav button.active {
  color: var(--green-dark);
  background: linear-gradient(90deg, rgba(0, 132, 95, 0.13), rgba(0, 132, 95, 0.03));
  font-weight: 750;
}

.nav button.active:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--green);
}

.quick {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}

.quick p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.quick button {
  width: 100%;
  min-height: 36px;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 9px;
  align-items: center;
  background: transparent;
  color: #4b5563;
  text-align: left;
  font-size: 11px;
}

.quick svg {
  width: 16px;
  height: 16px;
}

.quick b,
.top-status b {
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #d80000;
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
}

.updated {
  padding: 14px 18px 22px;
  color: var(--muted);
  font-size: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
}

.updated strong {
  color: var(--ink);
  font-size: 12px;
}

.updated i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.main {
  min-width: 0;
  background: var(--bg);
}

.topbar {
  height: 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) auto;
  gap: 18px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.top-status {
  display: flex;
  gap: 18px;
  align-items: center;
  color: #334155;
  font-size: 12px;
  white-space: nowrap;
}

.top-status span,
.top-status button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.top-status button {
  position: relative;
  background: transparent;
  color: #334155;
}

.top-status button b {
  position: absolute;
  right: -8px;
  top: -8px;
}

.top-status svg {
  width: 17px;
  height: 17px;
}

.user {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 0 !important;
}

.user small {
  color: var(--muted);
}

.command,
.module-page {
  padding: 10px;
}

.map-toolbar {
  min-height: 40px;
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
  z-index: 4;
}

.map-toolbar button,
.map-toolbar select,
.section-head button,
.primary,
.action-grid button,
.cctv-body button {
  min-height: 30px;
  border-radius: 5px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: #263238;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.map-toolbar .green,
.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.map-toolbar .live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.map-tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.twin-canvas {
  height: 535px;
  position: relative;
  overflow: hidden;
  background: #dce7e4;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  touch-action: none;
  cursor: grab;
  contain: layout paint;
}

.twin-canvas.fm {
  height: 430px;
  border-radius: 0 0 8px 8px;
}

.twin-canvas:active {
  cursor: grabbing;
}

.twin-stage {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  transform-style: preserve-3d;
  transition: transform 0.16s ease;
}

.twin-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  filter: saturate(1.04) contrast(1.02);
}

.twin-stage:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), transparent 36%, rgba(0,0,0,0.06));
  pointer-events: none;
}

.heatmap {
  position: absolute;
  width: 130px;
  height: 70px;
  border-radius: 50%;
  opacity: 0.72;
  filter: blur(8px);
  mix-blend-mode: multiply;
  pointer-events: none;
}

.heat-main {
  left: 44%;
  top: 38%;
  background: radial-gradient(circle, rgba(220,38,38,.75), rgba(234,179,8,.65), rgba(34,197,94,.3), transparent 70%);
}

.heat-icu {
  left: 47%;
  top: 48%;
  background: radial-gradient(circle, rgba(37,99,235,.45), rgba(34,197,94,.45), transparent 70%);
}

.heat-ncc {
  left: 74%;
  top: 34%;
  background: radial-gradient(circle, rgba(230,106,0,.58), rgba(250,204,21,.42), transparent 70%);
}

.building-marker,
.asset-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 3;
  background: transparent;
  border: 0;
}

.pin-icon {
  width: 31px;
  height: 31px;
  border-radius: 50% 50% 50% 5px;
  transform: rotate(-45deg);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  border: 2px solid #fff;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
}

.pin-icon svg {
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
}

.building-marker.major .pin-icon {
  background: var(--orange);
}

.building-marker.critical .pin-icon {
  background: var(--red);
}

.building-marker.selected .pin-icon {
  outline: 3px solid rgba(0, 132, 95, 0.25);
}

.building-marker .label {
  position: absolute;
  left: 50%;
  top: -58px;
  min-width: 118px;
  transform: translateX(-50%);
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.95);
  border: 1px solid #4b5563;
  color: #111827;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.asset-pin {
  min-width: 92px;
  padding: 7px 9px;
  color: #fff;
  background: var(--red);
  border: 2px solid #fff;
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(0,0,0,.25);
  text-align: left;
  font-size: 11px;
  font-weight: 800;
}

.asset-pin:not(.selected) {
  min-width: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50% 50% 50% 6px;
  transform: translate(-50%, -100%) rotate(-45deg);
}

.asset-pin:not(.selected) span,
.asset-pin:not(.selected) small {
  display: none;
}

.asset-pin:not(.selected):after {
  content: "!";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: rotate(45deg);
  font-size: 16px;
}

.asset-pin small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 650;
}

.asset-pin.major {
  background: var(--orange);
}

.asset-pin.info {
  background: var(--blue);
}

.asset-pin.selected {
  outline: 4px solid rgba(220,38,38,.25);
}

.campus-ground {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 8%;
  bottom: 8%;
  border-radius: 18px;
  transform-style: preserve-3d;
  background:
    radial-gradient(circle at 18% 25%, rgba(12, 116, 85, .18), transparent 20%),
    radial-gradient(circle at 72% 18%, rgba(12, 116, 85, .16), transparent 22%),
    linear-gradient(135deg, #d7e7df, #a9c8ba 42%, #dce9e4);
  box-shadow: 0 34px 70px rgba(15, 38, 31, .28), inset 0 0 0 2px rgba(255,255,255,.56);
}

.aerial-texture {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("assets/sgh-campus-aerial.png");
  background-size: cover;
  background-position: center;
  opacity: .34;
  filter: saturate(.9) contrast(.92);
}

.road {
  position: absolute;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(#728079, #586861);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 8px 16px rgba(0,0,0,.12);
}

.road:after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  border-top: 2px dashed rgba(255,255,255,.75);
}

.road-a { left: 3%; right: 2%; top: 76%; transform: rotate(-12deg); }
.road-b { left: 60%; right: -8%; top: 46%; transform: rotate(59deg); }
.road-c { left: -8%; right: 54%; top: 58%; transform: rotate(19deg); }

.skybridge {
  position: absolute;
  height: 18px;
  background: linear-gradient(90deg, rgba(255,255,255,.88), rgba(212,232,226,.95));
  border: 1px solid rgba(87, 112, 106, .45);
  box-shadow: 0 10px 16px rgba(0,0,0,.16);
}

.bridge-a { left: 46%; top: 54%; width: 19%; transform: rotate(-8deg); }
.bridge-b { left: 29%; top: 48%; width: 17%; transform: rotate(17deg); }

.tree {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(18px * var(--s));
  height: calc(18px * var(--s));
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6ecf7e, #1d7c45 58%, #0f4f31);
  box-shadow: 0 6px 8px rgba(0,0,0,.2);
}

.building3d {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--w) * 1%);
  height: calc(var(--d) * 1%);
  transform: translate(-50%, -50%) rotate(var(--r));
  transform-style: preserve-3d;
  border: 0;
  background: transparent;
  z-index: 3;
}

.building3d .block {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  filter: drop-shadow(18px 24px 12px rgba(20, 40, 34, .24));
}

.building3d .face {
  position: absolute;
  display: block;
  border: 1px solid rgba(92, 118, 112, .45);
  backface-visibility: visible;
}

.building3d .front {
  left: 0;
  bottom: 0;
  width: 100%;
  height: calc(var(--h) * 1px);
  transform-origin: bottom;
  transform: rotateX(-90deg) translateY(calc(var(--h) * -1px));
  background:
    repeating-linear-gradient(0deg, rgba(0,132,95,.16) 0 3px, transparent 3px 13px),
    repeating-linear-gradient(90deg, rgba(0,86,70,.13) 0 4px, transparent 4px 18px),
    linear-gradient(120deg, #ffffff, #dcece7);
}

.building3d .side {
  right: 0;
  bottom: 0;
  width: calc(var(--d) * 7px);
  height: calc(var(--h) * 1px);
  transform-origin: right bottom;
  transform: rotateY(90deg) rotateX(-90deg) translateY(calc(var(--h) * -1px));
  background: linear-gradient(120deg, #c6ddd6, #f7fbfa);
}

.building3d .roof {
  inset: 0;
  transform: translateZ(calc(var(--h) * 1px));
  background:
    radial-gradient(circle at 30% 35%, rgba(0,132,95,.22), transparent 14%),
    repeating-linear-gradient(90deg, rgba(80,100,96,.16) 0 8px, transparent 8px 18px),
    linear-gradient(135deg, #f8fbfa, #dceae6);
}

.building3d .facade {
  position: absolute;
  display: block;
  background: rgba(0,132,95,.12);
  border: 1px solid rgba(0,132,95,.18);
}

.building3d .facade-a { left: 18%; top: 15%; width: 18%; height: 68%; }
.building3d .facade-b { right: 18%; top: 18%; width: 20%; height: 60%; }

.building3d.selected .roof {
  outline: 4px solid rgba(0, 132, 95, .42);
  outline-offset: 2px;
}

.building3d.critical .roof {
  box-shadow: inset 0 0 0 4px rgba(220,38,38,.35);
}

.building3d.major .roof,
.building3d.warning .roof {
  box-shadow: inset 0 0 0 4px rgba(230,106,0,.32);
}

.building3d .pin-icon {
  position: absolute;
  left: 50%;
  top: -38px;
  z-index: 6;
}

.building3d.major .pin-icon,
.building3d.warning .pin-icon { background: var(--orange); }
.building3d.critical .pin-icon { background: var(--red); }

.building3d .label {
  position: absolute;
  left: 50%;
  top: -76px;
  z-index: 7;
  min-width: 118px;
  transform: translateX(-50%) rotate(calc(var(--r) * -1));
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,.96);
  border: 1px solid #4b5563;
  color: #111827;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.campus-ground .asset-pin {
  z-index: 9;
}

body.sunlight .campus-ground {
  filter: brightness(1.08) contrast(1.03);
}

.zoom-readout {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #475569;
  font-size: 11px;
  font-weight: 650;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.kpi {
  min-height: 86px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  position: relative;
}

.kpi div {
  position: absolute;
  right: 10px;
  bottom: 10px;
  color: #64748b;
}

.kpi label {
  display: block;
  color: #334155;
  font-size: 11px;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-size: 23px;
  line-height: 1;
}

.kpi:nth-child(3) strong,
.kpi:nth-child(4) strong {
  color: var(--red);
}

.kpi:nth-child(4) strong {
  color: var(--orange);
}

.kpi span {
  display: block;
  margin-top: 8px;
  color: #00845f;
  font-size: 10px;
}

.timeline-panel,
.data-card,
.drilldown {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.timeline-panel {
  margin-top: 10px;
  overflow-x: auto;
}

.section-head {
  min-height: 48px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head h2,
.module-head h2 {
  margin: 0;
  font-size: 16px;
}

.section-head span,
.module-head p {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tabs button {
  min-height: 24px;
  padding: 0 10px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--line);
  color: #334155;
  font-size: 11px;
}

.tabs button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.tabs b {
  margin-left: 5px;
  font-size: 9px;
  color: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

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

th {
  color: #64748b;
  font-weight: 700;
  background: #fbfdfe;
}

td small {
  color: var(--muted);
}

.badge,
.status {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
}

.badge.critical {
  color: var(--red);
  background: #fff1f1;
  border: 1px solid #fecaca;
}

.badge.major {
  color: var(--orange);
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.badge.info {
  color: var(--blue);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.badge.normal,
.status.closed,
.normal {
  color: var(--green);
}

.status.active {
  color: var(--red);
}

.status.in-progress,
.major {
  color: var(--orange);
}

.inspector {
  min-width: 0;
  background: #fff;
  border-left: 1px solid var(--line);
  min-height: 100vh;
  overflow: auto;
}

.asset-head {
  padding: 18px 12px 12px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.asset-head button {
  position: absolute;
  right: 12px;
  top: 13px;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  font-size: 22px;
}

.asset-head h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.asset-head p,
.asset-head small {
  display: block;
  margin: 8px 0 0;
  color: #475569;
  font-size: 12px;
}

.inspector-tabs {
  padding: 11px 12px 0;
}

.inspector-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
}

.inspector-tabs button.active {
  color: var(--green);
  background: transparent;
  border-bottom-color: var(--green);
}

.alert-card,
.inspector-card {
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.alert-card {
  padding: 14px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--red);
  background: #fff7f7;
  border-color: #fecaca;
}

.alert-card strong {
  display: block;
  font-size: 13px;
}

.alert-card span {
  display: block;
  margin-top: 4px;
  color: #475569;
  font-size: 11px;
  line-height: 1.35;
}

.card-title {
  min-height: 36px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #334155;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.card-title span {
  color: var(--muted);
  font-size: 10px;
}

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

.metric-grid div,
.status-grid span {
  min-height: 70px;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid label,
.status-grid span {
  color: #64748b;
  font-size: 10px;
}

.metric-grid strong,
.status-grid b {
  display: block;
  margin-top: 7px;
  color: var(--ink);
  font-size: 17px;
}

.metric-grid span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.good {
  color: var(--green) !important;
}

.bad {
  color: var(--red) !important;
}

.action-grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.action-grid button:first-child {
  color: var(--red);
  border-color: #fecaca;
}

.action-grid button:nth-child(2) {
  color: var(--green);
  border-color: #a7f3d0;
}

.related {
  min-height: 34px;
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: #475569;
  font-size: 11px;
}

.module-head {
  min-height: 68px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.fm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 10px;
}

.fm-twin {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.drilldown {
  padding: 14px;
}

.drilldown h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.path {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.path button {
  min-height: 34px;
  border-radius: 5px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #334155;
  text-align: left;
  padding: 0 10px;
  font-size: 12px;
}

.path button:after {
  content: "›";
  float: right;
  color: var(--muted);
}

.path button.critical {
  background: #fff1f1;
  color: var(--red);
  border-color: #fecaca;
}

.floor-stack {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.floor-stack button {
  min-height: 58px;
  border-radius: 5px;
  background: #fff;
  border: 1px solid var(--line);
  color: #334155;
  text-align: left;
  padding: 8px;
}

.floor-stack button.active {
  outline: 3px solid rgba(0, 132, 95, 0.16);
  border-color: var(--green);
}

.floor-stack button.critical {
  border-color: #fecaca;
}

.floor-stack b,
.floor-stack span {
  display: block;
}

.floor-stack span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.data-card {
  margin-top: 10px;
  overflow: hidden;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.analytics-grid.two {
  grid-template-columns: 1.25fr .75fr;
}

.chart-card {
  margin-top: 0;
}

.bars {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 142px 1fr 70px;
  gap: 10px;
  align-items: center;
}

.bar-row label {
  color: #334155;
  font-size: 11px;
  font-weight: 650;
}

.bar-row .track {
  height: 12px;
  border-radius: 999px;
  background: #e5edf0;
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #33b795);
}

.bar-row strong {
  font-size: 12px;
}

.bar-row small {
  grid-column: 2 / 4;
  margin-top: -6px;
  color: var(--muted);
  font-size: 10px;
}

.recommendation {
  padding: 14px;
  display: grid;
  gap: 9px;
}

.recommendation span {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 5px;
  background: #f0fdf7;
  border: 1px solid #bbf7d0;
  color: #065f46;
  font-size: 12px;
  font-weight: 650;
}

.trend-chart {
  height: 170px;
  padding: 12px;
}

.trend-chart svg {
  width: 100%;
  height: 100%;
}

.trend-chart polyline {
  fill: none;
  stroke: var(--red);
  stroke-width: 4;
}

.trend-chart .green-line {
  stroke: var(--green);
}

.trend-legend,
.history-list,
.wo-mini-list,
.checklist {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.trend-legend span,
.history-list button,
.wo-mini-list button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #334155;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
}

.wo-mini-list button {
  display: grid;
  gap: 3px;
}

.wo-mini-list button.active {
  border-color: var(--green);
  background: #effaf6;
}

.wo-mini-list span,
.wo-mini-list small {
  color: var(--muted);
}

.work-order-control {
  margin-top: 10px;
}

.workflow-line {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.workflow-line button {
  min-height: 72px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: #64748b;
  display: grid;
  place-items: center;
  gap: 4px;
  font-size: 11px;
}

.workflow-line b {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e5edf0;
}

.workflow-line button.done {
  color: var(--green);
  border-color: #b7ebd2;
  background: #f0fdf7;
}

.workflow-line button.done b {
  color: #fff;
  background: var(--green);
}

.workflow-line button.current {
  outline: 3px solid rgba(0,132,95,.18);
}

.wo-table tr {
  cursor: pointer;
}

.selected-row td {
  background: #f0fdf7;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, .42);
  display: grid;
  place-items: center;
  padding: 24px;
}

.wo-modal {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

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

.modal-head button,
.modal-actions button {
  min-height: 34px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
  font-weight: 750;
}

.wo-modal p {
  color: var(--muted);
  line-height: 1.45;
}

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

.modal-grid div {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px;
}

.modal-grid label {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.modal-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}

.checklist label {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions button:first-child {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

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

.cctv-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.06);
}

.cctv-card.selected {
  border-color: var(--red);
}

.image-wrap {
  position: relative;
  aspect-ratio: 16 / 8.2;
  background: #111827;
  overflow: hidden;
}

.image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.recording,
.box {
  position: absolute;
  z-index: 2;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.recording {
  left: 10px;
  top: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.52);
  padding: 5px 8px;
}

.box {
  color: #fff;
  background: rgba(220, 38, 38, 0.9);
  border: 2px solid rgba(255,255,255,.85);
  padding: 6px 9px;
}

.box-1 { left: 48%; top: 62%; }
.box-2 { left: 52%; top: 49%; }
.box-3 { left: 47%; top: 40%; }
.box-4 { left: 25%; top: 30%; }

.cctv-body {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.cctv-body h3 {
  margin: 0;
  font-size: 15px;
}

.cctv-body p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.detection {
  grid-column: 1 / 3;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.detection span {
  padding: 4px 8px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #334155;
  font-size: 10px;
  font-weight: 700;
}

.confidence {
  grid-column: 1 / 2;
  position: relative;
  min-height: 34px;
}

.confidence label {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.confidence b {
  color: var(--green);
  font-size: 16px;
}

.confidence:before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  border-radius: 999px;
  background: #e5edf0;
}

.confidence i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.cctv-body button {
  align-self: end;
  color: var(--green);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  background: #111827;
  color: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1280px) {
  .platform {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .brand {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .brand div:not(.brand-logo),
  .nav span,
  .quick,
  .updated {
    display: none;
  }

  .nav button {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0;
  }

  .inspector {
    display: none;
  }

  .kpi-strip {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 860px) {
  .platform {
    display: block;
  }

  .sidebar {
    min-height: 76px;
    display: block;
  }

  .brand {
    height: 72px;
    display: flex;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 0;
    border-top: 1px solid var(--line);
  }

  .nav button {
    min-height: 54px;
  }

  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .top-status {
    flex-wrap: wrap;
    gap: 10px;
  }

  .map-toolbar,
  .module-head,
  .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .map-tools {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .twin-canvas,
  .twin-canvas.fm {
    height: 430px;
  }

  .kpi-strip,
  .fm-layout,
  .analytics-grid,
  .analytics-grid.two,
  .cctv-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

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

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

  table {
    min-width: 720px;
  }

  .timeline-panel,
  .data-card {
    overflow-x: auto;
  }

  .bar-row small {
    grid-column: auto;
    margin-top: -4px;
  }
}
