:root {
  color-scheme: light;
  --ink: #18332d;
  --muted: #64736f;
  --paper: #f5f3eb;
  --surface: #fffef9;
  --line: #d9ded8;
  --brand: #173f35;
  --brand-soft: #dcebe4;
  --accent: #e16d3d;
  --accent-dark: #be4f23;
  --danger: #b43a3a;
  --shadow: 0 14px 36px rgba(23, 63, 53, 0.09);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(225, 109, 61, 0.13), transparent 24rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
label[for],
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(225, 109, 61, 0.35);
  outline-offset: 2px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 24px;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--brand);
}

.container {
  width: min(100% - 32px, 960px);
  margin: 12px auto 80px;
}

.view[hidden] {
  display: none;
}

.hero {
  max-width: 650px;
  padding: 48px 0 36px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.8rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.hero > p:last-child {
  max-width: 520px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.8;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.action-card {
  display: flex;
  grid-column: span 2;
  min-height: 172px;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  text-align: left;
  background: var(--surface);
  box-shadow: 0 2px 0 rgba(23, 63, 53, 0.03);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.action-card:first-child,
.action-card:nth-child(2) {
  grid-column: span 3;
}

.action-card:hover {
  border-color: #aebbb5;
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.action-card.accent {
  border-color: var(--brand);
  color: white;
  background: var(--brand);
}

.action-card strong {
  margin-top: auto;
  font-size: 1.05rem;
}

.action-card small {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

.action-card.accent small {
  color: #cfe0d9;
}

.card-icon {
  font-size: 1.8rem;
  font-weight: 400;
}

.privacy-note,
.warning-banner {
  display: flex;
  gap: 10px 24px;
  justify-content: space-between;
  margin-top: 22px;
  border-radius: 15px;
  padding: 18px 20px;
  color: var(--ink);
  background: var(--brand-soft);
  font-size: 0.86rem;
  line-height: 1.6;
}

.privacy-note span,
.warning-banner span {
  color: #52645e;
}

.privacy-note > div {
  display: grid;
  gap: 4px;
}

.notice-link {
  align-self: center;
  border: 0;
  padding: 6px;
  color: var(--brand);
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 54px 0 26px;
}

.section-heading h1 {
  font-size: clamp(2rem, 6vw, 3.5rem);
}

.text-button {
  border: 0;
  padding: 10px;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(20px, 5vw, 38px);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-stack {
  display: grid;
  gap: 22px;
}

label {
  display: grid;
  gap: 8px;
}

label > span {
  font-size: 0.9rem;
  font-weight: 750;
}

label em {
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-style: normal;
}

input,
textarea {
  width: 100%;
  border: 1px solid #bdc7c2;
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--ink);
  background: white;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input-suffix {
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid #bdc7c2;
  border-radius: 12px;
  background: white;
}

.input-suffix input {
  border: 0;
}

.input-suffix span {
  padding-right: 15px;
  color: var(--muted);
}

.destination-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: -14px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 46px;
  border-radius: 12px;
  padding: 11px 17px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--brand);
  color: white;
  background: var(--brand);
}

.primary-button:hover {
  background: #0e3028;
}

.primary-button:disabled {
  border-color: #9ba8a3;
  background: #9ba8a3;
  cursor: not-allowed;
}

.secondary-button {
  border: 1px solid #b8c4bf;
  background: white;
}

.danger-button {
  border: 1px solid var(--danger);
  color: white;
  background: var(--danger);
}

.full-width {
  width: 100%;
}

.field-help {
  margin: -10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.fare-suggestion {
  margin-top: -12px;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: #fff4ed;
  font-size: 0.86rem;
}

.fare-suggestion button {
  border: 0;
  padding: 3px 6px;
  color: var(--accent-dark);
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
}

.error-box,
.message {
  border: 1px solid #e4b1b1;
  border-radius: 12px;
  padding: 13px 15px;
  color: #872828;
  background: #fff0f0;
  line-height: 1.6;
}

.message {
  position: sticky;
  z-index: 10;
  top: 12px;
  border-color: #9fcab6;
  color: var(--ink);
  background: #e7f4ed;
  box-shadow: var(--shadow);
}

.month-switcher {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.month-switcher button {
  border: 0;
  padding: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.month-switcher button:last-child {
  text-align: right;
}

.month-switcher strong {
  font-size: 1.16rem;
  white-space: nowrap;
}

.summary-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  border-radius: 18px;
  padding: 22px;
  color: white;
  background: var(--brand);
}

.summary-card strong {
  font-size: 1.65rem;
}

.list-order-help {
  margin: -6px 2px 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.expense-row {
  display: grid;
  grid-template-columns: 30px 105px 1fr auto auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 17px 18px;
  background: var(--surface);
}

.drag-handle {
  align-self: stretch;
  border: 0;
  padding: 0;
  color: #84928d;
  background: transparent;
  font-size: 1.4rem;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.expense-row.is-dragging {
  z-index: 2;
  border-color: var(--accent);
  opacity: 0.78;
  box-shadow: var(--shadow);
}

body.is-reordering {
  user-select: none;
  overscroll-behavior: contain;
}

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

.expense-route {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  font-weight: 800;
}

.expense-meta {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
}

.expense-fare {
  font-size: 1.05rem;
  font-weight: 850;
  white-space: nowrap;
}

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

.row-actions button {
  border: 0;
  padding: 8px;
  color: var(--muted);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.row-actions .delete {
  color: var(--danger);
}

.empty-state {
  border: 1px dashed #b9c4bf;
  border-radius: 18px;
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.4);
}

.csv-preview {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  border-radius: 16px;
  padding: 24px;
  background: var(--brand-soft);
}

.csv-preview strong {
  font-size: 1.7rem;
}

.csv-preview span:last-child {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--muted);
}

.safety-callout {
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  color: #69412f;
  background: #fff1e9;
  font-size: 0.85rem;
  line-height: 1.7;
}

.notice-content {
  display: grid;
  gap: 26px;
}

.notice-content section + section {
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.notice-content h2 {
  margin: 0 0 10px;
  font-size: 1.08rem;
}

.notice-content p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.upload-area {
  place-items: center;
  border: 2px dashed #aebdb6;
  border-radius: 18px;
  padding: 38px 18px;
  text-align: center;
  background: #f8faf7;
}

.upload-area:hover {
  border-color: var(--brand);
}

.upload-area input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-area small {
  color: var(--muted);
}

.upload-icon {
  font-size: 2.2rem;
}

.ocr-preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  object-fit: contain;
}

.progress-wrap p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe5e1;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.divider {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.ocr-disclaimer {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.warning-banner {
  margin: 0 0 16px;
  background: #fff0e8;
}

.ocr-confirm-list {
  display: grid;
  gap: 12px;
  padding-bottom: 100px;
}

.ocr-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
}

.ocr-card.is-selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(23, 63, 53, 0.1);
}

.ocr-card-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.select-record {
  display: flex;
  grid-template-columns: auto 1fr;
  gap: 9px;
  align-items: center;
  font-weight: 800;
}

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

.ocr-row-number {
  color: var(--muted);
  font-size: 0.8rem;
}

.ocr-fields {
  display: grid;
  grid-template-columns: 0.75fr 1fr 1fr 0.7fr;
  gap: 10px;
}

.ocr-fields label:last-child {
  grid-column: 1 / -1;
}

.ocr-fields label > span {
  font-size: 0.72rem;
}

.ocr-card .destination-actions {
  margin: 14px 0 0;
}

.ocr-card .fare-suggestion {
  margin: 12px 0 0;
}

.sticky-actions {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  background: rgba(255, 254, 249, 0.94);
  backdrop-filter: blur(12px);
}

dialog {
  width: min(90vw, 430px);
  border: 0;
  border-radius: 20px;
  padding: 25px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 31, 25, 0.5);
}

dialog h2 {
  margin: 0 0 8px;
}

dialog p {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

@media (max-width: 680px) {
  .app-header {
    padding: 18px 16px;
  }

  .app-header p {
    display: none;
  }

  .container {
    width: min(100% - 24px, 960px);
    margin-top: 0;
  }

  .hero {
    padding-top: 34px;
  }

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

  .action-card,
  .action-card:first-child,
  .action-card:nth-child(2) {
    grid-column: span 1;
    min-height: 155px;
    padding: 19px;
  }

  .action-card:first-child {
    grid-column: 1 / -1;
  }

  .privacy-note,
  .warning-banner {
    flex-direction: column;
  }

  .section-heading {
    margin-top: 34px;
  }

  .two-columns,
  .ocr-fields {
    grid-template-columns: 1fr;
  }

  .ocr-fields label:last-child {
    grid-column: auto;
  }

  .expense-row {
    grid-template-columns: 30px 1fr auto;
  }

  .expense-date {
    grid-column: 2 / -1;
  }

  .row-actions {
    grid-column: 2 / -1;
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    padding-top: 8px;
  }
}

@media (max-width: 420px) {
  .action-card {
    grid-column: 1 / -1;
  }

  .month-switcher {
    gap: 2px;
  }

  .month-switcher button {
    padding-inline: 4px;
    font-size: 0.8rem;
  }

  .destination-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sticky-actions {
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
