:root {
  --bg: #eef1f3;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5a6571;
  --line: #d5dde4;
  --slate: #1f2d3a;
  --slate-hover: #15212d;
  --soft: #f7f8f9;
  --good: #1f7a4d;
  --warn: #a33b3b;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.page-head,
.section-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-head {
  margin-bottom: 14px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #6f7a86;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h2 {
  font-size: 1rem;
}

.muted,
.section-head p {
  color: var(--muted);
  line-height: 1.45;
}

.credit-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

.upload-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.status-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  position: sticky;
  top: 14px;
}

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

#password-field {
  grid-column: 1 / -1;
}

.result-banner {
  border: 1px solid var(--line);
  border-left: 5px solid #6f7a86;
  border-radius: 6px;
  background: #f7f8f9;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.42;
  padding: 10px 12px;
}

.result-banner.progress {
  border-left-color: #4b6f8f;
  background: #f1f6fa;
}

.result-banner.success {
  border-color: rgba(31, 122, 77, 0.34);
  border-left-color: var(--good);
  background: #eff8f3;
  color: var(--good);
}

.result-banner.error {
  border-color: rgba(163, 59, 59, 0.34);
  border-left-color: var(--warn);
  background: #fff3f3;
  color: var(--warn);
}

label {
  display: grid;
  gap: 6px;
  color: #33404d;
  font-size: 0.86rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c7d0d8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 9px 10px;
}

input:focus,
button:focus-visible,
.file-drop:focus-within {
  outline: 3px solid rgba(31, 45, 58, 0.16);
  border-color: var(--slate);
}

.file-drop {
  border: 1px dashed #2f8f5b;
  border-radius: 8px;
  background: #edf8f1;
  cursor: pointer;
  gap: 4px;
  min-height: 88px;
  padding: 14px;
}

.file-drop:hover {
  background: #e3f3ea;
  border-color: #237347;
}

.file-drop span {
  color: #16613e;
  font-weight: 800;
}

.file-drop strong {
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.file-list {
  display: grid;
  gap: 6px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
}

.preview-thumb {
  display: grid;
  align-items: center;
  justify-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  aspect-ratio: 1 / 1;
  position: relative;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-thumb span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 22px;
  border-radius: 999px;
  background: rgba(23, 33, 43, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  padding: 5px 7px;
  text-align: center;
}

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

.file-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row small {
  color: var(--muted);
}

.permission-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  color: #34404d;
  font-weight: 600;
  line-height: 1.42;
  padding-top: 12px;
}

.permission-row input {
  min-height: 18px;
  margin-top: 2px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
  padding: 9px 14px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary {
  border: 1px solid var(--slate);
  background: var(--slate);
  color: #fff;
}

.primary:hover {
  background: var(--slate-hover);
}

.secondary {
  border: 1px solid #b8c2cc;
  background: #fff;
  color: var(--slate);
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #33404d;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 10px;
}

.status-message {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  min-height: 58px;
  padding: 10px;
}

.status-message.success {
  border-color: rgba(31, 122, 77, 0.34);
  background: #eff8f3;
  color: var(--good);
  font-weight: 700;
}

.status-message.error {
  border-color: rgba(163, 59, 59, 0.34);
  background: #fff3f3;
  color: var(--warn);
  font-weight: 700;
}

.status-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: center;
  justify-items: center;
  background: rgba(15, 23, 42, 0.46);
  padding: 16px;
}

.upload-modal {
  display: grid;
  gap: 12px;
  width: min(620px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
  padding: 16px;
}

.modal-message {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.modal-preview-grid {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.status-list div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1080px);
    padding-top: 14px;
  }

  .page-head,
  .section-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .field-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 8px;
  }

  .preview-grid,
  .modal-preview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-panel {
    position: static;
  }
}

@media (max-width: 420px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

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

  .modal-actions {
    flex-direction: column;
  }
}
