:root {
  --brand: #b4235a;
  --brand-dark: #8c1a45;
  --ink: #1d2433;
  --muted: #57606a;
  --line: #d0d7de;
  --bg: #fff8fa;
  --ok: #1a7f37;
  --danger: #cf222e;
}

body {
  background: var(--bg);
}

body .tw table {
  min-width: 0;
  font-size: 0.88rem;
}

body .tw th,
body .tw td {
  padding: 5px 6px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

body .tw th {
  white-space: nowrap;
}

body .tw th:first-child,
body .tw td:first-child {
  white-space: nowrap;
  overflow-wrap: normal;
}

#tk-rows td {
  vertical-align: top;
}

#tk-rows .tk-date-cell {
  display: block;
  font-weight: 600;
  white-space: nowrap;
}

#tk-rows .tk-memo-cell {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: normal;
}

#tk-rows .tk-amount-cell {
  white-space: nowrap;
  text-align: right;
}

#tk-rows .tk-del {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

main {
  max-width: 860px;
}

h1 {
  color: var(--brand-dark);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.planner {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 18px 0;
}

.planner h2 {
  margin-top: 0;
}

.listbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.listbar select {
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  max-width: 100%;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 12px;
  align-items: end;
}

.meta-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  font-weight: 600;
  gap: 4px;
}

.meta-grid input,
.meta-grid select {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
}

button {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.ghost {
  background: #fff;
  color: var(--brand-dark);
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 6px;
}

.summary div {
  background: #fff5f8;
  border: 1px solid #f3c6d6;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.summary span {
  font-size: 0.8rem;
  color: var(--muted);
}

.summary strong {
  font-size: clamp(0.95rem, 3.6vw, 1.2rem);
  overflow-wrap: anywhere;
}

.summary strong.negative {
  color: var(--danger);
}

.sum-status {
  margin: 6px 0 12px;
  font-weight: 600;
  color: #8b1a41;
}

#people-table input,
#people-table select {
  width: 100%;
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  box-sizing: border-box;
  background: #fff;
  min-width: 0;
}

#people-table td {
  text-align: left;
  vertical-align: middle;
  padding: 5px;
}

#people-table th {
  text-align: left;
  font-size: 0.82rem;
  padding: 5px;
  white-space: nowrap;
}

#people-table tr.over {
  outline: 2px solid var(--danger);
  outline-offset: -2px;
  background: #fff0f0;
}

#people-table td:nth-child(3) input,
#people-table td:nth-child(4) input {
  text-align: right;
}

#people-table .p-del {
  min-height: 38px;
  padding: 4px 8px;
  background: #fff;
  color: var(--danger);
  border-color: #f1b8bd;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px dashed var(--brand);
  border-radius: 8px;
  font-weight: 700;
  color: var(--brand-dark);
  cursor: pointer;
}

.file input {
  display: none;
}

#copy-out {
  width: 100%;
  min-height: 96px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

.notice {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--ok);
  font-weight: 600;
}

.notice.error {
  color: var(--danger);
}

.small {
  font-size: 0.85rem;
  color: var(--muted);
}

.steps li {
  margin: 0.4em 0;
}

.related-links {
  padding-left: 18px;
}

.related-links li {
  margin: 0.3em 0;
}

.aff-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 18px 0;
}

.aff-card ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aff-card a {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  text-decoration: none;
}

.aff-disc {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 6px 0 0;
}

.split-list {
  margin: 8px 0;
  padding-left: 22px;
}

.split-list li {
  margin: 2px 0;
}

.mono {
  font-variant-numeric: tabular-nums;
}

#tk-rows button,
#oc-upcoming {
  font-size: 0.9rem;
}

#tk-rows button {
  min-height: 36px;
  padding: 4px 8px;
  background: #fff;
  color: var(--danger);
  border-color: #f1b8bd;
}

@media (max-width: 620px) {
  #people-table thead {
    position: absolute;
    left: -9999px;
  }
  #people-table,
  #people-table tbody,
  #people-table tr,
  #people-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  #people-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    margin: 8px 0;
    background: #fff;
  }
  #people-table tr.over {
    border-color: var(--danger);
    outline: none;
  }
  #people-table td {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 3px 0;
  }
  #people-table td::before {
    content: attr(data-label);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
  }
  #people-table td:last-child {
    grid-template-columns: 1fr;
  }
  #people-table td:last-child::before {
    display: none;
  }
  #people-table .p-del {
    width: 100%;
  }
  #people-table td:nth-child(3) input,
  #people-table td:nth-child(4) input {
    text-align: left;
  }
  .tw table.cards,
  .tw table.cards thead,
  .tw table.cards tbody,
  .tw table.cards tr,
  .tw table.cards th,
  .tw table.cards td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  .tw table.cards thead {
    position: absolute;
    left: -9999px;
  }
  .tw table.cards tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 8px 0;
    padding: 8px 10px;
    background: #fff;
  }
  .tw table.cards tr > th:first-child {
    margin-bottom: 4px;
    font-size: 0.95rem;
    white-space: normal;
  }
  .tw table.cards td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    padding: 2px 0;
    text-align: left;
    border: none;
    white-space: normal;
  }
  .tw table.cards td::before {
    content: attr(data-label);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
  }
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .listbar button {
    flex: 1 1 auto;
  }
}
