:root {
  --brand: #0b3b5c;
  --brand-bright: #2d9cdb;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #14212b;
  --muted: #5b6b78;
  --border: #d9e0e6;
  --danger: #b3261e;
  --success: #146c43;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1418;
    --surface: #161f26;
    --text: #eaf0f4;
    --muted: #9fb0bc;
    --border: #27343d;
    --danger: #ff8a80;
    --success: #7ee2a8;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}

.app-header__title {
  font-weight: 600;
  font-size: 16px;
}

.app-header__logo {
  border-radius: 6px;
}

.app-header__offline {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
}

.screen-host {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen[hidden] {
  display: none;
}

h1 {
  font-size: 20px;
  line-height: 1.3;
  margin: 0;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

.error {
  color: var(--danger);
  font-weight: 500;
}

.success {
  color: var(--success);
  font-weight: 500;
}

.request-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.request-card__label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.request-card__provider {
  font-size: 18px;
  font-weight: 600;
}

.request-card__case {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
}

.checklist li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.checklist li::before {
  content: '';
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--brand-bright);
}

.actions {
  display: grid;
  gap: 10px;
}

.actions[hidden] {
  display: none;
}

.button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

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

.button--ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  min-height: 44px;
  font-weight: 500;
}

.button[disabled],
.button[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.file-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  word-break: break-all;
}

.pages-header h1 {
  margin-bottom: 4px;
}

.pages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.page-card {
  display: flex;
  align-items: stretch;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.page-card__thumb {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  height: 112px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.page-card__thumb--pdf {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.page-card__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.page-card__title {
  font-weight: 600;
}

.page-card__meta {
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

.page-card__remove {
  flex: 0 0 auto;
  align-self: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.page-card__remove:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-card--busy {
  opacity: 0.6;
}

.stage {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.stage[hidden] {
  display: none;
}

.stage__text p:first-child {
  font-weight: 600;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress[hidden] {
  display: none;
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--brand-bright);
  transition: width 120ms linear;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--brand-bright);
  animation: spin 900ms linear infinite;
  margin: 24px auto 8px;
}

.spinner--inline {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: 0 0 auto;
}

.spinner[hidden] {
  display: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

.status-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  margin: 8px auto 0;
}

.status-icon--warn {
  background: var(--danger);
}

.app-footer {
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}
