:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  line-height: 1.6;
  --brand: #126c57;
  --brand-dark: #0c4f40;
  --brand-soft: #e9f5f1;
  --ink: #17211e;
  --muted: #5d6965;
  --line: #dce4e0;
  --surface: #ffffff;
  --surface-soft: #f5f8f7;
  --warning: #8a4b08;
  --warning-soft: #fff7e6;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 16px 40px rgba(18, 45, 37, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  background: linear-gradient(180deg, #f8fbfa 0, #f3f6f5 24rem, #f5f7f6 100%);
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
}

button, input, select { font: inherit; }

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

a:hover { color: var(--brand); }

.site-header {
  align-items: center;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid rgba(220, 228, 224, .92);
  display: flex;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 1.04rem;
  font-weight: 750;
  gap: .7rem;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: var(--brand);
  border-radius: 11px;
  color: #fff;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.page-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 44px 28px 72px;
}

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

h1 {
  font-size: clamp(1.8rem, 3vw, 2.55rem);
  letter-spacing: -.035em;
  line-height: 1.25;
  margin-bottom: .6rem;
}

h2 {
  font-size: clamp(1.12rem, 2vw, 1.35rem);
  letter-spacing: -.018em;
  line-height: 1.35;
}

h3 { font-size: .95rem; }

.page-heading { margin: 22px 0 30px; max-width: 760px; }
.page-description { color: var(--muted); margin-bottom: 0; }
.back-link { display: inline-block; font-weight: 700; text-decoration: none; }
.eyebrow { color: var(--brand); font-size: .76rem; font-weight: 800; letter-spacing: .12em; margin-bottom: .4rem; text-transform: uppercase; }
.muted, small { color: var(--muted); }

button,
.button-secondary {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  justify-content: center;
  min-height: 46px;
  padding: .68rem 1rem;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

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

button:hover { background: var(--brand-dark); }
button:active { transform: translateY(1px); }
button.danger { background: var(--danger); }
button:disabled { cursor: wait; opacity: .58; }

.button-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button-secondary:hover { background: var(--surface-soft); border-color: #b9c9c2; color: var(--ink); }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(18, 108, 87, .3);
  outline-offset: 3px;
}

form, fieldset { margin: 0; }
form { display: grid; gap: 1rem; }
fieldset { border: 0; padding: 0; }
label { display: grid; font-size: .91rem; font-weight: 700; gap: .38rem; }

input,
select {
  background: #fff;
  border: 1px solid #bdc9c4;
  border-radius: 10px;
  color: var(--ink);
  min-height: 46px;
  padding: .65rem .75rem;
  width: 100%;
}

input::placeholder { color: #89948f; }
input:hover, select:hover { border-color: #8fa39a; }

.auth-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 180px);
}

.auth-card,
.form-card,
.search-card,
.statement-card,
.info-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card { max-width: 460px; padding: clamp(28px, 6vw, 48px); width: 100%; }
.auth-card--wide { max-width: 680px; }
.auth-secondary { border-top: 1px solid var(--line); margin: 1.5rem 0 0; padding-top: 1.25rem; text-align: center; }

.menu-hero { margin-bottom: 26px; }
.menu-hero h1 { margin-bottom: .35rem; }
.menu-hero > p:last-child { color: var(--muted); }

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

.menu-card {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 26px rgba(18, 45, 37, .05);
  color: var(--ink);
  display: grid;
  gap: 14px;
  grid-template-columns: auto 1fr auto;
  min-height: 118px;
  padding: 22px;
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.menu-card:hover { border-color: #a6cabc; box-shadow: var(--shadow); color: var(--ink); transform: translateY(-2px); }
.menu-card--primary { background: linear-gradient(135deg, #0f624f, #168268); border-color: transparent; color: #fff; }
.menu-card--primary:hover { color: #fff; }
.menu-card strong { display: block; font-size: 1.08rem; margin-bottom: .2rem; }
.menu-card small { color: inherit; opacity: .78; }
.menu-card-icon { align-items: center; background: var(--brand-soft); border-radius: 12px; color: var(--brand-dark); display: flex; font-weight: 850; height: 46px; justify-content: center; width: 46px; }
.menu-card--primary .menu-card-icon { background: rgba(255,255,255,.18); color: #fff; }
.menu-utilities { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 24px; }
.menu-utilities a { font-weight: 700; text-underline-offset: .2em; }
.logout-form { margin-top: 18px; width: max-content; }
.release-value { overflow-wrap: anywhere; }

.dashboard-status {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: .88rem;
  gap: 10px 18px;
  margin-bottom: 30px;
  padding: 12px 14px;
}

.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 850;
  padding: .28rem .68rem;
}
.status-badge--ok { background: #e8f7ef; color: #087443; }
.status-badge--warning { background: var(--warning-soft); color: var(--warning); }

.section-heading { align-items: end; display: flex; justify-content: space-between; margin: 34px 0 15px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > p { color: var(--muted); font-size: .88rem; }

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.metric-grid--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.metric-card p { color: var(--muted); font-size: .83rem; margin-bottom: .45rem; }
.metric-card strong { display: block; font-size: clamp(1.25rem, 2.4vw, 1.75rem); line-height: 1.25; }
.metric-card--primary { border-color: #b9dacc; box-shadow: 0 8px 24px rgba(18,108,87,.08); }
.metric-card--negative strong { color: var(--danger); }

.statement-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 24px; }
.statement-grid .statement-card:last-child { grid-column: 1 / -1; }
.statement-card { margin-top: 22px; padding: 24px; }
.statement-card > h2 { margin-bottom: 1rem; }
.statement-card h3 { color: var(--muted); margin: 1.3rem 0 .35rem; }
.empty-state { color: var(--muted); margin-bottom: 0; }

.financial-table { border-collapse: collapse; width: 100%; }
.financial-table th, .financial-table td { border-bottom: 1px solid var(--line); padding: .72rem 0; }
.financial-table th { font-weight: 600; text-align: left; }
.financial-table td { font-variant-numeric: tabular-nums; font-weight: 750; text-align: right; }

.alert-panel,
.notice {
  border: 1px solid #b9dacc;
  border-radius: 12px;
  margin: 18px 0;
  padding: 15px 17px;
  white-space: pre-wrap;
}
.notice { background: var(--brand-soft); color: var(--brand-dark); }
.notice.error, .alert-panel--error { background: var(--danger-soft); border-color: #f1b6b1; color: #801e16; }
.alert-panel--warning { background: var(--warning-soft); border-color: #f0d39e; color: #6d3b08; }
.alert-panel--success { background: #e8f7ef; border-color: #a8d9bd; color: #087443; }
.alert-panel h2 { font-size: 1.02rem; margin-bottom: .35rem; }
.alert-panel p:last-child { margin-bottom: 0; }

.technical-details { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-top: 24px; padding: 14px 16px; }
.technical-details summary { cursor: pointer; font-weight: 750; }
.technical-details dl { margin: 14px 0 0; }
.technical-details dd { overflow-wrap: anywhere; }

.admin-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-card, .search-card, .info-panel { padding: 24px; }
.form-card--wide { max-width: 760px; }
.info-panel { box-shadow: none; margin-top: 20px; max-width: 760px; }
.info-panel ol { margin-bottom: 0; padding-left: 1.35rem; }
.info-panel li + li { margin-top: .4rem; }

.upload-field {
  background: var(--surface-soft);
  border: 1px dashed #8fb7a8;
  border-radius: 12px;
  padding: 18px;
}
.upload-field-title { color: var(--brand-dark); font-size: 1.05rem; }
.file-status-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.file-status-list li { align-items: center; background: var(--surface-soft); border-radius: 10px; display: flex; gap: 12px; justify-content: space-between; overflow-wrap: anywhere; padding: 10px 12px; }
.file-state { border-radius: 999px; flex: none; font-size: .75rem; padding: .2rem .55rem; }
.file-state-pending { background: #eef1f0; color: #52605b; }
.file-state-working { background: #e8f0ff; color: #2459a8; }
.file-state-complete { background: #e8f7ef; color: #087443; }
.file-state-error { background: var(--danger-soft); color: var(--danger); }

.search-card { margin-bottom: 18px; }
.search-form { max-width: 760px; }
.search-row { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; }
.summary-list { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; margin: 0; max-width: 760px; }
.summary-list div { display: contents; }
.summary-list dt, .summary-list dd { background: var(--surface-soft); margin: 0; padding: 13px 15px; }
.summary-list dt { border-radius: 10px 0 0 10px; font-weight: 650; }
.summary-list dd { border-radius: 0 10px 10px 0; font-size: 1.08rem; font-weight: 800; text-align: right; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: .75rem .65rem; text-align: left; vertical-align: top; }
thead th { color: var(--muted); font-size: .78rem; font-weight: 800; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.responsive-table td:last-child { display: flex; flex-wrap: wrap; gap: 7px; }
.responsive-table td:last-child select { min-width: 9rem; width: auto; }
.responsive-table td:last-child button { font-size: .82rem; min-height: 38px; padding: .42rem .7rem; }
.inventory-table td:last-child { display: table-cell; font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; }
[data-inventory-next] { margin-top: 18px; }

.one-time { background: #f1f4f3; border-radius: 8px; display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top: .35rem; overflow-wrap: anywhere; padding: .65rem; white-space: pre-wrap; }
output, small { display: block; overflow-wrap: anywhere; }
pre { overflow-x: auto; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .metric-grid, .metric-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statement-grid, .admin-grid { grid-template-columns: 1fr; }
  .statement-grid .statement-card:last-child { grid-column: auto; }
}

@media (max-width: 640px) {
  .site-header { min-height: 60px; padding: 0 18px; }
  .brand-mark { height: 32px; width: 32px; }
  .page-shell { padding: 26px 16px 52px; }
  .auth-shell { align-items: flex-start; min-height: 0; }
  .auth-card, .form-card, .search-card, .statement-card, .info-panel { border-radius: 14px; box-shadow: none; padding: 20px 17px; }
  .menu-grid, .metric-grid, .metric-grid--compact { grid-template-columns: 1fr; }
  .menu-card { min-height: 104px; padding: 18px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .dashboard-status { align-items: flex-start; flex-direction: column; }
  .search-row { grid-template-columns: 1fr; }
  .search-row button, .logout-form, .logout-form button { width: 100%; }

  .responsive-table thead {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; padding: 8px 12px; }
  .responsive-table td { align-items: flex-start; border: 0; display: grid !important; gap: 12px; grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr); padding: .45rem 0; text-align: left !important; }
  .responsive-table td::before { color: var(--muted); content: attr(data-label); font-size: .78rem; font-weight: 750; }
  .responsive-table td:last-child { display: flex !important; flex-direction: column; }
  .responsive-table td:last-child::before { align-self: stretch; }
  .responsive-table td:last-child select, .responsive-table td:last-child button { width: 100%; }
  .inventory-table td:last-child { display: grid !important; }

  .file-status-list li { align-items: flex-start; flex-direction: column; }
}

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