:root {
  --ink: #14211e;
  --muted: #65756f;
  --line: #dce8e3;
  --paper: #f5f8f6;
  --white: #ffffff;
  --green: #23a66b;
  --teal: #0f8588;
  --cyan: #56c7d3;
  --navy: #17223b;
  --amber: #d79332;
  --red: #c84b4b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Inter", "Noto Sans KR", system-ui, sans-serif;
}

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

button, .primary {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 13px;
  color: var(--ink);
  background: var(--white);
  font-weight: 800;
  cursor: pointer;
}

button:hover { border-color: var(--teal); }

button.primary, .primary {
  border-color: transparent;
  color: #06231a;
  background: var(--cyan);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  color: var(--white);
  background: #081513;
  overflow-y: auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 800;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(86, 199, 211, 0.92), transparent 50%),
    linear-gradient(315deg, rgba(35, 166, 107, 0.92), transparent 52%);
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

.side-nav button {
  justify-content: flex-start;
  width: 100%;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  text-align: left;
}

.side-nav button.active,
.side-nav button:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
}

.workspace {
  min-width: 0;
  padding: 26px clamp(18px, 4vw, 54px) 54px;
}

.topbar,
.view-head,
.panel-top,
.account-box,
.form-actions,
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.3rem);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.18;
}

h3 {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.account-box {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.account-box span {
  padding-left: 8px;
  color: var(--muted);
  font-weight: 800;
}

.auth-panel {
  display: grid;
  grid-template-columns: 1fr 1.8fr;
  gap: 18px;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.auth-panel.hidden { display: none; }
.auth-copy p { margin-bottom: 0; color: var(--muted); }

.auth-form,
.form-panel {
  display: grid;
  gap: 12px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--white);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.switch-row input {
  width: 20px;
  height: 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-head {
  margin: 22px 0 18px;
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(240px, 1fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 8px;
  color: var(--white);
  background: #0c1715;
  overflow: hidden;
}

.hero-card img {
  width: 100%;
  min-height: 260px;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.hero-card div {
  display: grid;
  align-content: center;
  padding: 20px;
}

.hero-card span {
  color: var(--cyan);
  font-weight: 800;
}

.hero-card strong {
  display: block;
  margin: 6px 0 12px;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 1;
}

.hero-card p {
  max-width: 620px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.08rem;
  font-weight: 700;
}

.camera-panel {
  margin-bottom: 18px;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #0c1715;
  aspect-ratio: 16 / 9;
}

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

.camera-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: var(--white);
  background: rgba(8, 21, 19, 0.72);
  backdrop-filter: blur(10px);
}

.camera-overlay strong,
.camera-overlay span {
  font-size: 0.86rem;
  font-weight: 800;
}

.camera-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

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

.content-grid.two {
  grid-template-columns: minmax(280px, 0.8fr) minmax(300px, 1.2fr);
}

.sensor-card,
.panel,
.alert-list li,
.timeline article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.sensor-card {
  min-height: 118px;
  padding: 18px;
}

.sensor-card span,
.panel-top span,
.timeline time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.sensor-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.sensor-card.ok strong { color: var(--green); }
.sensor-card.warn strong { color: var(--amber); }
.sensor-card.danger strong { color: var(--red); }

.panel {
  min-height: 160px;
  padding: 20px;
}

.info-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  margin: 16px 0 0;
}

.info-list dt { color: var(--muted); font-weight: 800; }
.info-list dd { margin: 0; font-weight: 800; text-align: right; }

.item-list,
.alert-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 16px 0 0;
  list-style: none;
}

.item-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.item-list li:last-child { border-bottom: 0; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 320px;
  margin-top: 14px;
}

.pcb-panel {
  margin-top: 14px;
}

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

.live-refresh span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.pcb-sensor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.raw-payload {
  max-height: 240px;
  overflow: auto;
  margin: 16px 0 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #d9eeeb;
  background: #081513;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  color: #0e554b;
  background: #e4f6f1;
  font-size: 0.78rem;
  font-weight: 800;
}

.alert-list li {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.alert-list strong { color: var(--ink); }
.alert-list small { color: var(--muted); font-weight: 700; }
.alert-list .danger { color: var(--red); }
.alert-list .warn { color: var(--amber); }
.alert-list .ok { color: var(--green); }

.timeline {
  display: grid;
  gap: 12px;
}

.timeline article {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.timeline img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--paper);
}

.timeline p { margin-bottom: 0; color: var(--muted); font-weight: 600; }

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.82rem;
}

.insight-panel {
  margin-top: 14px;
}

.danger-zone {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 18px;
}

.danger-zone button:last-child {
  color: var(--red);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-nav button {
    text-align: center;
  }

  .hero-card,
  .auth-panel,
  .content-grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .view-head,
  .auth-panel,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .side-nav,
  .stat-grid,
  .content-grid,
  .pcb-sensor-grid {
    grid-template-columns: 1fr;
  }

  .hero-card img {
    min-height: 210px;
  }

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

  .camera-form,
  .camera-overlay {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .timeline article {
    grid-template-columns: 1fr;
  }
}
