:root {
  --ink: #172126;
  --muted-ink: #526267;
  --paper: #fbfcfb;
  --soft: #eef3f1;
  --line: #d7e1dc;
  --teal: #16666b;
  --teal-dark: #0e474b;
  --coral: #c65f45;
  --gold: #b18728;
  --green: #4d7c45;
  --danger: #a44235;
  --white: #ffffff;
  --shadow: 0 18px 45px rgba(23, 33, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 82px;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(238, 243, 241, 0.9), rgba(251, 252, 251, 0.96) 420px),
    var(--paper);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.7;
  max-width: 100%;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.tool-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 54px);
  color: var(--white);
  background: rgba(14, 28, 30, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 700;
  white-space: nowrap;
}

.tool-nav {
  display: flex;
  gap: clamp(12px, 2vw, 26px);
  font-size: 0.92rem;
  overflow-x: auto;
}

.tool-nav a {
  color: rgba(255, 255, 255, 0.86);
  white-space: nowrap;
}

.tool-nav a:hover,
.tool-nav a:focus-visible {
  color: var(--white);
}

main {
  width: calc(100% - clamp(72px, 8vw, 112px));
  max-width: 1180px;
  margin: 0 auto;
}

.hero {
  padding: clamp(52px, 9vw, 92px) 0 clamp(36px, 6vw, 64px);
}

.hero-inner {
  width: 100%;
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 20px;
  color: var(--teal-dark);
  font-size: clamp(2.4rem, 5.3vw, 4.6rem);
  line-height: 1.04;
  letter-spacing: 0;
}

section,
aside {
  scroll-margin-top: 88px;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1.24;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.05rem;
  line-height: 1.34;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  margin-bottom: 24px;
  color: var(--muted-ink);
  font-size: clamp(1.02rem, 2vw, 1.22rem);
}

.hero-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-status span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--teal-dark);
  background: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
}

.notice,
.next-note {
  display: grid;
  grid-template-columns: minmax(220px, 0.44fr) minmax(0, 1fr);
  gap: clamp(18px, 4vw, 42px);
  align-items: start;
  margin-bottom: 28px;
  padding: 24px clamp(20px, 4vw, 34px);
  border: 1px solid rgba(198, 95, 69, 0.26);
  border-radius: 8px;
  background: #fff8f5;
}

.notice p:last-child,
.next-note p:last-child {
  margin-bottom: 0;
  color: var(--muted-ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  gap: 22px;
  align-items: start;
}

.panel {
  margin-bottom: 24px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 22px;
}

.section-heading p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted-ink);
}

.section-heading.compact {
  max-width: 560px;
}

.field-hint,
.action-note,
.summary-note,
.export-note {
  display: block;
  color: var(--muted-ink);
  font-size: 0.86rem;
  line-height: 1.6;
}

.field-hint {
  margin-top: 7px;
}

.action-note,
.summary-note,
.export-note {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: #fff9e8;
}

.action-note.inline {
  flex: 0 1 240px;
  margin: 0;
  padding: 10px 12px;
  line-height: 1.45;
}

.export-note {
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

label,
fieldset {
  min-width: 0;
}

label span,
legend,
.month-picker span,
.filters span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

label strong,
legend strong {
  color: var(--coral);
  font-size: 0.76rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(22, 102, 107, 0.22);
  outline-offset: 2px;
}

.wide {
  grid-column: 1 / -1;
}

.type-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted-ink);
  background: var(--soft);
  text-align: center;
}

.segmented input:checked + span {
  color: var(--white);
  border-color: var(--teal);
  background: var(--teal);
}

.segmented input:focus-visible + span {
  outline: 3px solid rgba(22, 102, 107, 0.22);
  outline-offset: 2px;
}

.form-actions,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  color: var(--white);
  background: var(--coral);
}

.button.primary:hover {
  background: #b85039;
}

.button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.button.ghost {
  color: var(--teal-dark);
  border-color: var(--line);
  background: var(--white);
}

.helper-text {
  min-height: 28px;
  margin: 18px 0 0;
  padding: 0;
  color: var(--teal-dark);
  font-weight: 700;
}

.helper-text.success,
.helper-text.error {
  padding: 12px 14px;
  border-radius: 8px;
}

.helper-text.success {
  color: var(--teal-dark);
  background: #e5f6f2;
}

.helper-text.error {
  color: var(--danger);
  background: #f9e8e2;
}

.month-picker {
  display: block;
  margin-bottom: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.summary-grid article {
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.summary-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-ink);
  font-size: 0.88rem;
  font-weight: 700;
}

.summary-grid strong {
  display: block;
  color: var(--teal-dark);
  font-size: clamp(1.3rem, 4vw, 2rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.monthly-table-wrap {
  margin-top: 24px;
}

.monthly-list {
  display: grid;
  gap: 10px;
}

.month-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.month-row div:first-child {
  grid-column: 1 / -1;
}

.month-row span {
  color: var(--muted-ink);
  font-size: 0.86rem;
}

.month-row strong {
  color: var(--teal-dark);
  display: block;
  overflow-wrap: anywhere;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.filters label {
  min-width: min(210px, 100%);
}

.check-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
}

.check-filter input {
  width: 18px;
  min-height: 18px;
}

.check-filter span {
  margin: 0;
}

.record-management {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.record-management h3 {
  margin-bottom: 6px;
}

.record-management p {
  margin-bottom: 8px;
  color: var(--muted-ink);
}

.helper-text.compact {
  min-height: 0;
  margin: 0;
  font-size: 0.9rem;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
  background: var(--white);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--teal-dark);
  background: var(--soft);
  font-size: 0.88rem;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.amount-cell {
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.tag.income {
  color: #245b2e;
  background: #e6f1e7;
}

.tag.expense {
  color: #8c3f2e;
  background: #f9e8e2;
}

.tag.pending {
  color: #71540f;
  background: #f5edcf;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.small-button {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--white);
  font-weight: 700;
  cursor: pointer;
}

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

.select-cell {
  text-align: center;
}

.select-cell input {
  width: 20px;
  min-height: 20px;
}

.empty-state {
  margin: 18px 0 0;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted-ink);
  background: var(--soft);
}

.export-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(280px, 1fr);
  gap: clamp(18px, 4vw, 34px);
  align-items: start;
}

.export-actions {
  margin: 0;
}

.export-actions p {
  margin: 0;
  color: var(--muted-ink);
}

.export-message {
  flex: 1 1 300px;
}

.next-note {
  background: var(--soft);
  border-color: var(--line);
}

.tool-footer {
  margin-top: 36px;
  padding: 28px clamp(18px, 5vw, 72px);
  color: rgba(255, 255, 255, 0.78);
  background: var(--ink);
}

.tool-footer p {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  font-size: 0.92rem;
}

@media (max-width: 980px) {
  .workspace,
  .export-panel,
  .notice,
  .next-note {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .tool-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  main {
    width: calc(100% - 112px);
    max-width: 1180px;
  }

  .form-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .filters,
  .record-management,
  .form-actions,
  .export-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters label,
  .bulk-actions,
  .button {
    width: 100%;
  }

  .record-management {
    display: flex;
  }

  .bulk-actions {
    justify-content: stretch;
  }

  .action-note.inline {
    flex-basis: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
  }

  td::before {
    content: attr(data-label);
    color: var(--muted-ink);
    font-weight: 700;
  }

  td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    width: 100%;
  }

  .small-button {
    flex: 1 1 120px;
  }

  .month-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  main *,
  .tool-header *,
  .tool-footer * {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-all;
    line-break: anywhere;
  }

  h1 {
    font-size: 2rem;
  }

  .panel,
  .notice,
  .next-note {
    padding: 20px 16px;
  }

  td {
    grid-template-columns: 1fr;
  }

  .month-row {
    grid-template-columns: 1fr;
  }

}
