:root {
  --green: #0e9f6e;
  --green-dark: #0a7d57;
  --green-bg: #e7f7f0;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6f5;
  --card: #fff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; }

header {
  background: var(--green-dark); color: #fff; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
header .ttl { font-weight: 700; font-size: 15px; }
header button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px; }

nav {
  display: flex; gap: 4px; overflow-x: auto; background: #fff;
  border-bottom: 1px solid var(--line); padding: 6px 10px;
  position: sticky; top: 44px; z-index: 19; -webkit-overflow-scrolling: touch;
}
nav button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 8px;
  white-space: nowrap; cursor: pointer; color: var(--muted); font-weight: 600;
}
nav button.on { background: var(--green-bg); color: var(--green-dark); }

main { max-width: 1080px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: 12px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 800; color: var(--green-dark); }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; }
tr:hover td { background: #fafcfb; }

.btn { background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--green-dark); }
.btn-sm { padding: 4px 10px; font-size: 12px; font-weight: 600; }
.btn-ghost { background: #fff; color: var(--green-dark); border: 1.5px solid var(--green); }
.btn-ghost:hover { background: var(--green-bg); }
.btn-danger { background: #fff; color: #b91c1c; border: 1.5px solid #fca5a5; }
.btn-danger:hover { background: #fef2f2; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input, .filters select {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--green); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--green); }

.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  display: none; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto;
}
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 560px; margin-top: 4vh; }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 11px; font-weight: 700; }
.badge.ok { background: var(--green-bg); color: var(--green-dark); }
.badge.off { background: #f3f4f6; color: #6b7280; }
.badge.warn { background: #fef3c7; color: #92400e; }

.login-bg { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: grid; place-items: center; padding: 16px; }
.login-box { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.login-box h1 { font-size: 18px; color: var(--green-dark); margin-bottom: 16px; text-align: center; }
.login-box input { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; font-size: 16px; margin-bottom: 12px; }
.login-box .btn { width: 100%; padding: 12px; }
.login-err { color: #b91c1c; font-size: 12px; margin-bottom: 8px; display: none; }

.qr-cell canvas, .qr-cell img { display: block; }
.muted { color: var(--muted); font-size: 12px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.price-row { display: grid; grid-template-columns: 1fr 90px 90px 34px; gap: 6px; margin-bottom: 6px; }
.price-row input { border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 10px; padding: 10px 18px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }
@media (max-width: 640px) {
  main { padding: 10px; }
  .stat .v { font-size: 18px; }
}
