:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #17211d;
  --muted: #5b6962;
  --primary: #087a5b;
  --primary-dark: #065d46;
  --primary-soft: #eaf7f2;
  --border: #d7e0db;
  --border-strong: #b9c8c0;
  --warning: #9a6700;
  --warning-bg: #fff7d6;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 8px 28px rgba(23, 52, 43, 0.08);
  --radius: 14px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.65; }
button, input, select { font: inherit; }
button, select, input[type="date"] { min-height: 46px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible { outline: 3px solid #1f8fef; outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 16px; color: #fff; background: var(--primary-dark); border-radius: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { width: min(1296px, calc(100% - 40px)); min-height: 74px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: #fff; background: var(--primary); font-size: 27px; font-weight: 400; line-height: 1; }
.privacy-status { display: inline-flex; align-items: center; gap: 9px; padding: 6px 13px; border-radius: 999px; color: var(--primary-dark); background: var(--primary-soft); font-size: 13px; font-weight: 700; }
.privacy-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

.page-shell { width: min(1296px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 58px; }
.hero .eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.hero h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); line-height: 1.3; letter-spacing: -.02em; }
.hero > p:last-child { margin: 10px 0 0; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0 30px; padding: 0; list-style: none; }
.steps li { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 16px; color: var(--muted); background: #e4eae7; border-radius: 999px; font-weight: 800; }
.steps li span { display: grid; place-items: center; flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%; color: var(--muted); background: #fff; font-size: 13px; }
.steps li.is-current { color: #fff; background: var(--primary); }
.steps li.is-current span { color: var(--primary); }
.steps li.is-complete { color: var(--primary-dark); background: var(--primary-soft); }
.steps li.is-complete span { color: #fff; background: var(--primary); }

.global-message { margin: 0 0 20px; padding: 14px 18px; color: var(--danger); background: var(--danger-bg); border: 1px solid #e9b8b4; border-radius: 10px; font-weight: 700; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; gap: 24px; }
.main-column, .side-column { display: grid; gap: 24px; min-width: 0; }
.side-column { position: sticky; top: 24px; }

.panel { padding: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel h2, .panel h3 { margin: 0; line-height: 1.4; }
.panel h2 { font-size: 21px; }
.panel h3 { font-size: 18px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.panel-heading > div { display: flex; align-items: center; gap: 11px; }
.panel-heading > p { max-width: 56%; margin: 0; color: var(--muted); font-size: 14px; text-align: right; }
.section-number { display: grid; place-items: center; width: 31px; height: 31px; margin: 0; color: #fff; background: var(--primary); border-radius: 50%; font-weight: 800; }

.date-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { font-size: 14px; font-weight: 800; }
.required { margin-left: 5px; color: var(--danger); font-size: 11px; font-weight: 800; }
.field input, .field select { width: 100%; padding: 10px 13px; color: var(--text); background: #fff; border: 1.5px solid var(--border-strong); border-radius: 9px; }
.field input:hover, .field select:hover { border-color: #7e968b; }
.field input:invalid:not(:focus):not(:placeholder-shown), .field select:invalid:not(:focus) { border-color: var(--danger); }
.field-help { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.drop-zone { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 17px; padding: 22px; background: #f7fbf9; border: 2px dashed #86b7a5; border-radius: 12px; }
.drop-zone.is-dragging { background: var(--primary-soft); border-color: var(--primary); }
.drop-zone strong { display: block; font-weight: 800; }
.drop-zone span { display: block; color: var(--muted); font-size: 13px; }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-size: 26px; }

.empty-state { margin-top: 18px; padding: 23px; color: var(--muted); background: #f8faf9; border: 1px solid var(--border); border-radius: 10px; text-align: center; }
.empty-state strong { color: var(--text); }
.empty-state p { margin: 5px 0 0; }
.file-list { display: grid; gap: 16px; margin-top: 18px; }
.file-card { padding: 19px; border: 1px solid var(--border); border-left: 6px solid var(--primary); border-radius: 12px; }
.file-card.has-warning { border-left-color: var(--warning); }
.file-card.has-error, .file-card.is-duplicate { border-left-color: var(--danger); }
.file-card-head { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.file-title-wrap { display: flex; align-items: center; min-width: 0; gap: 12px; }
.file-icon { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; color: #fff; background: var(--primary); border-radius: 8px; font-weight: 900; }
.file-name { overflow-wrap: anywhere; font-size: 16px !important; }
.file-size { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status-chip { align-self: flex-start; flex: 0 0 auto; padding: 4px 10px; color: var(--muted); background: #eef2f0; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-chip.success { color: var(--primary-dark); background: var(--primary-soft); }
.status-chip.warning { color: #6e4a00; background: var(--warning-bg); }
.status-chip.error { color: var(--danger); background: var(--danger-bg); }
.file-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.file-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 15px; }
.file-result { margin-top: 15px; padding: 11px 13px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.file-result.success { color: var(--primary-dark); background: var(--primary-soft); }
.file-result.warning { color: #6e4a00; background: var(--warning-bg); }
.file-result.error { color: var(--danger); background: var(--danger-bg); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 17px; border: 1px solid transparent; border-radius: 9px; font-weight: 800; transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:not(:disabled):hover { background: var(--primary-dark); }
.button-primary:disabled { color: #fff; background: #aebbb5; }
.button-secondary { color: #fff; background: var(--primary); }
.button-tertiary { color: var(--text); background: #fff; border-color: var(--border-strong); }
.button-tertiary:hover { background: #f4f7f5; }
.button-danger { color: var(--danger); background: #fff; border-color: #e4aaa5; }
.button-danger:hover { background: var(--danger-bg); }
.button-wide { width: 100%; min-height: 54px; }
.button-icon { font-size: 18px; }
.panel-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.panel-actions p { margin: 0; color: var(--muted); font-size: 13px; text-align: right; }

.department-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.department-card { padding: 17px; background: #f7fbf9; border: 1px solid var(--border); border-radius: 10px; }
.department-card.has-data { background: var(--primary-soft); border-color: #86b7a5; }
.department-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.department-card-head h3 { font-size: 16px; }
.department-card-head span { color: var(--muted); font-size: 12px; }
.department-values { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-top: 14px; }
.department-values p { margin: 0; color: var(--muted); font-size: 13px; }
.department-values strong { font-size: 19px; white-space: nowrap; }
.tax-breakdown { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tax-pill { padding: 3px 8px; color: var(--muted); background: #fff; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; }

.notice-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.notice-heading, .notice-heading > div { display: flex; align-items: center; gap: 10px; }
.notice-heading { justify-content: space-between; }
.status-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.status-icon.warning { color: #fff; background: var(--warning); }
.count-badge { padding: 3px 9px; color: #6e4a00; background: var(--warning-bg); border-radius: 999px; font-size: 12px; font-weight: 800; }
.notice-section > p { color: var(--muted); font-size: 13px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--primary-dark); background: #edf5f1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }

.summary-panel h2, .export-panel h2 { margin-bottom: 18px; }
.summary-list { margin: 0; }
.summary-list > div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.summary-list dt { color: var(--muted); font-size: 14px; }
.summary-list dd { margin: 0; font-size: 20px; font-weight: 850; }
.summary-list .summary-amount { align-items: end; }
.summary-list .summary-amount span { font-size: 11px; }
.summary-list .summary-amount dd { color: var(--primary-dark); font-size: clamp(22px, 2.4vw, 29px); }
.status-strip { margin-top: 17px; padding: 9px 12px; border-radius: 999px; text-align: center; font-size: 13px; font-weight: 800; }
.status-strip.neutral { color: var(--muted); background: #eef2f0; }
.status-strip.success { color: var(--primary-dark); background: var(--primary-soft); }
.status-strip.warning { color: #6e4a00; background: var(--warning-bg); }

.confirm-check { display: grid; grid-template-columns: 23px 1fr; gap: 11px; align-items: start; margin-bottom: 18px; font-weight: 700; }
.confirm-check input { width: 21px; height: 21px; margin: 3px 0 0; accent-color: var(--primary); }
.export-panel > p { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.retention-note { margin-top: 20px; padding: 14px; color: var(--muted); background: #f7f9f8; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }
.retention-note strong { color: var(--text); }
.retention-note p { margin: 4px 0 0; }

.app-footer { padding: 24px 20px 36px; color: var(--muted); text-align: center; font-size: 13px; }
.app-footer p { margin: 0; }

@media (max-width: 960px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .side-column { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  .header-inner, .page-shell { width: min(100% - 24px, 1296px); }
  .header-inner { min-height: 66px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 34px; height: 34px; }
  .privacy-status { max-width: 132px; padding: 5px 9px; font-size: 11px; text-align: center; }
  .page-shell { padding-top: 28px; }
  .hero > p:last-child { font-size: 14px; }
  .steps { grid-template-columns: 1fr; gap: 7px; }
  .steps li { min-height: 42px; }
  .panel { padding: 20px 16px; }
  .panel-heading { display: block; }
  .panel-heading > p { max-width: none; margin-top: 8px; text-align: left; }
  .date-grid, .file-fields, .department-grid, .side-column { grid-template-columns: 1fr; }
  .drop-zone { grid-template-columns: auto 1fr; padding: 18px 14px; }
  .drop-zone .button { grid-column: 1 / -1; width: 100%; }
  .file-card { padding: 16px 13px; }
  .file-card-head { align-items: flex-start; }
  .file-status { max-width: 104px; text-align: center; }
  .file-actions { justify-content: stretch; }
  .file-actions .button { flex: 1; }
  .panel-actions { display: grid; }
  .panel-actions .button { width: 100%; }
  .panel-actions p { text-align: left; }
  .department-values strong { font-size: 17px; }
  .summary-list .summary-amount dd { font-size: 23px; }
}

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