:root {
  --background: #ffffff;
  --foreground: #171717;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --primary: #262626;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --secondary-foreground: #262626;
  --accent-red: #dc2626;
  --success: #15803d;
  --danger: #b91c1c;
  --warning: #a16207;
  --radius: 0.5rem;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--foreground);
  background: var(--muted);
}

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

.app-shell {
  display: grid;
  grid-template-rows: 64px 1fr 64px;
  gap: 0.5rem;
  min-height: 100dvh;
  padding: 0.5rem;
}

.topbar,
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-weight: 600;
}

.brand svg {
  width: 2.5rem;
  height: 2.5rem;
  fill: var(--accent-red);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  color: var(--muted-foreground);
  font-size: 1.25rem;
}

.nav a:hover,
.nav a.active {
  color: var(--foreground);
}

.nav a.active {
  font-weight: 700;
}

.flag-nav {
  display: flex;
  align-items: center;
}

.swiss-flag {
  display: block;
  width: 45px;
  height: 45px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  image-rendering: pixelated;
}

.footer-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.footer-contact a:hover,
.footer-brand:hover {
  color: var(--foreground);
}

.footer-brand {
  margin: 0;
  font-weight: 700;
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.test-mode-note {
  margin: 0;
  max-width: 18rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: right;
}

.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 23, 23, 0.45);
}

.pin-gate[hidden] {
  display: none;
}

body.pin-locked {
  overflow: hidden;
}

.pin-dialog {
  width: min(24rem, calc(100vw - 2rem));
  padding: 2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  text-align: center;
}

.pin-dialog h2 {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.pin-slots {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.pin-slot {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--muted);
  text-align: center;
  font-size: 1.25rem;
}

.pin-slot:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.pin-error {
  margin: 1rem 0 0;
  color: var(--danger);
}

.content {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
}

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  min-height: 70vh;
  text-align: center;
}

.home h1,
.page-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
}

.home-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(20rem, 100%);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.05);
}

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

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-color: var(--border);
}

.btn-large {
  min-height: 6rem;
  font-size: 1.5rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.type-layout {
  display: grid;
  gap: 2rem;
  max-width: 56rem;
  margin: 0 auto;
}

.upload-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding-top: 2rem;
}

.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(32rem, 100%);
  min-height: 18rem;
  padding: 1.5rem;
  border: 4px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--muted);
  text-align: center;
  color: var(--muted-foreground);
  cursor: pointer;
}

.dropzone.is-dragover {
  border-style: solid;
  color: var(--foreground);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.history {
  display: grid;
  gap: 0.75rem;
}

.history h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

.history-meta {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.table th {
  color: var(--muted-foreground);
  font-weight: 500;
}

.table a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge.queued,
.badge.processing {
  background: #fef3c7;
  color: var(--warning);
}

.badge.completed {
  background: #dcfce7;
  color: var(--success);
}

.badge.failed {
  background: #fee2e2;
  color: var(--danger);
}

.badge.sent {
  background: #dbeafe;
  color: #1d4ed8;
  margin-left: 0.35rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.status-panel,
.docs-panel,
.send-result {
  display: grid;
  gap: 1rem;
}

.status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 16rem;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  text-align: center;
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.docs-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.doc-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.doc-card iframe {
  width: 100%;
  min-height: 22rem;
  border: 0;
  border-radius: 0.25rem;
  background: #fff;
}

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

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

.banner {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fffbeb;
  color: var(--warning);
  font-size: 0.875rem;
}

.success-banner {
  width: min(32rem, 100%);
  background: #dcfce7;
  color: var(--success);
}

.error-banner {
  width: min(32rem, 100%);
  background: #fee2e2;
  color: var(--danger);
}

.success-banner a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-panel {
  display: grid;
  place-items: center;
  min-height: 18rem;
  padding: 2rem 1rem;
}

.login-dialog {
  width: min(24rem, 100%);
}

.login-dialog .page-title {
  font-size: 1.25rem;
  margin: 0 0 1rem;
  text-align: center;
}

.pin-form {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.send-result--failed h3,
.send-result--partial h3 {
  color: var(--danger);
}

.dropzone-copy {
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}

.selected-files-list {
  margin: 0;
  padding-left: 1.25rem;
  text-align: left;
  color: var(--foreground);
  font-size: 0.875rem;
}

.send-result {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.send-result ul {
  margin: 0;
  padding-left: 1.25rem;
}

.empty {
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  text-align: center;
}

@media (max-width: 720px) {
  .nav {
    gap: 0.75rem;
  }

  .table th:nth-child(3),
  .table td:nth-child(3) {
    display: none;
  }
}
