:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #627184;
  --line: #d9e1ec;
  --panel: #ffffff;
  --panel-soft: #f6f8fb;
  --nav: #061f35;
  --blue: #1266d6;
  --blue-dark: #084d9a;
  --green: #168a45;
  --amber: #c77700;
  --red: #d92d20;
  --shadow: 0 12px 32px rgba(30, 45, 62, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #edf2f8;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: linear-gradient(180deg, #05233c, #031827);
  color: white;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid #2686ff;
  border-radius: 50%;
  color: #54a7ff;
  font-size: 28px;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 24px;
}

.brand span {
  display: block;
  color: #54a7ff;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #dcecff;
  text-decoration: none;
  padding: 14px 16px;
  border-radius: 8px;
}

nav a.active,
nav a:hover {
  background: #0c4f92;
}

.profile {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.profile span,
.profile small {
  color: #afc4d9;
}

main {
  margin-left: 260px;
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 380px) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.feeder-select,
.status-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.feeder-select span {
  color: var(--muted);
}

.feeder-select select {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.status-pill {
  color: var(--green);
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(420px, 1fr) 430px;
  gap: 12px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2 {
  font-size: 17px;
}

.panel-title button,
.segmented button {
  border: 1px solid var(--line);
  background: #f9fbfe;
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}

.segmented {
  display: flex;
  gap: 4px;
}

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

fieldset {
  margin: 0;
  padding: 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

legend {
  margin-bottom: 12px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #24364b;
  font-size: 14px;
  font-weight: 650;
}

.field-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.field-row input {
  min-width: 0;
  border: 0;
  padding: 9px 10px;
}

.field-row span {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

select {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

input[type="range"] {
  accent-color: var(--blue);
}

.slider-value {
  justify-self: end;
  color: var(--blue-dark);
}

.diagram-panel {
  min-height: 470px;
}

.diagram-wrap {
  padding: 20px;
}

svg {
  width: 100%;
  height: auto;
}

.bus,
.breaker,
.breaker-x,
.source,
.transformer,
.fuse {
  fill: none;
  stroke: #101820;
  stroke-width: 4;
}

.wave {
  fill: none;
  stroke: #101820;
  stroke-width: 3;
}

.arrow,
.fault-bolt,
.fault-dot {
  fill: var(--red);
}

.fault-stem {
  stroke: var(--red);
  stroke-width: 3;
  stroke-dasharray: 6 8;
}

.diagram-labels text {
  fill: #102033;
  font-size: 17px;
  font-weight: 650;
}

.toggle {
  display: flex;
  align-items: center;
  margin: 0;
}

.results {
  min-height: 470px;
}

#severityBadge {
  padding: 7px 11px;
  border-radius: 999px;
  background: #fff3cd;
  color: var(--amber);
  font-weight: 800;
  text-transform: capitalize;
}

#severityBadge.critical {
  background: #fee4e2;
  color: var(--red);
}

#severityBadge.normal {
  background: #dcfce7;
  color: var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.metric-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.metric-grid span,
.metric-grid small {
  color: var(--muted);
}

.metric-grid strong {
  display: block;
  margin: 6px 0 3px;
  color: var(--blue);
  font-size: 24px;
}

.recommendation {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 14px 14px;
  padding: 14px;
  border: 1px solid #bce5cb;
  border-radius: 8px;
  background: #f4fff8;
}

.check {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

table {
  width: calc(100% - 28px);
  margin: 0 14px 16px;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  background: var(--panel-soft);
}

.chart-panel {
  grid-column: span 2;
}

canvas {
  width: 100%;
  max-height: 360px;
  display: block;
  padding: 12px 18px 18px;
}

.details {
  min-height: 360px;
}

.details p {
  padding: 18px;
  color: var(--muted);
  line-height: 1.55;
}

dl {
  display: grid;
  gap: 0;
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

dl div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

dl div:last-child {
  border-bottom: 0;
}

dt,
dd {
  margin: 0;
  padding: 12px;
}

dt {
  background: var(--panel-soft);
  color: var(--muted);
}

dd {
  font-weight: 800;
}

@media (max-width: 1220px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  main {
    margin-left: 0;
  }

  .workspace,
  .topbar {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  main {
    padding: 12px;
  }

  .sidebar {
    padding: 18px;
  }

  nav {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .metric-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }
}
