:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #17191f;
  --muted: #626975;
  --subtle: #8b929d;
  --border: #dfe3e8;
  --border-strong: #c7cdd5;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #a15c08;
  --warning-soft: #fffbeb;
  --danger: #b42318;
  --danger-soft: #fff4f2;
  --focus: #2563eb;
  --radius: 8px;
  font-family: system-ui, "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 34%, transparent);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon,
.product-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-header {
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner,
.workspace,
.app-footer {
  width: min(100% - 32px, 1040px);
  margin-inline: auto;
}

.header-inner {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.product-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.internal-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #444b55;
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  padding-block: 24px 44px;
}

.workflow-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.section-heading {
  min-height: 58px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #edf0f3;
}

.section-heading > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-label {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.warning-step {
  color: var(--warning);
  background: #fef3c7;
}

.success-step {
  color: var(--success);
  background: #dcfce7;
}

.success-step .icon {
  width: 16px;
  height: 16px;
}

.retention-note,
.action-status,
.rule-notes,
.app-footer,
.month-field p {
  color: var(--muted);
  font-size: 12px;
}

.month-field {
  min-height: 72px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 130px 180px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #edf0f3;
}

.month-field label {
  font-weight: 700;
}

.month-field input {
  min-height: 44px;
  width: 100%;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.upload-list {
  padding: 4px 18px;
}

.upload-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: 150px minmax(280px, 1fr) 180px;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #edf0f3;
}

.upload-row:last-child {
  border-bottom: 0;
}

.upload-label {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.upload-label strong {
  font-size: 14px;
}

.upload-label span {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
}

.file-picker {
  min-height: 46px;
  width: 100%;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #3f4650;
  text-align: left;
  background: #fafbfc;
  border: 1px dashed #b8c0ca;
  border-radius: 6px;
  cursor: pointer;
}

.file-picker:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: #f7f7ff;
}

.file-picker.has-file {
  color: #253047;
  border-style: solid;
  border-color: #aab3bf;
  background: var(--surface);
}

.file-picker.drag-over {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.file-picker span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-state {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-state.ready {
  color: var(--success);
  font-weight: 700;
}

.section-actions,
.unresolved-actions {
  min-height: 68px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid #edf0f3;
}

.button,
.icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.button {
  padding: 9px 15px;
  border: 1px solid transparent;
}

.button:disabled {
  color: #969daa;
  background: #e9ecf0;
  border-color: #e9ecf0;
  cursor: not-allowed;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.secondary-button {
  color: #303643;
  background: var(--surface);
  border-color: var(--border-strong);
}

.secondary-button:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: #fafaff;
}

.quiet-button {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.quiet-button:hover {
  color: var(--text);
  background: #f3f4f6;
}

.icon-button {
  width: 44px;
  padding: 0;
  background: transparent;
  border: 0;
}

.validation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-validation {
  padding: 18px;
}

.account-validation + .account-validation {
  border-left: 1px solid #edf0f3;
}

.account-title {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-title strong {
  font-size: 15px;
}

.account-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.account-state.warning {
  color: var(--warning);
}

.account-state .icon {
  width: 15px;
  height: 15px;
}

.validation-list {
  margin: 0;
}

.validation-item {
  min-height: 36px;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #f0f2f4;
}

.validation-item:last-child {
  border-bottom: 0;
}

.validation-item dt {
  color: var(--muted);
  font-size: 12px;
}

.validation-item dd {
  margin: 0;
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.verified-badge {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bbf7d0;
}

.warning-badge {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #f6d68b;
}

.warning-section {
  border-color: #e8cc8f;
}

.table-scroll {
  overflow-x: auto;
}

.unresolved-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.unresolved-table th,
.unresolved-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  vertical-align: middle;
}

.unresolved-table th {
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
  font-weight: 700;
}

.unresolved-table th:nth-child(1) {
  width: 70px;
}

.unresolved-table th:nth-child(2) {
  width: 90px;
}

.unresolved-table th:nth-child(4) {
  width: 130px;
}

.unresolved-table th:nth-child(5) {
  width: 270px;
}

.unresolved-table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.unresolved-summary {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.master-select {
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
}

.checkbox-row {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #444b55;
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.generate-bar {
  padding: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px 20px;
}

.processing-status {
  min-height: 44px;
  display: none;
  align-items: center;
  gap: 9px;
  color: #3730a3;
  font-size: 13px;
  font-weight: 700;
}

.processing-status.active {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c7d2fe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.rule-notes {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.rule-notes span::before {
  content: "・";
}

.result-section {
  border-color: #b9dfc4;
}

.result-heading {
  background: var(--success-soft);
}

.result-summary {
  padding: 13px 18px;
  color: #315c3d;
  border-bottom: 1px solid #dcefe1;
}

.result-summary.partial {
  color: #76510b;
  background: var(--warning-soft);
}

.download-list {
  padding: 4px 18px;
}

.download-row {
  min-height: 72px;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #edf0f3;
}

.download-row:last-child {
  border-bottom: 0;
}

.download-account {
  font-weight: 800;
}

.download-file {
  min-width: 0;
}

.download-file strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-file span {
  color: var(--muted);
  font-size: 12px;
}

.global-alert {
  min-height: 54px;
  margin-bottom: 16px;
  padding: 9px 10px 9px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid;
  border-radius: var(--radius);
}

.error-alert {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f5b9b3;
}

.global-alert p {
  flex: 1 1 auto;
}

.app-footer {
  padding-bottom: 28px;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .header-inner,
  .workspace,
  .app-footer {
    width: min(100% - 24px, 1040px);
  }

  .workspace {
    padding-top: 14px;
  }

  .section-heading {
    align-items: flex-start;
    padding: 13px 14px;
  }

  .retention-note {
    max-width: 150px;
    text-align: right;
  }

  .month-field {
    grid-template-columns: 1fr 1.25fr;
    padding-inline: 14px;
  }

  .month-field p {
    grid-column: 1 / -1;
  }

  .upload-list {
    padding-inline: 14px;
  }

  .upload-row {
    grid-template-columns: 1fr;
    gap: 9px;
    padding-block: 14px;
  }

  .file-state {
    white-space: normal;
  }

  .section-actions,
  .unresolved-actions {
    padding-inline: 14px;
    flex-wrap: wrap;
  }

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

  .account-validation {
    padding: 14px;
  }

  .account-validation + .account-validation {
    border-left: 0;
    border-top: 1px solid #edf0f3;
  }

  .generate-bar {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .primary-button {
    width: 100%;
  }

  .processing-status,
  .rule-notes {
    grid-column: 1;
  }

  .download-list {
    padding-inline: 14px;
  }

  .download-row {
    grid-template-columns: 74px minmax(0, 1fr);
    padding-block: 12px;
  }

  .download-row .button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 420px) {
  h1 {
    max-width: 230px;
    font-size: 14px;
  }

  .internal-badge {
    display: none;
  }

  .retention-note {
    display: none;
  }

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

  .month-field p {
    grid-column: 1;
  }

  .validation-item {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-block: 7px;
  }

  .validation-item dd {
    text-align: left;
  }

  .result-heading {
    align-items: center;
  }

  .result-heading .quiet-button {
    width: 44px;
    padding: 0;
    font-size: 0;
  }
}

