:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-strong: #eef4ef;
  --text: #202421;
  --muted: #66706a;
  --line: #d9ded8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warning: #a15c12;
  --danger: #b42318;
  --ok: #287148;
  --shadow: 0 16px 40px rgba(32, 36, 33, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

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

.eyebrow,
.step-label {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
}

.header-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 40px;
}

.work-panel,
.side-panel,
.result-panel {
  min-width: 0;
}

.work-panel,
.rule-panel,
.retention-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.work-panel,
.result-panel {
  padding: 22px;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.rule-panel,
.retention-panel {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title.compact {
  margin-bottom: 12px;
}

.file-format {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.upload-form {
  display: grid;
  gap: 14px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 168px;
  padding: 24px;
  border: 2px dashed #9eb8b2;
  border-radius: 8px;
  background: #f9fbf8;
  cursor: pointer;
  text-align: center;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  background: #edf7f4;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 700;
}

.drop-meta {
  display: block;
  max-width: 100%;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 132px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
}

.primary-button,
.download-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover,
.download-button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.status-box {
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.status-title {
  font-weight: 700;
}

.status-copy {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-box.is-working {
  border-color: #93c5bd;
}

.status-box.is-error {
  border-color: #f0b4ad;
  background: #fff4f2;
}

.status-box.is-success {
  border-color: #9bc6aa;
  background: #f0f8f2;
}

.rules-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.rules-list div {
  display: grid;
  grid-template-columns: minmax(82px, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.rules-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.rules-list dt {
  font-weight: 700;
}

.rules-list dd {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.retention-panel {
  border-color: #e7c99a;
  background: #fffaf0;
}

.retention-panel p:last-child {
  margin-top: 8px;
  color: #77531b;
  line-height: 1.6;
}

.result-panel {
  grid-column: 1 / -1;
}

.is-hidden {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metrics-grid div {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metrics-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.notice {
  min-height: 40px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fbfcfa;
}

.notice.is-ok {
  color: #14532d;
  border-color: #9bc6aa;
  background: #effaf2;
}

.notice.is-warning {
  color: var(--warning);
  border-color: #e7c99a;
  background: #fffaf0;
}

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

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f7f9f6;
}

td:nth-child(2),
td:nth-child(3) {
  text-align: right;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 26px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  color: #14532d;
  background: #dcf5e2;
}

.badge.warn {
  color: #7a3d0a;
  background: #fff0d6;
}

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-layout {
    grid-template-columns: 1fr;
    width: min(100vw - 24px, 680px);
    margin-top: 14px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .download-button,
  .primary-button,
  .secondary-button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 21px;
  }

  .work-panel,
  .rule-panel,
  .retention-panel,
  .result-panel {
    padding: 16px;
  }

  .drop-zone {
    min-height: 148px;
    padding: 18px;
  }

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