:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d1d5db;
  --blue: #1d4ed8;
  --blue-dark: #1e3a8a;
  --green: #047857;
  --green-bg: #d1fae5;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber-bg: #fef3c7;
  --amber: #92400e;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 20px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  background: var(--blue); color: #fff;
  padding: .7rem 1rem; padding-top: calc(.7rem + env(safe-area-inset-top));
  min-height: 3.6rem;
}
.top h1 { font-size: 1.3rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px;
  font-size: 1.1rem; font-weight: 700; padding: .45rem .8rem; min-height: 2.75rem;
}
main { max-width: 640px; margin: 0 auto; padding: 1rem; }
h2 { font-size: 1.25rem; margin: 1.2rem 0 .6rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .9rem; }

.card {
  background: var(--card); border-radius: 14px; padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: .8rem;
  border: 2px solid transparent;
}
a.card { display: block; color: inherit; text-decoration: none; }
.card.done { border-color: var(--green); }
.machine, a.card.machine { display: flex; align-items: center; gap: .8rem; }
.machine .name { font-size: 1.4rem; font-weight: 800; }
.machine .info { flex: 1; min-width: 0; }
.machine .sub { color: var(--muted); font-size: 1rem; }
.badge {
  display: inline-block; padding: .4rem .8rem; border-radius: 999px; font-weight: 700; font-size: 1rem;
  white-space: nowrap;
}
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.todo { background: var(--blue); color: #fff; }

.summary { background: var(--blue-dark); color: #fff; text-align: center; }
.summary .label { font-size: 1rem; opacity: .9; }
.summary .big { font-size: 2.2rem; font-weight: 800; }
.summary .sub { font-size: 1rem; opacity: .9; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.summary .pos { color: #86efac; }
.summary .neg { color: #fca5a5; }

label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; font-weight: 700; margin-bottom: .3rem; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: .95rem; }
select { appearance: auto; }
input[type=text], input[type=date], input[type=time], input[type=password], input[type=tel], select {
  width: 100%; font-size: 1.6rem; padding: .7rem .8rem; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--text); font-family: inherit;
}
input[type=date], input[type=time], select { font-size: 1.2rem; min-height: 3.2rem; }
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,78,216,.25); }
input.small-in { font-size: 1.2rem; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px;
  font-size: 1.3rem; font-weight: 800; padding: 1rem; min-height: 3.6rem;
  background: var(--blue); color: #fff; text-align: center; text-decoration: none; font-family: inherit;
}
.btn:active { filter: brightness(.9); }
.btn.secondary { background: #fff; color: var(--blue); border: 2px solid var(--blue); }
.btn.danger { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn[disabled] { opacity: .5; }
.btn + .btn { margin-top: .7rem; }

.result { background: var(--card); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; border: 2px solid var(--line); }
.result .row { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; }
.result .row b { font-variant-numeric: tabular-nums; }
.result .zisk { font-size: 1.6rem; border-top: 2px solid var(--line); margin-top: .4rem; padding-top: .5rem; }
.warn { background: var(--amber-bg); color: var(--amber); border-radius: 12px; padding: .7rem .9rem; margin-bottom: 1rem; font-weight: 600; }
.err { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: .7rem .9rem; margin-bottom: 1rem; font-weight: 600; }
.prev { background: #e0e7ff; border-radius: 12px; padding: .7rem .9rem; margin-bottom: 1rem; }
.prev b { font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem 1rem; font-size: 1rem; }
.grid .k { color: var(--muted); }
.grid .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .4rem; }
.entry-head .d { font-weight: 800; }
.entry-head .z { font-size: 1.3rem; font-weight: 800; }
.linkbtn { background: none; border: 0; color: var(--blue); font-size: 1rem; font-weight: 700; padding: .5rem 0; text-decoration: underline; font-family: inherit; }

.daylist .r { display: flex; justify-content: space-between; padding: .35rem 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.daylist .r:first-child { border-top: 0; }
.daylist .r b { font-variant-numeric: tabular-nums; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: #fff; border-top: 2px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 4.4rem; color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 700;
}
.bottom a .ico { font-size: 1.5rem; line-height: 1.2; }
.bottom a.active { color: var(--blue); background: #eff6ff; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(4.2rem + env(safe-area-inset-top)); z-index: 20;
  background: #111827; color: #fff; padding: .8rem 1.2rem; border-radius: 12px; font-weight: 700;
  max-width: calc(100% - 2rem); text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.mset { display: grid; grid-template-columns: 1fr 6.5rem; gap: .5rem; align-items: end; }
.mset label { font-size: .9rem; color: var(--muted); font-weight: 700; }
