:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --bg: #f3f6f3;
  --card: #ffffff;
  --text: #1f2a1f;
  --muted: #667066;
  --line: #dde5dd;
  --red: #c62828;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  padding-bottom: 76px;
}
h2 { margin: 6px 0 12px; font-size: 20px; }
h3 { margin: 16px 0 6px; font-size: 16px; }
.sub { font-size: 13px; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin: 2px 0 8px; }
.err { color: var(--red); min-height: 20px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--green); color: #fff;
  padding: 10px 16px;
}
.top .sub { color: #d7ecd8; }
.top .link { color: #fff; }

main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
input, select {
  display: block; width: 100%;
  margin-top: 4px;
  padding: 11px 10px;
  font-size: 16px;               /* 16px để iPhone không tự phóng to */
  border: 1px solid #c5d0c5;
  border-radius: 8px;
  background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid #81c784; border-color: var(--green); }

.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .row3 { grid-template-columns: 1fr; } }

.btn {
  display: block; width: 100%;
  background: var(--green); color: #fff;
  border: 0; border-radius: 10px;
  padding: 13px; font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.btn:active { background: var(--green-dark); }
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green); margin-top: 8px; }
.btn[disabled] { opacity: .6; }
.link {
  background: none; border: 0; padding: 4px 6px;
  color: var(--green); font-size: 14px; text-decoration: underline; cursor: pointer;
}
.badge {
  background: #fff3cd; color: #7a5b00;
  border: 1px solid #f0d98a; border-radius: 10px;
  padding: 1px 8px; font-size: 12px; cursor: pointer;
}

.list .item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 8px; align-items: flex-start;
}
.list .val { text-align: right; font-weight: 600; white-space: nowrap; }
.list .val .link, .list .val .badge { font-weight: 400; }

.mrow {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 6px; align-items: center;
  margin-bottom: 6px; font-size: 13px;
}
.mrow input { margin: 0; padding: 9px 6px; text-align: center; }
.mrow-head { font-size: 12px; color: var(--muted); text-align: center; }
.rack-title { font-weight: 600; margin: 10px 0 4px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { background: #eaf2ea; color: #35513a; }
td.num, th.num { text-align: right; }
.total { font-size: 26px; font-weight: 700; color: var(--green-dark); }

canvas { width: 100%; height: 190px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.legend { font-size: 13px; margin: 4px 0; }
.legend span { margin-right: 12px; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; border: 0; background: none;
  padding: 14px 2px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.nav button.on { color: var(--green); font-weight: 700; border-top: 3px solid var(--green); padding-top: 11px; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }
.login h1 { color: var(--green); margin-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #263326; color: #fff; padding: 10px 16px;
  border-radius: 20px; font-size: 14px; max-width: 90%;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }
