:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --line: #e8e8e4;
  --text: #171816;
  --muted: #777973;
  --muted-2: #a0a19b;
  --accent: #252724;
  --green: #26845d;
  --red: #b84c4c;
  --amber: #a87529;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { width: min(100% - 56px, 960px); margin: 0 auto; }
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-size: 19px; font-weight: 650; letter-spacing: -.06em; text-decoration: none; }
.brand span { color: #777973; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.connection-state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.connection-state i, .device-led { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #b5b6b0; }
.pill-online { color: var(--green); }
.pill-online i, .device-led.online { background: var(--green); }
.pill-offline i { background: #b5b6b0; }
.text-button { padding: 5px 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.text-button:hover { color: var(--text); }

.login-layout { min-height: calc(100vh - 77px); display: grid; place-items: center; padding: 48px 0 80px; }
.login-form { width: min(100%, 350px); }
.section-label { margin: 0 0 13px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .13em; text-transform: uppercase; }
.login-form h1 { margin: 0; font-size: 29px; font-weight: 570; letter-spacing: -.055em; }
.login-copy { margin: 9px 0 30px; color: var(--muted); font-size: 13px; line-height: 1.6; }
label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
input {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px;
  color: var(--text); background: var(--surface); border: 1px solid #dcded8;
  border-radius: 7px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: #777d70; box-shadow: 0 0 0 3px rgba(45, 56, 39, .08); }
.button { min-height: 42px; padding: 0 17px; border: 1px solid var(--accent); border-radius: 7px; font-size: 12px; font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
.button-primary { color: white; background: var(--accent); }
.button-primary:hover { background: #41443f; border-color: #41443f; }
.login-form .button { width: 100%; margin-top: 12px; }
.form-message { min-height: 16px; margin: 12px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.5; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }

.dashboard { padding: 44px 0 28px; }
.dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.dashboard-heading .section-label { margin-bottom: 9px; }
.device-state-line { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.last-update { color: var(--muted-2); font-size: 11px; }
.main-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 56px; padding: 44px 0 42px; border-bottom: 1px solid var(--line); }
.clock-section .section-label, .alarm-section .section-label { margin-bottom: 15px; }
.device-clock { font-size: clamp(64px, 9vw, 92px); line-height: 1; font-weight: 480; letter-spacing: -.085em; font-variant-numeric: tabular-nums; }
.device-date { margin-top: 12px; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.clock-source { display: inline-block; margin-top: 25px; color: var(--muted-2); font-size: 10px; }
.alarm-section { align-self: center; padding-left: 42px; border-left: 1px solid var(--line); }
.alarm-title-row { display: flex; align-items: center; gap: 12px; }
.alarm-title-row .section-label { margin: 0; }
.alarm-state { color: var(--green); font-size: 9px; font-weight: 700; letter-spacing: .09em; }
.alarm-time { margin: 16px 0 20px; font-size: 52px; line-height: 1; font-weight: 500; letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.alarm-form { display: flex; align-items: center; gap: 8px; }
.alarm-form input { width: 132px; }
.alarm-form .button { flex: 0 0 auto; }
.helper-text { margin: 12px 0 0; color: var(--muted); font-size: 11px; }
.alarm-section .form-message { margin-top: 6px; }

.device-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding: 23px 0; border-bottom: 1px solid var(--line); }
.detail-item { display: grid; gap: 5px; min-width: 0; }
.detail-label { color: var(--muted-2); font-size: 10px; }
.detail-item strong { color: var(--text); font-size: 13px; font-weight: 600; }
.detail-item small { color: var(--muted); font-size: 10px; }
.history-section { padding-top: 36px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 14px; }
.section-heading .section-label { margin-bottom: 7px; }
.section-heading h2 { margin: 0; font-size: 21px; font-weight: 560; letter-spacing: -.045em; }
.history-list { display: grid; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 15px 2px; border-bottom: 1px solid var(--line); }
.history-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.history-icon { width: 22px; height: 22px; display: grid; place-items: center; flex: 0 0 auto; color: var(--green); border: 1px solid #d8e7dd; border-radius: 50%; font-size: 11px; }
.history-title { font-size: 12px; font-weight: 600; }
.history-sub { margin-top: 4px; color: var(--muted); font-size: 10px; }
.history-time { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-empty { padding: 18px 0; color: var(--muted); font-size: 12px; }
.dashboard-footer { display: flex; justify-content: space-between; gap: 14px; padding: 26px 0 0; color: var(--muted-2); font-size: 9px; letter-spacing: .07em; }
.toast { position: fixed; z-index: 10; bottom: 22px; left: 50%; max-width: calc(100% - 32px); padding: 11px 15px; color: white; background: #252724; border-radius: 7px; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .app-shell { width: min(100% - 36px, 560px); }
  .dashboard { padding-top: 30px; }
  .main-grid { grid-template-columns: 1fr; gap: 32px; padding: 34px 0; }
  .alarm-section { padding: 25px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .device-clock { font-size: clamp(62px, 18vw, 82px); }
  .device-details { gap: 12px; }
}
@media (max-width: 460px) {
  .app-shell { width: calc(100% - 32px); }
  .topbar { height: 64px; }
  .dashboard-heading { align-items: flex-start; }
  .last-update { max-width: 112px; text-align: right; line-height: 1.5; }
  .device-details { grid-template-columns: 1fr 1fr; row-gap: 20px; }
  .section-heading { align-items: flex-start; }
  .dashboard-footer { font-size: 8px; }
  .alarm-form { align-items: stretch; }
  .alarm-form input { width: 120px; }
}
