* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #f6f5ef;
  color: #243e37;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  line-height: 1.65;
}
header {
  border-bottom: 1px solid #dedfd5;
  padding: 22px max(5vw, 20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fffefa;
}
.brand {
  font-size: 23px;
  font-weight: 750;
  text-decoration: none;
  color: #215c50;
}
.brand span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.07em;
}
main {
  max-width: 1080px;
  margin: auto;
  padding: 40px 22px;
}
.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}
h1 {
  font-size: clamp(25px, 4vw, 38px);
  letter-spacing: -0.05em;
  margin: 6px 0;
}
h2 {
  font-size: 21px;
  margin-top: 28px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.17em;
  color: #658076;
}
p {
  color: #64746c;
}
small {
  color: #67776d;
}
aside {
  padding: 12px 18px;
  background: #edeedd;
  border-radius: 10px;
  margin: 24px 0;
  font-size: 13px;
}
nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #dce0d6;
  padding-bottom: 14px;
  margin-bottom: 26px;
}
button,
.button {
  background: #fffefa;
  color: #285347;
  border: 1px solid #cdd7cb;
  border-radius: 9px;
  padding: 10px 15px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: inline-block;
}
button:hover,
.button:hover {
  background: #e8eee5;
}
nav .active,
button[type='submit'],
#add {
  background: #215c50;
  color: white;
  border-color: #215c50;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card {
  background: #fffefa;
  border: 1px solid #e0e4d8;
  border-radius: 18px;
  padding: 24px;
}
.card.primary {
  background: #215c50;
  color: white;
}
.card.primary p,
.card.primary small {
  color: #d7e4dc;
}
.amount {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 12px 0;
}
.warning {
  background: #fff0df;
  color: #82552d;
  border-left: 3px solid #c08d50;
  padding: 14px 18px;
  margin: 18px 0;
}
.chart {
  height: 150px;
  width: 100%;
  display: block;
}
.chartbox {
  background: #fffefa;
  border-radius: 18px;
  padding: 24px;
  margin: 20px 0;
}
.chart text {
  font-size: 11px;
  fill: #63786d;
}
.tablewrap {
  overflow: auto;
  max-height: 470px;
  border-radius: 12px;
  border: 1px solid #e0e4d8;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fffefa;
  white-space: nowrap;
}
th,
td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid #edf0e5;
}
th {
  position: sticky;
  top: 0;
  background: #edf0e5;
}
td:last-child {
  text-align: right;
}
.negative {
  color: #a24a32;
}
.row {
  padding: 16px;
  background: #fffefa;
  border: 1px solid #e0e4d8;
  border-radius: 12px;
  margin: 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.row p {
  font-size: 12px;
  margin: 3px 0;
}
.row .actions {
  flex-shrink: 0;
}
.sectionhead,
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.sectionhead {
  justify-content: space-between;
}
input,
select {
  font: inherit;
  border: 1px solid #cbd5c8;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  max-width: 100%;
  width: 100%;
  color: #243e37;
}
label {
  display: block;
  font-size: 13px;
}
label input,
label select {
  margin: 4px 0 14px;
}
.top input {
  margin: 0;
}
.danger {
  color: #a24a32;
}
dialog {
  border: 0;
  border-radius: 18px;
  box-shadow: 0 15px 80px #1235;
  width: min(460px, 95vw);
  max-height: 90vh;
  color: #243e37;
}
dialog::backdrop {
  background: #18352c66;
}
footer {
  font-size: 11px;
  color: #778579;
  margin-top: 40px;
}
#message {
  font-size: 13px;
}
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #edf0e5;
}
a {
  color: #215c50;
}
[hidden] {
  display: none !important;
}
@media (max-width: 650px) {
  header {
    padding: 17px 20px;
  }
  header small {
    font-size: 10px;
  }
  .brand {
    font-size: 20px;
  }
  main {
    padding: 25px 16px;
  }
  .top {
    display: block;
  }
  .top label {
    margin-top: 18px;
    max-width: 180px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 20px;
  }
  .amount {
    margin: 4px 0;
  }
  nav {
    gap: 4px;
    overflow: auto;
  }
  nav button {
    white-space: nowrap;
    padding: 9px;
    font-size: 12px;
  }
  .row {
    align-items: flex-start;
    flex-direction: column;
  }
  .row .actions {
    width: 100%;
  }
} /* Keep the forecast readable without sideways scrolling. */
.tablewrap {
  overflow-x: hidden;
}
table {
  table-layout: fixed;
  white-space: normal;
}
th,
td {
  overflow-wrap: anywhere;
  vertical-align: top;
}
th:nth-child(1) {
  width: 12%;
}
th:nth-child(2) {
  width: 43%;
}
th:nth-child(n + 3) {
  width: 15%;
}
td:nth-child(n + 3) {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 700px) {
  .tablewrap {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
  }
  .tablewrap table,
  .tablewrap tbody {
    display: block;
    background: transparent;
  }
  .tablewrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .tablewrap tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 8px;
    margin-bottom: 12px;
    padding: 16px;
    background: #fffefa;
    border: 1px solid #e0e4d8;
    border-radius: 14px;
  }
  .tablewrap td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .tablewrap td:first-child {
    grid-column: 1/-1;
    font-weight: 750;
    font-size: 16px;
    margin-bottom: 6px;
  }
  .tablewrap td:nth-child(2) {
    grid-column: 1/-1;
    line-height: 1.65;
    color: #64746c;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf0e5;
    font-size: 12px;
  }
  .tablewrap td:nth-child(n + 3) {
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -0.03em;
  }
  .tablewrap td:nth-child(n + 3)::before {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #64746c;
    letter-spacing: 0;
    margin-bottom: 4px;
  }
  .tablewrap td:nth-child(3)::before {
    content: '入金・借入';
  }
  .tablewrap td:nth-child(4)::before {
    content: '支出・返済';
  }
  .tablewrap td:nth-child(5)::before {
    content: '日末残高';
  }
}
/* Keep long editors inside the available viewport. */
#editor {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(460px, calc(100% - 24px));
  max-width: calc(100% - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  background: #fffefa;
}
#editor #form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  min-height: 0;
  margin: 0;
}
#editTitle {
  flex: none;
  margin: 0;
  padding: 18px 20px 14px;
  font-size: 20px;
  border-bottom: 1px solid #e0e4d8;
  overflow-wrap: anywhere;
}
#fields {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 0;
  scroll-padding-block: 16px;
}
#fields label {
  min-width: 0;
  overflow-wrap: anywhere;
}
#fields input,
#fields select {
  min-width: 0;
  max-width: 100%;
  font-size: 16px;
}
#form > .actions {
  flex: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid #e0e4d8;
  background: #fffefa;
}
#form > .actions button {
  min-height: 44px;
  flex: 1;
}
body:has(#editor[open]) {
  overflow: hidden;
}
@media (max-height: 420px) {
  #editTitle {
    padding: 10px 16px;
    font-size: 17px;
  }
  #fields {
    padding: 10px 16px 0;
  }
  #form > .actions {
    padding: 8px 16px;
  }
}
/* 基準日と「予定を入れた最後の日」を並べる。 */
.dates {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.dates label {
  max-width: 220px;
}
/* 入力済みの期限より後の日は薄く出す。 */
.chart .beyondarea {
  fill: #eef0e8;
}
tr.beyond td {
  color: #9aa69f;
}
tr.divider td {
  text-align: left;
  white-space: normal;
  background: #f4f5ee;
  color: #4d5e55;
  font-size: 12px;
}
@media (max-width: 650px) {
  .top .dates label {
    margin-top: 18px;
    max-width: none;
    flex: 1 1 140px;
  }
}
@media (max-width: 700px) {
  .tablewrap tr.divider {
    display: block;
    background: transparent;
    padding: 4px 0 8px;
    border: 0;
  }
  .tablewrap tr.divider td {
    background: transparent;
    font-size: 13px;
  }
  .tablewrap tr.beyond {
    opacity: 0.6;
  }
}
/* 端末の間の同期 */
button.primary {
  background: #215c50;
  color: #fff;
  border-color: #215c50;
}
.syncstatus {
  padding: 10px 14px;
  border-radius: 10px;
  background: #eef0e8;
  font-size: 13px;
}
.warning .actions {
  margin-top: 10px;
}
