:root {
  --accent: #2f855a;
  --accent-dark: #276749;
  --accent-soft: #e6f4ec;
  --bg: #f4f6f5;
  --card: #ffffff;
  --border: #e2e8e4;
  --border-strong: #cbd5d0;
  --text: #1c2521;
  --muted: #5f6f66;
  --danger: #b83232;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(28, 37, 33, 0.06), 0 4px 12px rgba(28, 37, 33, 0.05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem 0.85rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  margin: 0 0 0.6rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--accent-dark);
  max-width: 720px;
  margin-inline: auto;
}

nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 0 auto;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover { background: var(--accent-soft); color: var(--accent-dark); }

.tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 0.75rem;
}

h2 + h2, .panel h2:not(:first-child) { margin-top: 1.75rem; }

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 1.5rem 0 0.5rem;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

input, select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  max-width: 10rem;
}

input:focus-visible, select:focus-visible, button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 550;
  font-family: inherit;
  transition: background 0.15s ease;
}

button:hover { background: var(--accent-dark); }

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid currentColor;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

button.danger:hover { background: #fdf0ef; }

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

button.secondary:hover { background: var(--bg); color: var(--text); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}

th, td {
  text-align: left;
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafcfb; }

td.num, th.num { text-align: right; }

.message {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: #fdecea;
  color: #7a1f1f;
  border: 1px solid #f2c2be;
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.message.ok {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: #bfe3cb;
}

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0; }

.totals {
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.goalbar {
  background: var(--border);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
  margin-top: 0.25rem;
}

.goalbar > div {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.goalbar > div.over { background: var(--danger); }

.import-label { margin-top: 1rem; }

@media (max-width: 480px) {
  main { padding-inline: 0.75rem; }
  .panel { padding: 1rem; }
  input, select { max-width: 100%; width: 100%; }
  label { width: 100%; }
  form button { width: 100%; }
}

/* Session bar (remote mode) */
#session-bar {
  max-width: 720px;
  margin: 0.5rem auto 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}
#session-bar button { font-size: 0.85rem; }
