:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #f3f7fb;
  color: #182b41;
  --muted: #476178;
  --line: #d9e4ee;
  --soft: #eaf2fa;
  --blue: #1b5074;
  --mono: "IBM Plex Mono", ui-monospace, "Consolas", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
p { line-height: 1.5; }
h2 { font-size: 1.5rem; letter-spacing: -.027em; line-height: 1.22; }
h3 { font-size: 1.375rem; letter-spacing: -.027em; line-height: 1.22; }
h4 { font-size: .9375rem; line-height: 1.35; }
.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.main { padding-block: 20px 38px; }

.hero {
  --banner-art: url("/capstone-banner.png");
  position: relative;
  overflow: hidden;
  background: linear-gradient(105deg, #081d36 0%, #0a2a4d 64%, #0a2844 100%);
  color: #fff;
}
.hero-inner {
  width: min(1600px, 100%);
  min-height: clamp(320px, 27.625vw, 442px);
  margin-inline: auto;
  padding: clamp(20px, 2.15vw, 34px) clamp(24px, 4.25vw, 68px);
  position: relative;
  display: flex;
  align-items: center;
}
.hero-copy { position: relative; z-index: 1; }
.hero-logos {
  width: auto;
  height: clamp(60px, 8.25vw, 132px);
  aspect-ratio: 300 / 132;
  margin-left: -.75rem;
  background-image: var(--banner-art);
  background-repeat: no-repeat;
  background-size: auto 334.849%;
  background-position: 1.385% 6.452%;
  mask-image: radial-gradient(ellipse 68% 73% at center, #000 60%, transparent 100%);
}
.hero h1 {
  margin-top: 7px;
  font-size: clamp(3.05rem, 7vw, 7rem);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -.035em;
}
.hero-subtitle {
  margin-top: 5px;
  font-size: clamp(1.65rem, 3.8vw, 3.8rem);
  line-height: 1.13;
}
.hero-name {
  margin-top: 9px;
  font-size: clamp(1.06rem, 2.1vw, 2.1rem);
  line-height: 1.25;
}
.hero-nim { margin-top: 3px; color: #bed7ed; font-size: clamp(.9rem, 1.32vw, 1.3rem); }
.hero-art {
  position: absolute;
  inset: 0 0 0 auto;
  width: 47%;
  background-image: var(--banner-art);
  background-repeat: no-repeat;
  background-size: auto 100%;
  background-position: right center;
  mask-image: linear-gradient(to right, transparent 0%, #000 23%);
}
@media (max-width: 640px) {
  .hero-inner { display: block; min-height: 0; padding: 21px 24px 0; }
  .hero-logos { height: 66px; margin-left: -.35rem; }
  .hero h1 { font-size: clamp(2.5rem, 11vw, 3.8rem); }
  .hero-subtitle { font-size: clamp(1.45rem, 6.5vw, 2rem); }
  .hero-art {
    position: relative;
    inset: auto;
    width: min(calc(100% + 24px), 390px);
    aspect-ratio: 7 / 4;
    margin: -4px -24px 0 auto;
    mask-image: linear-gradient(to right, transparent, #000 21%);
  }
}

.toolbar, .section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 15px; }
.toolbar { margin-bottom: 12px; }
.back-link { min-height: 44px; display: inline-flex; align-items: center; color: var(--blue); font-size: .875rem; font-weight: 670; text-decoration: underline; text-underline-offset: 4px; }
.server-state { margin-left: auto; color: var(--muted); font-size: .8125rem; }
.server-state[data-state="offline"], .server-state[data-state="forbidden"] { color: #774229; }
.section-head { justify-content: space-between; }
.section-head p, .device-ip { color: var(--muted); margin-top: 4px; font-size: .875rem; }
.button { display: inline-flex; flex: none; align-items: center; justify-content: center; min-height: 44px; padding: 8px 13px; font-size: .875rem; font-weight: 670; border-radius: 7px; line-height: 1.25; }
.secondary { color: var(--blue); border: 1px solid #c9dae8; background: #fff; }
.secondary:hover:not(:disabled), .device-row:hover .device-action { background: var(--soft); border-color: #a2bfd4; }
.button:disabled { opacity: .75; }

.directory-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, .46fr); gap: 26px; align-items: start; }
.directory-grid:has(.setup[hidden]) { grid-template-columns: minmax(0, 1fr); }
.device-list { display: grid; gap: 9px; }
.device-list:empty { display: none; }
.empty, .device-row { display: flex; align-items: center; gap: 13px; border-radius: 10px; padding: 15px; }
.empty { min-height: 102px; border: 1px solid var(--line); background: #fff; }
.empty h3 { font-size: 1rem; }
.empty p { color: var(--muted); margin-top: 4px; font-size: .875rem; }
.device-row { background: #fff; border: 1px solid var(--line); min-height: 82px; }
.device-row:hover { border-color: #a2bfd4; }
.row-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.device-name, .device-ip { display: block; }
.device-icon, .dashboard-icon { display: inline-grid; flex: none; place-items: center; border-radius: 9px; }
.device-icon { width: 42px; height: 42px; color: var(--blue); background: var(--soft); }
.chip { width: 15px; height: 15px; display: block; position: relative; border: 1.5px solid currentColor; border-radius: 3px; }
.chip::before, .chip::after {
  content: ""; position: absolute; inset: 2px -4px; background: currentColor;
  clip-path: polygon(0 0, 3px 0, 3px 100%, 0 100%, 0 66%, 100% 66%, 100% 100%, calc(100% - 3px) 100%, calc(100% - 3px) 0, 100% 0, 100% 33%, 0 33%);
}
.chip::after { transform: rotate(90deg); }

.setup { background: var(--soft); border: 1px solid #d6e5f1; border-radius: 11px; padding: 19px; }
.setup h2 { font-size: 1.13rem; }
.sign-in { display: grid; gap: 7px; margin-top: 12px; }
.sign-in label { font-size: .875rem; font-weight: 650; }
.sign-in input { min-width: 0; min-height: 44px; padding: 8px 10px; background: #fff; color: inherit; border: 1px solid #7994aa; border-radius: 6px; }
.sign-in button { justify-self: start; margin-top: 4px; }
.sign-in-error { color: #7d301f; font-size: .875rem; }
.sign-in-error:empty { display: none; }

.dashboard-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 21px 25px; border-radius: 12px; border: 1px solid #d6e5f1; background: var(--soft); }
.dashboard-identity { display: flex; align-items: center; gap: 15px; min-width: 0; }
.dashboard-icon { width: 49px; height: 49px; color: #f1fbff; background: var(--blue); }
.dashboard-identity h2 { font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.045em; line-height: 1.1; overflow-wrap: anywhere; }
.dashboard-identity p { font-size: .875rem; color: var(--muted); margin-top: 5px; }
.dashboard-connection { display: grid; justify-items: end; gap: 6px; flex: none; }
.state-badge { display: inline-flex; align-items: center; gap: 7px; flex: none; width: max-content; padding: 4px 8px; border: 1px solid #cfe3d4; color: #1e5d3f; background: #edf7ed; border-radius: 6px; font-weight: 660; font-size: .8125rem; line-height: 1.35; }
.state-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state-badge[data-state="offline"] { color: #774229; background: #f7eee4; border-color: #eedfd4; }
.last-update { color: var(--muted); font: .8125rem var(--mono); }
.notice { border: 1px solid #e9dbc7; background: #faf3e6; color: #724a24; padding: 12px 14px; line-height: 1.5; border-radius: 8px; margin-top: 15px; font-size: .875rem; }

.dashboard-section { margin-top: 24px; }
.dashboard-section > h3, .control-head { margin-bottom: 12px; }
.metrics, .statuses { display: grid; gap: 12px; }
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.statuses { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric, .sensor-status { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 14px 15px; }
.reading { display: flex; align-items: baseline; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.reading-value { font: 650 clamp(1.35rem, 3.3vw, 2.22rem) var(--mono); letter-spacing: -.055em; overflow-wrap: anywhere; }
.unit { color: var(--muted); font-size: .875rem; }
.state-value { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; margin-top: 10px; }
.state-value::before { content: ""; width: 9px; height: 9px; flex: none; border: 2px solid #71899e; border-radius: 50%; }
.state-value[data-active="true"] { color: #1e5d3f; }
.state-value[data-active="true"]::before { border-color: currentColor; background: currentColor; }

.control-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.control-head p { color: var(--muted); font-size: .875rem; }
.controls { background: #fff; border: 1px solid var(--line); border-radius: 9px; overflow: clip; }
.controls table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.controls th, .controls td { padding: 5px 15px; text-align: left; }
.controls thead { background: var(--soft); color: #375670; font-size: .8125rem; }
.controls thead th { padding-block: 10px; }
.controls tbody tr { border-top: 1px solid var(--line); }
.controls tbody th { font-weight: 650; font-size: .9375rem; }
.control-button { min-width: 44px; min-height: 44px; padding: 4px 0; display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: #274d69; font-size: .8125rem; text-align: left; }
.control-button[aria-disabled="true"] { color: var(--muted); cursor: default; }
.control-button:focus-visible { outline-offset: -1px; }
.toggle { width: 32px; height: 18px; display: inline-flex; flex: none; align-items: center; padding: 2px; border-radius: 30px; background: #71899e; }
.toggle::before { content: ""; display: block; width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.control-button[aria-checked="true"] .toggle { justify-content: end; background: var(--blue); }
.control-button[aria-disabled="true"] .toggle { opacity: .65; }

.footer { padding-block: 15px 23px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 850px) {
  .statuses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory-grid { gap: 16px; }
}
@media (max-width: 660px) {
  .shell { width: calc(100% - 32px); }
  .main { padding-block: 12px 30px; }
  .directory-grid { grid-template-columns: minmax(0, 1fr); }
  .device-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 7px; }
  .device-action { grid-column: 2 / -1; justify-self: end; }
  .dashboard-head { align-items: flex-start; padding: 16px; flex-wrap: wrap; gap: 9px; }
  .dashboard-connection { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .dashboard-icon { width: 38px; height: 38px; }
}
@media (max-width: 410px) {
  .metric, .sensor-status { padding: 11px 9px; }
  .metrics, .statuses { gap: 7px; }
  h4 { font-size: .875rem; }
  .controls th, .controls td { padding-inline: 6px; }
  .controls tbody th { font-size: .875rem; }
  .control-button { gap: 4px; }
  .toggle { width: 25px; }
}
@media (max-width: 360px) {
  .metrics { grid-template-columns: minmax(0, 1fr); }
}
