:root {
  --bg: #f6f7f9; --card: #fff; --text: #16181d; --muted: #5b6270; --line: #dfe2e8;
  --accent: #1d4ed8; --accent-text: #fff; --warn-bg: #fff4d6; --warn-text: #6b4800;
  --stop-bg: #fde2e1; --stop-text: #8a1c14; --ok: #137a3a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --card: #1b1e24; --text: #e9ebef; --muted: #a2a9b6; --line: #2d323b;
    --accent: #6d9bff; --accent-text: #0b0d10; --warn-bg: #3d3010; --warn-text: #ffd98a;
    --stop-bg: #44191a; --stop-text: #ffb4ae; --ok: #5fd08a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top, 0) 0 calc(64px + env(safe-area-inset-bottom, 0));
}
[hidden] { display: none !important; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }

.top {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
main { max-width: 760px; margin: 0 auto; padding: .5rem 16px 1.5rem; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: .78rem;
  padding: .85rem .1rem; min-height: 52px; cursor: pointer;
}
.tabs button.active { color: var(--accent); font-weight: 600; box-shadow: inset 0 3px 0 var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: .75rem 0; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

.banner { margin: .5rem 16px 0; padding: .7rem 1rem; border-radius: 10px; font-weight: 500; }
.banner.warning { background: var(--warn-bg); color: var(--warn-text); }
.banner.stopped { background: var(--stop-bg); color: var(--stop-text); }

button, .button {
  font: inherit; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: .65rem 1rem; min-height: 44px; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: .4rem; min-height: 0; }
button:disabled { opacity: .55; cursor: default; }

label { display: block; font-weight: 500; margin: .9rem 0 .3rem; }
.help { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem;
}
textarea { min-height: 6rem; resize: vertical; }
input[type="checkbox"] { width: auto; transform: scale(1.3); margin-right: .5rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.msg { min-height: 1.4em; margin-top: .6rem; }
.msg.error { color: var(--stop-text); }
.msg.ok { color: var(--ok); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 360px; }
.login button { width: 100%; margin-top: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem; }
.stat b { display: block; font-size: 1.3rem; }
.meter { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: .5rem 0; }
.meter > div { height: 100%; background: var(--accent); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }

.save-bar {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0)); background: var(--bg);
  padding: .6rem 0; border-top: 1px solid var(--line);
}
