:root {
  color-scheme: light;
  --ink: #20342c;
  --muted: #718078;
  --paper: #f5f7f2;
  --card: rgba(255, 255, 255, 0.86);
  --green: #167052;
  --green-deep: #105b43;
  --green-soft: #e2f1e9;
  --cream: #f1eee6;
  --danger: #aa453b;
  --danger-soft: #f8eae7;
  --line: rgba(32, 52, 44, 0.11);
  --shadow: 0 20px 60px rgba(36, 57, 47, 0.10);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 4%, rgba(244, 211, 142, 0.25), transparent 27rem),
    radial-gradient(circle at 2% 42%, rgba(94, 167, 132, 0.15), transparent 31rem),
    linear-gradient(180deg, #fbfcf8 0%, var(--paper) 72%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 30px; border: 1px solid rgba(255,255,255,.9); border-radius: 28px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-brand { margin-bottom: 48px; }
.login-heading h1 { font-size: 48px; }
.login-heading > p:last-child { margin: 14px 0 26px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-form label { display: block; margin: 14px 0 7px; font-size: 12px; font-weight: 750; }
.login-form input { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; color: var(--ink); background: #fff; outline: none; }
.login-form input:focus { border-color: rgba(22,112,82,.48); box-shadow: 0 0 0 3px rgba(22,112,82,.08); }
.login-form .primary-button { margin-top: 8px; }
.login-form button:disabled { cursor: wait; opacity: .7; }
.login-error { min-height: 20px; margin: 9px 0 0; color: var(--danger); font-size: 12px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 15px; color: var(--muted); font-size: 11px; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.authentik-button { display: block; padding: 13px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: #fff; text-align: center; text-decoration: none; font-size: 13px; font-weight: 750; }
.authentik-button:hover { background: var(--cream); }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
}
.ambient-one { width: 300px; height: 300px; right: -90px; top: -95px; background: rgba(244, 210, 140, .12); }
.ambient-two { width: 380px; height: 380px; left: -230px; top: 35%; background: rgba(83, 152, 117, .10); }

.shell { width: min(1120px, 100%); margin: 0 auto; padding: 28px 30px 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #277d60, #145e46);
  box-shadow: 0 8px 22px rgba(22, 112, 82, .22);
  font-family: "Songti SC", serif;
  font-size: 20px;
  font-weight: 700;
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  box-shadow: 0 6px 20px rgba(29, 54, 43, .05);
  font-size: 13px;
  font-weight: 700;
}
.refresh-button:hover { background: #fff; transform: translateY(-1px); }
.refresh-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: end;
  gap: 30px;
  padding: 76px 0 48px;
}
.eyebrow, .section-kicker { margin: 0 0 9px; color: #b37835; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font: 700 clamp(46px, 6vw, 72px)/.98 "Songti SC", "STSong", serif; letter-spacing: -.06em; }
.subtitle { max-width: 560px; margin: 18px 0 0; color: var(--muted); font-size: 15px; line-height: 1.75; }

.summary-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 20px;
  background: rgba(255,255,255,.68);
  box-shadow: 0 12px 35px rgba(31, 53, 44, .07);
  backdrop-filter: blur(16px);
}
.summary-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--green-soft); }
.summary-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 6px rgba(22,112,82,.10); }
.summary-copy strong, .summary-copy span { display: block; }
.summary-copy strong { font-size: 13px; }
.summary-copy span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.summary-card time { color: var(--ink); font: 600 20px/1 Georgia, serif; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.section-heading h2 { font: 700 25px/1.15 "Songti SC", serif; letter-spacing: -.03em; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.section-kicker { margin-bottom: 5px; }
.device-heading { margin-top: 2px; }

.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.device-card {
  position: relative;
  overflow: hidden;
  min-height: 345px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.device-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -76px;
  top: -82px;
  border-radius: 50%;
  background: rgba(221, 185, 111, .13);
}
.device-card.is-online { border-color: rgba(126, 189, 158, .30); }
.device-top { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 14px; }
.device-identity { display: flex; align-items: flex-start; gap: 13px; min-width: 0; }
.device-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: var(--green); background: var(--green-soft); }
.device-icon svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.device-name { overflow: hidden; max-width: 250px; text-overflow: ellipsis; white-space: nowrap; font: 700 23px/1.15 "Songti SC", serif; }
.machine-name { display: block; overflow: hidden; max-width: 250px; margin-top: 5px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font: 10px/1.3 ui-monospace, SFMono-Regular, monospace; }
.device-status { position: relative; z-index: 1; flex: none; text-align: right; }
.device-status small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 11px; font-weight: 800; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.offline { color: #7c817d; background: #eceeea; }

.schedule-display { margin: 34px 0 29px; }
.schedule-display small { color: var(--muted); font-size: 11px; }
.schedule-time { margin-top: 4px; font: 600 48px/.98 Georgia, "Times New Roman", serif; letter-spacing: -.055em; }
.schedule-days { margin-top: 9px; color: var(--muted); font-size: 12px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 750;
  transition: transform .16s ease, box-shadow .16s ease;
}
.card-button:hover { transform: translateY(-1px); }
.card-button span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 7px; background: rgba(255,255,255,.18); font-size: 10px; }
.card-button.primary { color: #fff; background: linear-gradient(145deg, #227b5d, var(--green-deep)); box-shadow: 0 8px 22px rgba(22,112,82,.18); }
.card-button.secondary { color: var(--ink); background: var(--cream); }
.card-button.danger { color: var(--danger); background: var(--danger-soft); }
.card-button.full { grid-column: 1 / -1; }
.cancel-button { grid-column: 1 / -1; justify-self: center; margin-top: 2px; padding: 5px 10px; border: 0; color: var(--muted); background: transparent; font-size: 11px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.cancel-button:hover { color: var(--ink); text-decoration-color: currentColor; }
.empty-card { grid-column: 1 / -1; padding: 62px 24px; border: 1px dashed rgba(32,52,44,.18); border-radius: 26px; color: var(--muted); background: rgba(255,255,255,.38); text-align: center; }
.empty-card strong { display: block; color: var(--ink); font-size: 17px; }
.empty-card p { margin: 8px 0 0; font-size: 13px; }

.activity-section { margin-top: 48px; }
.activity-list { overflow: hidden; border: 1px solid rgba(255,255,255,.86); border-radius: 20px; background: rgba(255,255,255,.54); box-shadow: 0 10px 30px rgba(36,57,47,.05); }
.activity-item { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-item .dot { width: 7px; height: 7px; border-radius: 50%; background: #c78a43; }
.activity-item p { margin: 0; font-size: 13px; }
.activity-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.activity-item > small { margin: 0; font-size: 11px; }
.activity-empty { padding: 24px 18px; color: var(--muted); font-size: 13px; text-align: center; }
footer { padding: 42px 0 5px; color: #98a199; font-size: 10px; letter-spacing: .08em; text-align: center; }

.sheet { width: min(500px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border: 0; padding: 0; border-radius: 26px; color: var(--ink); background: #fffdfa; box-shadow: 0 30px 90px rgba(21, 35, 29, .28); }
.sheet::backdrop { background: rgba(23, 37, 31, .47); backdrop-filter: blur(6px); }
.sheet form { padding: 13px 26px 27px; }
.sheet-handle { width: 40px; height: 4px; margin: 0 auto 18px; border-radius: 5px; background: #d7dad5; }
.sheet-title { display: flex; align-items: flex-start; justify-content: space-between; }
.sheet h2 { margin-bottom: 18px; font: 700 28px/1.15 "Songti SC", serif; }
.close-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--ink); background: #f0f1ed; font-size: 21px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-block: 1px solid var(--line); }
.toggle-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.toggle-row input { width: 22px; height: 22px; accent-color: var(--green); }
.field-label, legend { display: block; margin: 17px 0 8px; font-size: 12px; font-weight: 750; }
.time-input, .text-input, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; color: var(--ink); background: #fff; outline: none; }
.time-input:focus, .text-input:focus, select:focus { border-color: rgba(22,112,82,.48); box-shadow: 0 0 0 3px rgba(22,112,82,.08); }
.time-input { font: 600 29px/1 Georgia, serif; }
fieldset { border: 0; padding: 0; margin: 0; }
.weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekday-picker label { display: grid; place-items: center; }
.weekday-picker input { position: absolute; opacity: 0; }
.weekday-picker span { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 50%; background: #eff1ed; font-size: 12px; }
.weekday-picker input:checked + span { color: #fff; background: var(--green); box-shadow: 0 5px 15px rgba(22,112,82,.18); }
.primary-button, .danger-button, .secondary-button { width: 100%; border: 0; border-radius: 14px; padding: 14px; margin-top: 19px; font-weight: 800; }
.primary-button { color: #fff; background: linear-gradient(145deg, #227b5d, var(--green-deep)); }
.danger-button { color: #fff; background: var(--danger); }
.secondary-button { margin-top: 7px; color: var(--muted); background: transparent; }
.compact-sheet form { text-align: center; }
.compact-sheet .field-label { text-align: left; }
.danger-mark { display: grid; place-items: center; width: 58px; height: 58px; margin: 5px auto 16px; border-radius: 18px; color: var(--danger); background: var(--danger-soft); font: 700 21px "Songti SC", serif; }
.compact-sheet p { color: var(--muted); font-size: 13px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 26px; transform: translate(-50%, 22px); padding: 11px 17px; border-radius: 999px; color: #fff; background: var(--ink); box-shadow: 0 12px 35px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transition: .22s ease; white-space: nowrap; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .shell { padding: max(20px, env(safe-area-inset-top)) 18px 46px; }
  .hero { grid-template-columns: 1fr; gap: 26px; padding: 54px 0 38px; }
  .summary-card { width: 100%; }
  .device-grid { grid-template-columns: 1fr; }
  .device-card { min-height: 335px; }
  .section-heading > span { display: none; }
  .activity-section { margin-top: 40px; }
  .sheet { margin-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .refresh-button span { display: none; }
  .refresh-button { width: 40px; height: 40px; justify-content: center; padding: 0; }
  .hero { padding-top: 47px; }
  h1 { font-size: 52px; }
  .subtitle { font-size: 14px; }
  .device-card { padding: 20px; border-radius: 23px; }
  .device-icon { width: 40px; height: 40px; }
  .device-name { max-width: 175px; font-size: 21px; }
  .machine-name { max-width: 175px; }
  .schedule-time { font-size: 45px; }
  .weekday-picker { gap: 3px; }
  .weekday-picker span { width: 35px; height: 35px; }
  .sheet form { padding-inline: 20px; }
}

@media (max-width: 360px) {
  .device-icon { display: none; }
  .device-name, .machine-name { max-width: 160px; }
  .card-button { font-size: 12px; padding-inline: 8px; }
}
