:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #b45309;
  --ok: #166534;
  --error: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 45%);
  color: var(--ink);
}

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px;
}

.hero {
  margin-bottom: 16px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
}

.hero p {
  margin: 0;
  color: var(--muted);
}

.app-version {
  margin: 6px 0 0;
  color: #0f766e;
  font-weight: 700;
  font-size: 0.9rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.05);
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.offscreen-input {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.col-grow {
  flex: 1;
  min-width: 240px;
}

button {
  appearance: none;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
}

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

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

button.muted {
  background: #475569;
}

label {
  display: block;
  margin: 8px 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.95rem;
}

.scanner {
  width: 100%;
  max-width: 460px;
  min-height: 220px;
  margin-bottom: 10px;
}

.scanner-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
}

.scanner-overlay-btn {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 5;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scanner-overlay-btn:hover {
  background: rgba(15, 23, 42, 0.9);
}

.scanner-overlay-btn svg {
  width: 23px;
  height: 23px;
  fill: currentColor;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.24s ease, visibility 0.24s ease;
  z-index: 50;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 14px;
  box-shadow: 0 24px 48px rgba(2, 6, 23, 0.22);
  padding: 18px;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.24s ease;
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-card.error {
  border-color: #fecaca;
}

.modal-card h3 {
  margin: 8px 0 6px;
  font-size: 1.02rem;
}

.modal-card p {
  margin: 0;
  color: #475569;
}

.modal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.modal-badge.ok {
  background: #ecfdf3;
  color: #166534;
}

.modal-badge.error {
  background: #fef2f2;
  color: #b91c1c;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.status {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #334155;
}

.status.ok {
  background: #ecfdf3;
  color: var(--ok);
}

.status.warn {
  background: #fff7ed;
  color: var(--warn);
}

.status.error {
  background: #fef2f2;
  color: var(--error);
}

.status.info {
  background: #f1f5f9;
  color: #334155;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.stats span {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
}

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

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px 6px;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

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