:root {
  --ink: #1b2420;
  --muted: #5e6b64;
  --line: #e3d9cc;
  --paper: #f3efe6;
  --card: #fffdf8;
  --green: #0f6a4c;
  --green-dark: #17352c;
  --green-soft: #e5f3ec;
  --red: #b42318;
  --red-soft: #fde8e6;
  --amber: #9a6700;
  --amber-soft: #fff4d6;
  --shadow: 0 12px 32px rgba(48, 38, 22, 0.06);
  --font: "Segoe UI", "Microsoft YaHei", sans-serif;
  --num: Bahnschrift, "Segoe UI", sans-serif;
  color: var(--ink);
  font-family: var(--font);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; font-size: 16px; }
button, .nav-btn, .lamp input { touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.boot { padding: 48px 20px; color: var(--muted); }

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(320px, 460px);
}
.login-aside {
  background:
    radial-gradient(circle at 20% 20%, rgba(229, 243, 236, 0.16), transparent 28%),
    var(--green-dark);
  color: #e7f6ef;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid rgba(231, 246, 239, 0.45);
  font-weight: 700;
  letter-spacing: 0;
}
.brand h1, .side-brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.02em; }
.brand p, .eyebrow { margin: 2px 0 0; color: #b7d2c6; font-size: 13px; }
.intro { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.intro li { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid rgba(231, 246, 239, 0.16); }
.intro b { font-size: 16px; }
.intro span { color: #d5eee4; font-family: var(--num); }
.intro em { font-style: normal; color: #b7d2c6; font-size: 13px; }
.login-aside .foot { color: #b7d2c6; font-size: 13px; line-height: 1.6; }
.login-panel { display: grid; align-content: center; padding: 36px 28px; background: var(--paper); }
.login-panel h2 { margin: 0 0 6px; font-size: 28px; }
.login-panel .lead { margin: 0 0 22px; color: var(--muted); }
.login-panel form, .stack { display: grid; gap: 12px; }

.field { display: grid; gap: 6px; }
.field span, .field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 12px;
}
.field textarea { height: 74px; padding: 8px 12px; resize: vertical; }
.field.wide { grid-column: 1 / -1; }

.btn {
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 14px;
}
.btn.primary { background: var(--green); border-color: var(--green); color: white; font-weight: 650; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #f0c2bd; background: white; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-row, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.error { color: var(--red); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; margin: 0; }
.note { color: var(--muted); font-size: 13px; line-height: 1.6; }
details.accounts-hint { margin-top: 18px; color: var(--muted); font-size: 13px; }
details.accounts-hint table { width: 100%; border-collapse: collapse; margin-top: 8px; }
details.accounts-hint td { padding: 4px 8px 4px 0; }

.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 220px 1fr; }
.side {
  background: var(--green-dark);
  color: #e7f6ef;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.side-brand h1 { font-size: 18px; }
.nav { display: grid; gap: 4px; }
.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: #d7eee4;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-btn.active { background: #e7f6ef; color: var(--green-dark); font-weight: 700; }
.badge {
  min-width: 20px;
  height: 20px;
  border-radius: 99px;
  background: var(--red);
  color: white;
  font-family: var(--num);
  font-size: 12px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}
.nav-btn.active .badge { background: var(--red); color: white; }
.side-foot { margin-top: auto; color: #b7d2c6; font-size: 12px; line-height: 1.6; padding: 0 8px; }

.main { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px 0;
}
.topbar h2 { margin: 0; font-size: 22px; }
.who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.who b { font-weight: 650; }
.who span { color: var(--muted); font-size: 13px; }
.content { padding: 16px 22px 40px; display: grid; gap: 14px; }

.banners { display: grid; gap: 8px; padding: 12px 22px 0; }
.banner {
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--amber-soft);
  color: #6d4a00;
  line-height: 1.5;
}
.banner.bad { background: var(--red-soft); color: var(--red); }
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 20;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 16px; }
.card.due { border-color: #efc3be; background: #fff8f7; }

.kpis, .today-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.today-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi, .today-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.kpi span, .today-card span { display: block; color: var(--muted); font-size: 13px; }
.kpi strong, .today-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--num);
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.kpi em, .today-card em { font-style: normal; color: var(--muted); font-size: 12px; }
.today-card.hot { border-color: #efc3be; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters .field { min-width: 160px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 0.85fr; gap: 14px; }
.chart-box { height: 280px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.pie-layout { display: grid; grid-template-columns: 180px 1fr; gap: 8px; align-items: center; }
.chart-box.pie { height: 220px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.legend li { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.area-line {
  display: grid;
  grid-template-columns: 108px 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}
.area-line span { color: var(--muted); font-size: 12px; margin-left: 6px; }
.bar { height: 8px; background: #f0eadf; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.area-line em { font-style: normal; color: var(--muted); min-width: 52px; text-align: right; font-family: var(--num); }

.table-wrap { overflow: auto; max-height: 460px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 650; position: sticky; top: 0; background: #fffdf8; }
.lamp-daily th { text-align: center; }
.lamp-daily thead tr:first-child th { top: 0; z-index: 2; }
.lamp-daily thead tr:nth-child(2) th { top: 33px; z-index: 2; }
.lamp-daily th.lamp-head { font-family: var(--num); color: var(--ink); font-size: 13px; min-width: 46px; }
.lamp-daily td.num { text-align: center; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
tr.alert td { background: var(--red-soft); color: var(--red); }
tr.today-row td { background: var(--green-soft); }

.tag {
  display: inline-block;
  border-radius: 99px;
  padding: 1px 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
}
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.areas { display: grid; gap: 12px; }
.area-card h3 { display: flex; justify-content: space-between; align-items: baseline; }
.area-card h3 b { font-family: var(--num); font-size: 18px; }
.lamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.lamp { display: grid; gap: 4px; justify-items: center; }
.lamp em { font-style: normal; color: var(--muted); font-family: var(--num); }
.lamp input {
  width: 100%;
  height: 54px;
  text-align: center;
  font-family: var(--num);
  font-size: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  scroll-margin-top: 76px;
  scroll-margin-bottom: 150px;
}
.lamp input.hot { border-color: #e7aaa4; background: var(--red-soft); color: var(--red); }
.lamp-state {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: white;
  color: var(--muted);
  font-size: 12px;
}
.lamp-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.lamp-state.fault { background: var(--red-soft); color: var(--red); border-color: #e7aaa4; font-weight: 700; }
.lamp-state.board { background: var(--green-soft, #e5f3ec); color: var(--green); border-color: #9dccb4; font-weight: 700; }
.hint { min-height: 16px; font-size: 11px; color: var(--amber); text-align: center; }
.point { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.point h4 { margin: 0; font-size: 15px; }
.point-group { margin: 16px 0 0; font-size: 14px; }
.choice { display: flex; gap: 8px; }
.choice .btn.on { background: var(--green); color: white; border-color: var(--green); }
.choice .btn.on.bad { background: var(--red); border-color: var(--red); }
.point-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.point-extra .wide, .point-extra .check { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.inspect-kpis { margin-top: 12px; }
.lamp input.hot + .hint, .hint.hot { color: var(--red); }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.submit-bar {
  position: sticky;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--green-dark);
  color: white;
}
.submit-bar span { color: #b7d2c6; margin-right: 8px; }
.submit-bar strong { font-family: var(--num); font-size: 32px; margin-right: 8px; }
.submit-bar .btn { background: transparent; color: white; border-color: rgba(255, 255, 255, 0.35); }
.submit-bar .btn.primary { background: white; color: var(--green-dark); border-color: white; min-width: 132px; font-weight: 700; }

.result { display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; align-items: center; }
.result strong { font-family: var(--num); font-size: 64px; line-height: 0.9; letter-spacing: -0.04em; color: var(--green); }
.result p { margin: 0; }
.result .label { color: var(--muted); }

.alert-list { display: grid; gap: 10px; }
.empty { color: var(--muted); margin: 8px 0; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 28, 0.35);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 15;
}
.modal-card { width: min(420px, 100%); display: grid; gap: 12px; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .grid-2 { grid-template-columns: 1fr 1fr; }
  .login { display: flex; flex-direction: column; min-height: 100dvh; }
  .login-panel { order: -1; align-content: start; padding: 28px 18px 12px; }
  .login-aside { padding: 8px 18px 24px; gap: 8px; }
  .login-aside .brand { display: none; }
  .intro { margin-top: 0; grid-template-columns: 1fr; }
  .pie-layout { grid-template-columns: 160px minmax(0, 1fr); }
  .filters .field { flex: 1 1 140px; min-width: 0; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .shell, .main, .side, .content, .card { max-width: 100%; }
  .side {
    position: sticky;
    top: 0;
    z-index: 8;
    width: 100%;
    overflow: hidden;
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
    gap: 0;
  }
  .side-brand, .side-foot { display: none; }
  .nav {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav { gap: 0; }
  .nav-btn { flex: 0 0 auto; white-space: nowrap; min-height: 44px; padding: 0 8px; font-size: 14px; }
  .topbar { flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px 0; }
  .topbar h2 { font-size: 18px; }
  .who { margin-left: auto; gap: 6px; }
  .who span { display: none; }
  .who .btn { height: 36px; padding: 0 10px; }
  .content, .banners { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; }
  .result { grid-template-columns: 1fr; }
  .result strong { font-size: 48px; }
  .area-line { grid-template-columns: minmax(0, 1fr) auto auto; }
  .area-line .bar { grid-column: 1 / -1; }
  .area-line div { min-width: 0; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .chart-box { height: 220px; }
  .toast { max-width: calc(100% - 24px); text-align: center; }
}
@media (max-width: 720px) {
  .submit-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    border-radius: 16px 16px 0 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .submit-bar .btn-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; }
  .submit-bar .btn { width: 100%; height: 46px; font-size: 14px; padding: 0 6px; }
  body.is-register .content { padding-bottom: calc(118px + env(safe-area-inset-bottom)); }
  body.is-register .toast { bottom: calc(118px + env(safe-area-inset-bottom)); }
  .grid-2 { grid-template-columns: 1fr; }
  .lamps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hint { font-size: 10px; line-height: 1.25; }
  .modal { padding: 12px; align-items: end; }
  .modal-card { width: 100%; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .row-actions input { width: 100%; height: 40px; }
}
@media (max-width: 360px) {
  .form-grid, .grid-2, .pie-layout { grid-template-columns: 1fr; }
  .lamps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-panel h2 { font-size: 24px; }
}
