:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #20242c;
  --muted: #697386;
  --line: #d9dee8;
  --accent: #246b5b;
  --accent-strong: #174b40;
  --danger: #a83232;
  --shadow: 0 8px 24px rgba(25, 35, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  background: var(--accent-strong);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(16px, 4vw, 40px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button input {
  display: none;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 18px;
}

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

.summary-item,
.paste-panel,
.toolbar,
.entry-form,
.table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-item {
  padding: 16px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.summary-item strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.toolbar,
.paste-panel,
.entry-form,
.table-section {
  padding: 16px;
}

.paste-panel {
  display: grid;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px;
  line-height: 1.6;
}

textarea:focus {
  outline: 2px solid rgba(36, 107, 91, 0.25);
  border-color: var(--accent);
}

.paste-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.secondary-button {
  background: #fff;
  color: var(--accent);
}

.secondary-button:hover {
  background: #eef6f3;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

input:focus {
  outline: 2px solid rgba(36, 107, 91, 0.25);
  border-color: var(--accent);
}

#entryForm {
  display: grid;
  grid-template-columns: 150px 180px 130px minmax(170px, 1fr) minmax(170px, 1fr) minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

#statusText {
  color: var(--muted);
  font-size: 13px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

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

th {
  position: sticky;
  top: 0;
  background: #eef3f1;
  color: #27352f;
  font-weight: 700;
  z-index: 1;
}

td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.delete-row {
  min-height: 32px;
  border-color: var(--danger);
  background: #fff;
  color: var(--danger);
  padding: 0 10px;
}

.delete-row:hover {
  background: #f8eaea;
}

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

tbody tr:hover {
  background: #f9fbfa;
}

@media (max-width: 900px) {
  .app-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .summary-grid,
  .toolbar,
  #entryForm {
    grid-template-columns: 1fr;
  }
}
