:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", sans-serif;
  background: #07110d;
  color: #edf7f1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(42, 177, 108, .15), transparent 34rem),
    #07110d;
}

button, input { font: inherit; }

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.topbar,
.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions form { margin: 0; }

h1, h2, p { margin: 0; }
h1 { margin-top: 5px; font-size: clamp(2rem, 6vw, 3.5rem); letter-spacing: -.05em; }
h2 { margin-top: 5px; font-size: 1.45rem; }

.eyebrow {
  color: #77d9a5;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.status-dot,
.device-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #244537;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #47db8c;
  box-shadow: 0 0 12px #47db8c;
  content: "";
}

.sensor-grid,
.control-grid {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

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

.metric,
.control-card,
.system-note,
.alert {
  border: 1px solid #1b342a;
  border-radius: 22px;
  background: rgba(14, 29, 23, .86);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .2);
}

.metric { padding: 26px; }
.metric span { color: #9db2a8; font-size: .9rem; }
.metric strong { display: block; margin-top: 14px; font-size: clamp(2.8rem, 8vw, 5.4rem); letter-spacing: -.06em; }
.metric-small { grid-column: 1 / -1; }
.metric-small strong { font-size: 1.2rem; letter-spacing: 0; }

.control-card { padding: 24px; }
.warning-card { border-color: #4b3820; }

.device-state.on { border-color: #22734c; background: #123b29; color: #65e4a1; }
.device-state.off { color: #9db2a8; }

.notice {
  min-height: 48px;
  margin-top: 18px;
  color: #ddc395;
  font-size: .88rem;
  line-height: 1.55;
}

.actions { margin-top: 22px; }
.actions form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button {
  min-height: 48px;
  border: 1px solid #315043;
  border-radius: 13px;
  background: #14271f;
  color: #eaf6ef;
  cursor: pointer;
  font-weight: 800;
}

button:hover { filter: brightness(1.2); }
button.primary { border-color: #238e59; background: #1f764c; }
button.danger { border-color: #9d523b; background: #773c2d; }
button:disabled { cursor: not-allowed; opacity: .55; }
.install-button { min-height: 38px; padding: 7px 13px; }
.install-button[hidden] { display: none; }
.logout-button { min-height: 38px; padding: 7px 13px; }
.hardware-notice { color: #e7a98f; }
.hardware-notice.ready { color: #77d9a5; }
.temporary-password { border-color: #a8692c; }
.temporary-password strong { color: #ffc56d; }
.success-alert { border-color: #22734c; }
.success-alert strong { color: #65e4a1; }

.pump-section { margin-top: 28px; }
.pump-card { max-width: 720px; }

.policy-section {
  margin-top: 18px;
}

.policy-overview,
.policy-panel {
  border: 1px solid #1b342a;
  border-radius: 22px;
  background: rgba(14, 29, 23, .86);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .2);
}

.policy-overview { padding: 24px; }
.policy-panel { padding: 22px; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.policy-caption {
  color: #82998e;
  font-size: .8rem;
}

.policy-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.summary-item {
  display: grid;
  gap: 7px;
  padding: 14px 16px;
  border: 1px solid #244036;
  border-radius: 14px;
  background: #0a1712;
}

.summary-item span { color: #82998e; font-size: .75rem; font-weight: 700; }
.summary-item strong { font-size: .95rem; }
.summary-item strong.safe { color: #65e4a1; }
.summary-item strong.warning { color: #ffc56d; }
.summary-item strong.muted { color: #a0afa8; }

.policy-form { margin-top: 14px; }
.settings-group + .settings-group { margin-top: 14px; }

.group-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #20372d;
}

.group-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #2a5d47;
  border-radius: 10px;
  background: #113524;
  color: #77d9a5;
  font-size: .72rem;
  font-weight: 900;
}

.group-heading h3 { margin: 0; font-size: 1rem; }
.group-heading p { margin-top: 3px; color: #82998e; font-size: .78rem; }

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

.settings-grid.single-setting { grid-template-columns: minmax(0, 1fr); }

.setting-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  padding: 17px 18px;
  border: 1px solid #243d33;
  border-radius: 15px;
  background: #0b1914;
  transition: border-color .18s ease, background .18s ease;
}

.setting-card:hover { border-color: #35634f; background: #0d1d17; }
.setting-copy { display: grid; gap: 6px; }
.setting-copy strong { color: #edf7f1; font-size: .94rem; }
.setting-copy small { max-width: 40rem; color: #8fa198; font-size: .78rem; line-height: 1.45; }

.setting-control {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.policy-state {
  color: #65e4a1;
  font-size: .7rem;
  font-weight: 900;
  white-space: nowrap;
}

.policy-state.warning { color: #ffc56d; }

.toggle-wrap {
  display: inline-flex;
  cursor: pointer;
}

.toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle {
  position: relative;
  width: 50px;
  height: 28px;
  border: 1px solid #385348;
  border-radius: 999px;
  background: #1a2a23;
  transition: .18s ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #91a69c;
  content: "";
  transition: .18s ease;
}

.toggle-input:checked + .toggle {
  border-color: #238e59;
  background: #1f764c;
}

.toggle-input:checked + .toggle::after {
  transform: translateX(22px);
  background: #effff6;
}

.toggle-input:focus-visible + .toggle { outline: 3px solid rgba(71, 219, 140, .35); }

.setting-card-runtime { grid-column: 1 / -1; }
.runtime-field {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 2px;
  padding-top: 13px;
  border-top: 1px solid #20372d;
  color: #91a69c;
  font-size: .8rem;
  font-weight: 700;
}

.runtime-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c7d7cf;
}

.runtime-box input {
  width: 92px;
  min-height: 40px;
  border: 1px solid #315043;
  border-radius: 10px;
  background: #07110d;
  color: #edf7f1;
  padding: 0 12px;
  text-align: right;
  font-weight: 800;
}

.inline-badge {
  justify-self: start;
  border: 1px solid #594627;
  border-radius: 999px;
  padding: 4px 7px;
  color: #ddc395;
  font-size: .64rem;
  font-weight: 800;
}

.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 16px 16px 16px 20px;
  border: 1px solid #28513f;
  border-radius: 20px;
  background: rgba(14, 33, 24, .94);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}

.save-bar p { color: #91a69c; font-size: .8rem; }
.save-policy {
  min-width: 180px;
  border-color: #238e59;
  background: #1f764c;
}

.system-note,
.alert {
  margin-top: 16px;
  padding: 20px 22px;
  line-height: 1.6;
}

.login-shell {
  width: min(440px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.login-card {
  width: 100%;
  padding: 30px;
  border: 1px solid #1b342a;
  border-radius: 24px;
  background: rgba(14, 29, 23, .94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
}

.login-brand {
  width: 72px;
  height: 72px;
  border-radius: 18px;
}

.login-card h1 { margin-top: 18px; font-size: 2rem; }
.login-copy { margin-top: 8px; color: #9db2a8; line-height: 1.6; }
.login-form { display: grid; gap: 16px; margin-top: 26px; }
.login-form label { display: grid; gap: 8px; color: #c6d7ce; font-size: .9rem; font-weight: 700; }
.login-form input {
  width: 100%;
  min-height: 50px;
  border: 1px solid #315043;
  border-radius: 13px;
  background: #0a1712;
  color: #edf7f1;
  padding: 0 14px;
}
.login-form button { margin-top: 4px; }
.login-error { margin-top: 18px; color: #ffb19b; line-height: 1.5; }

.system-note strong { color: #78dba7; }
.system-note p, .alert span { margin-top: 5px; color: #a9bbb2; }
.alert { border-color: #7b3e36; }

@media (max-width: 700px) {
  .shell { padding-top: 28px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .sensor-grid, .control-grid { grid-template-columns: 1fr; }
  .metric-small { grid-column: auto; }
  .policy-section { padding: 0; }
  .policy-overview, .policy-panel { padding: 18px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .policy-summary { grid-template-columns: 1fr; }
  .summary-item { display: flex; align-items: center; justify-content: space-between; }
  .settings-grid { grid-template-columns: 1fr; }
  .setting-card-runtime { grid-column: auto; }
  .setting-card { min-height: 96px; padding: 15px; }
  .save-bar { align-items: stretch; flex-direction: column; }
  .save-policy { width: 100%; }
}
