:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-raised: #fbfcfc;
  --text: #161719;
  --muted: #666d75;
  --subtle: #8b929a;
  --border: #dfe3e6;
  --border-strong: #c7cdd3;
  --red: #d71920;
  --red-dark: #ad1117;
  --amber: #f2b705;
  --green: #16794f;
  --shadow: 0 18px 48px rgba(20, 24, 29, 0.08);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(215, 25, 32, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: flex-start;
  max-width: 650px;
  gap: 12px;
  min-width: 0;
  font-size: 15px;
  font-weight: 720;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 7px;
  background:
    linear-gradient(90deg, var(--red) 0 33%, var(--amber) 33% 66%, #222 66% 100%);
  color: #fff;
  font-size: 20px;
  font-weight: 820;
  line-height: 1;
  text-transform: lowercase;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 560;
  line-height: 1.35;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.topbar-actions a:hover {
  color: var(--text);
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 7px;
  padding: 0 10px;
  border-radius: 7px;
}

.topbar-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.lang-btn {
  display: grid;
  width: 34px;
  height: 30px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.lang-btn:hover {
  transform: translateY(-1px);
}

.lang-btn.is-active {
  border-color: rgba(215, 25, 32, 0.22);
  background: rgba(215, 25, 32, 0.08);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workflow-panel,
.preview-panel,
.attachments-panel {
  padding: 22px;
}

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

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

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

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

.preview-toolbar,
.viewer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-toolbar {
  justify-content: flex-end;
}

.toolbar-button,
.viewer-nav-button {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
}

.toolbar-button:hover:not(:disabled),
.viewer-nav-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--text);
}

.toolbar-button:disabled,
.viewer-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.toolbar-button svg,
.viewer-nav-button svg {
  width: 18px;
  height: 18px;
}

.preview-maximize {
  min-width: 122px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--red);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.2;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 780;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(22, 121, 79, 0.2);
  border-radius: 999px;
  background: rgba(22, 121, 79, 0.08);
  color: var(--green);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.meta-pill {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--muted);
}

.drop-zone {
  display: grid;
  min-height: 218px;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 22px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(251, 252, 252, 0.96)),
    repeating-linear-gradient(
      135deg,
      rgba(215, 25, 32, 0.055) 0,
      rgba(215, 25, 32, 0.055) 1px,
      transparent 1px,
      transparent 12px
    );
  color: var(--muted);
  text-align: center;
  cursor: default;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--red);
  background-color: #fff;
}

.button:focus-visible,
.icon-button:focus-visible,
.lang-btn:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.drop-zone strong {
  color: var(--text);
  font-size: 18px;
  font-weight: 780;
  line-height: 1.2;
}

.drop-zone span {
  font-size: 14px;
}

.drop-icon,
.empty-preview svg {
  width: 38px;
  height: 38px;
  color: var(--red);
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 740;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button-primary {
  width: 100%;
  background: var(--red);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.button-light {
  border-color: var(--border);
  background: var(--surface-raised);
}

.button-light:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: #fff;
}

.button-ghost {
  border-color: var(--border);
  background: #fff;
}

.button-ghost:hover {
  border-color: var(--red);
  color: var(--red);
}

.button-coffee {
  border-color: rgba(242, 183, 5, 0.44);
  background: #fff;
}

.button-coffee:hover {
  border-color: var(--amber);
  color: #8a5e00;
}

.file-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 16px 0 18px;
}

.file-summary div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
}

.file-summary dt {
  margin-bottom: 3px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.file-summary dd {
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-form {
  display: grid;
  gap: 10px;
}

.password-form label {
  color: var(--text);
  font-size: 13px;
  font-weight: 730;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.password-row:focus-within {
  border-color: rgba(215, 25, 32, 0.55);
  box-shadow: var(--focus);
}

.password-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 7px 0 0 7px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 42px;
}

.password-row input:focus {
  outline: none;
}

.password-row input:disabled {
  color: var(--subtle);
  cursor: not-allowed;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 42px;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0 7px 7px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  color: var(--text);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button.toolbar-button,
.icon-button.viewer-nav-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
}

.icon-button.toolbar-button svg,
.icon-button.viewer-nav-button svg {
  width: 18px;
  height: 18px;
}

.status-message {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 620;
}

.status-message.is-error {
  color: var(--red-dark);
}

.status-message.is-success {
  color: var(--green);
}

.preview-panel {
  min-height: 472px;
}

.preview-frame {
  position: relative;
  display: grid;
  min-height: 388px;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, #f1f3f4 25%, transparent 25%),
    linear-gradient(-45deg, #f1f3f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f3f4 75%),
    linear-gradient(-45deg, transparent 75%, #f1f3f4 75%);
  background-color: #fff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#pdf-preview {
  display: none;
  max-width: 100%;
  margin: 16px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(19, 24, 30, 0.16);
}

.preview-frame.has-preview #pdf-preview {
  display: block;
}

.preview-frame.has-preview .empty-preview {
  display: none;
}

.empty-preview {
  display: grid;
  place-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-align: center;
}

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

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: var(--text);
  font-size: 14px;
  font-weight: 620;
}

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

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

.file-badge {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: rgba(215, 25, 32, 0.09);
  color: var(--red);
}

.file-badge svg {
  width: 18px;
  height: 18px;
}

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

.file-label strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.35;
}

.file-label span {
  display: block;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 620;
}

.empty-row {
  height: 82px;
  color: var(--muted);
  text-align: center;
}

.download-button {
  min-width: 112px;
}

body.viewer-open {
  overflow: hidden;
}

.viewer-overlay[hidden] {
  display: none;
}

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(246, 247, 248, 0.88);
  backdrop-filter: blur(8px);
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1280px, 100%);
  height: min(920px, calc(100vh - 48px));
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 72px rgba(20, 24, 29, 0.22);
}

.viewer-navbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.viewer-title-block {
  min-width: 0;
}

.viewer-page-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 116px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
  white-space: nowrap;
}

.viewer-frame {
  display: grid;
  min-height: 0;
  align-items: start;
  justify-items: center;
  overflow: auto;
  padding: 24px;
  background:
    linear-gradient(45deg, #f1f3f4 25%, transparent 25%),
    linear-gradient(-45deg, #f1f3f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f3f4 75%),
    linear-gradient(-45deg, transparent 75%, #f1f3f4 75%);
  background-color: #fff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

#pdf-viewer {
  display: block;
  background: #fff;
  box-shadow: 0 14px 34px rgba(19, 24, 30, 0.2);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--red-dark);
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 28px, 680px);
    padding-top: 18px;
  }

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

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: auto;
  }

  .preview-frame {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  .workflow-panel,
  .preview-panel,
  .attachments-panel {
    padding: 16px;
  }

  .brand {
    align-items: flex-start;
    font-size: 14px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .topbar-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .topbar-link,
  .topbar-actions .button,
  .topbar-actions > a:not(.button) {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .lang-switch {
    justify-content: center;
    width: 100%;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .preview-toolbar {
    display: grid;
    width: 100%;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .preview-toolbar .meta-pill {
    width: 100%;
  }

  .preview-maximize {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .viewer-overlay {
    padding: 10px;
  }

  .viewer-shell {
    height: calc(100vh - 20px);
  }

  .viewer-navbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .viewer-controls {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .viewer-page-indicator {
    min-width: 0;
    width: 100%;
  }

  #close-viewer {
    width: 100%;
  }

  .viewer-frame {
    padding: 12px;
  }

  .table-heading {
    align-items: stretch;
  }

  #download-all {
    width: 100%;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  tbody tr {
    padding: 12px;
  }

  tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }

  tbody td {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
    padding: 7px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--subtle);
    font-size: 12px;
    font-weight: 780;
    text-transform: uppercase;
  }

  tbody td:first-child,
  tbody td:last-child,
  tbody td.empty-row {
    grid-template-columns: 1fr;
  }

  tbody td:first-child::before,
  tbody td:last-child::before,
  tbody td.empty-row::before {
    display: none;
  }

  .file-cell {
    align-items: flex-start;
  }

  .download-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
