:root {
  --bg: #f6f4f4;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7684;
  --accent: #ea1917;
  --accent-dark: #c01413;
  --red: #ea1917;
  --border: #ddd8d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
}

header h1 { margin: 0; font-size: 1.25rem; }

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

footer {
  text-align: center;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

h2 { margin-top: 0; }
h3 { margin-bottom: 0.5rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red); font-weight: 500; }
.hidden { display: none !important; }

.branch-title {
  text-align: center;
  margin: 0;
}

.acr-line { margin: 0 0 0.75rem; }

input[type="text"], input:not([type]), input[type="number"], select {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  min-width: 0;
}

button {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  background: #eef1f4;
  color: var(--text);
}

button.primary { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
button.red { background: var(--red); border-color: var(--accent-dark); color: #fff; }
button.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
button.big { font-size: 1.15rem; padding: 0.8rem 2rem; }
button.link { background: none; border: none; color: var(--accent); text-decoration: underline; padding: 0; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

form.row-form, form.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
form.row-form input[type="text"] { flex: 1 1 12rem; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
td.indent { padding-left: 1.5rem; }
tr.group-head td {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border-bottom: none;
  padding-bottom: 0;
}

.copy-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.copy-row input {
  flex: 1 1 auto;
  font-size: 0.85rem;
  color: var(--muted);
}

.paper-list { list-style: none; padding: 0; margin: 0; }
.paper-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.qty-row label { color: var(--muted); }
.qty-row input {
  width: 4.5rem;
  text-align: center;
  font-weight: 700;
}

.counter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin: 0.75rem 0;
}
.counter-row button.round {
  font-size: 1.6rem;
  font-weight: 700;
  min-width: 4.5rem;
  min-height: 3.6rem;
  border-radius: 12px;
}
.counter-row button.round.minus { background: #4a545f; border-color: #3c454f; color: #fff; }
.counter-row button.round.plus { background: var(--accent); border-color: var(--accent-dark); color: #fff; }
#count {
  font-size: 2.6rem;
  font-weight: 800;
  min-width: 3ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-pair {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.75rem 0 0.25rem;
}
.btn-pair button.minus { background: #4a545f; border-color: #3c454f; color: #fff; }
.btn-pair button.plus { background: var(--accent); border-color: var(--accent-dark); color: #fff; }

table.mini-stats th:nth-child(n+2),
table.mini-stats td:nth-child(n+2),
.stats th:nth-child(n+3),
.stats td:nth-child(n+3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.self-row td {
  font-weight: 700;
  background: rgba(234, 25, 23, 0.07);
}

.issue-img {
  display: block;
  max-width: 100%;
  max-height: 40vh;
  margin: 0 auto 0.5rem;
  border-radius: 8px;
}
p.center { text-align: center; }
.issue-current img { max-width: 240px; max-height: 320px; border-radius: 8px; }
.issue-history {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.issue-history figure { margin: 0; }
.issue-history img {
  width: 90px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  opacity: 0.75;
}
.issue-history figcaption { font-size: 0.75rem; }

@media (max-width: 480px) {
  table.stats th:nth-child(3), table.stats td:nth-child(3) { white-space: nowrap; }
}
