:root {
  --bg: #f3f6fb;
  --bg-soft: #ebf1f8;
  --panel: #ffffff;
  --text: #1e293b;
  --muted: #55657a;
  --primary: #1f5fa7;
  --primary-soft: #e8f0fb;
  --border: #d8e1ec;
  --ok: #1f7a48;
  --ok-soft: #ebf8f1;
  --warn: #8f6400;
  --warn-soft: #fff7e5;
  --err: #a31f1f;
  --err-soft: #fff0f0;
  --info: #1c4f88;
  --info-soft: #edf4ff;
  --shadow: 0 10px 24px rgba(22, 38, 64, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 400px at 100% -20%, #dde9f7 0%, transparent 65%),
    radial-gradient(900px 350px at -5% -20%, #eef3fa 0%, transparent 60%),
    var(--bg);
}

.app-container {
  width: min(1140px, 100% - 32px);
  margin: 22px auto 30px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

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

h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

.top-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.top-header-main h1 {
  font-size: 32px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.top-header-main p {
  color: var(--muted);
  line-height: 1.5;
}

.top-header-main .header-note {
  margin-top: 6px;
  font-size: 14px;
}

.top-header-badge {
  flex-shrink: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: var(--primary-soft);
  border: 1px solid #bfd0e9;
  color: #234f80;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8aa3c4;
}

.dot.ok {
  background: var(--ok);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.mode-card:hover {
  transform: translateY(-1px);
  border-color: #9eb6d4;
}

.mode-card input {
  margin-top: 3px;
}

.mode-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mode-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #f1f5fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.mode-copy h3 {
  font-size: 16px;
  margin-bottom: 5px;
}

.mode-copy p {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.mode-hint {
  margin-top: 10px;
  font-size: 13px;
  color: #385a80;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upload-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fcfdff;
}

.upload-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.upload-hint {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.upload-card input[type="file"] {
  width: 100%;
  border: 1px dashed #bccde1;
  background: #f7fafe;
  border-radius: 10px;
  padding: 10px;
}

.file-chip-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-chip {
  flex: 1;
  min-width: 0;
  border: 1px solid #ccd8e6;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #445f7c;
  background: #f4f8fd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip.ready {
  border-color: #9ac3ac;
  background: var(--ok-soft);
  color: #245f3f;
}

.chip-btn {
  border: 1px solid #c2cfdf;
  background: #fff;
  color: #3a546f;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.chip-btn:hover {
  background: #f2f6fc;
}

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #164f90;
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-spinner-dark {
  border-color: rgba(31, 95, 167, 0.2);
  border-top-color: var(--primary);
}

.btn-secondary {
  background: #fff;
  color: #284a6d;
  border-color: #c5d3e4;
}

.btn-secondary:hover:not(:disabled) {
  background: #f6f9fd;
}

.btn-ghost {
  background: #eef3fa;
  color: #345273;
  border-color: #d5dfeb;
}

.btn-ghost:hover:not(:disabled) {
  background: #e5edf7;
}

.status-banner {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.status-ready,
.status-info {
  background: var(--info-soft);
  border-color: #c8dbf5;
  color: var(--info);
}

.status-success {
  background: var(--ok-soft);
  border-color: #b8dec9;
  color: var(--ok);
}

.status-warning {
  background: var(--warn-soft);
  border-color: #efd9a1;
  color: var(--warn);
}

.status-error {
  background: var(--err-soft);
  border-color: #f0b6b6;
  color: var(--err);
}

.status-detail {
  font-size: 13px;
  color: #4f6175;
  min-height: 18px;
}

.recipient-text {
  margin-top: 8px;
  font-size: 13px;
  color: #5e6f82;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.summary-item {
  border: 1px solid var(--border);
  background: #f8fbff;
  border-radius: 10px;
  padding: 10px;
}

.summary-item .k {
  font-size: 12px;
  color: #5b7188;
  margin-bottom: 4px;
}

.summary-item .v {
  font-size: 15px;
  font-weight: 700;
  color: #223a54;
  word-break: break-word;
}

.audit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.audit-pill {
  border-radius: 999px;
  border: 1px solid #c7d7ea;
  background: #eef4fc;
  color: #244f80;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.audit-pill.pass {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b8dec9;
}

.audit-pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #efd9a1;
}

.audit-pill.fail {
  background: var(--err-soft);
  color: var(--err);
  border-color: #f0b6b6;
}

.section-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.preview-empty {
  color: #5f7387;
  font-size: 14px;
  background: #f8fbff;
  border: 1px dashed #c7d7e9;
  border-radius: 10px;
  padding: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eff5fd;
  border-bottom: 1px solid #d3e0ef;
  color: #2b4f76;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 9px 10px;
}

tbody td {
  border-bottom: 1px solid #e5edf7;
  padding: 8px 10px;
  font-size: 13px;
  color: #2c4460;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

details summary {
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
}

.log-box {
  margin: 0;
  min-height: 150px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid #bdd0e4;
  border-radius: 10px;
  background: #0c1c2f;
  color: #d9e8ff;
  font-size: 12px;
  line-height: 1.45;
  padding: 12px;
}

.footer-note {
  color: #5b6d80;
  font-size: 13px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 1020px) {
  .mode-grid,
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-container {
    width: calc(100% - 20px);
    margin-top: 12px;
  }

  .panel {
    padding: 14px;
  }

  .top-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-header-main h1 {
    font-size: 26px;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }
}
