:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #687380;
  --panel: #ffffff;
  --line: #d9e1e8;
  --field: #f7f9fb;
  --brand: #295b6f;
  --brand-strong: #143946;
  --accent: #b94f2a;
  --ok: #1c7c54;
  --warn: #a36100;
  --error: #a42d2d;
  --bg: #eef3f5;
  --shadow: 0 16px 40px rgba(24, 35, 46, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(238, 243, 245, 0.84), rgba(238, 243, 245, 0.98)),
    repeating-linear-gradient(90deg, rgba(32, 36, 42, 0.05) 0 1px, transparent 1px 64px);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost {
  background: transparent;
  color: var(--brand-strong);
  border: 1px solid var(--line);
}

button.ghost:hover {
  border-color: var(--brand);
  background: #f6fbfd;
}

button.ghost.danger {
  color: var(--error);
}

button.ghost.danger:hover {
  border-color: var(--error);
  background: #fff7f7;
}

.shell {
  width: min(1440px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-strong);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

p {
  color: var(--muted);
  font-size: 0.92rem;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.88fr) minmax(420px, 1.35fr) minmax(340px, 1fr);
  grid-template-areas:
    "account upload files"
    "transpose transpose files";
  gap: 16px;
  align-items: start;
}

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

.account-panel {
  grid-area: account;
}

.upload-panel {
  grid-area: upload;
}

.transpose-panel {
  grid-area: transpose;
}

.files-panel {
  grid-area: files;
  min-height: 420px;
}

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

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  min-width: 64px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge.muted {
  color: var(--muted);
  background: #edf1f4;
}

.badge.ok {
  color: var(--ok);
  background: #e8f5ef;
}

.badge.warn {
  color: var(--warn);
  background: #fff4df;
}

.badge.error {
  color: var(--error);
  background: #feecec;
}

.inline-form,
.control-grid {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-top: 12px;
}

.inline-form label {
  grid-column: 1 / -1;
}

.inline-form input {
  min-width: 0;
}

.retry-checkout {
  width: 100%;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #303944;
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(41, 91, 111, 0.24);
  border-color: var(--brand);
  background: #fff;
}

.dropzone {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 112px;
  border: 1px dashed #aebbc5;
  border-radius: 8px;
  padding: 16px;
  background: #f9fbfc;
}

.dropzone input[type="file"] {
  grid-column: 1 / -1;
  min-height: auto;
  padding: 10px;
  background: white;
}

.dropcopy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.dropcopy strong {
  overflow-wrap: anywhere;
}

.dropcopy span {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.summary-item span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.control-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  align-items: end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.rights-row {
  grid-column: 1 / -1;
}

.terms-row {
  grid-column: 1 / -1;
  align-items: flex-start;
}

.terms-row a {
  color: var(--brand-strong);
  text-underline-offset: 0.18em;
}

#exportButton {
  align-self: end;
}

.files-list {
  display: grid;
  gap: 10px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
}

.file-row strong {
  overflow-wrap: anywhere;
}

.file-row span {
  color: var(--muted);
  font-size: 0.8rem;
}

.message-log {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(420px, calc(100vw - 40px));
  display: grid;
  gap: 8px;
  z-index: 20;
}

.message {
  border-radius: 7px;
  padding: 12px 14px;
  background: var(--brand-strong);
  color: #fff;
  box-shadow: var(--shadow);
}

.message.error {
  background: var(--error);
}

.message.warn {
  background: var(--warn);
}

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

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "account upload"
      "transpose transpose"
      "files files";
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 24px, 680px);
    padding: 14px 0;
  }

  .topbar,
  .brand,
  .top-actions,
  .dropzone,
  .inline-form {
    align-items: stretch;
  }

  .topbar,
  .top-actions {
    flex-direction: column;
  }

  .workspace,
  .control-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "account"
      "upload"
      "transpose"
      "files";
  }

  .dropzone,
  .inline-form {
    grid-template-columns: 1fr;
  }

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