:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 14px 14px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.topbar .nav-link {
  font-size: 0.85rem;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  background: #e0f2fe;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.hidden {
  display: none !important;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.qr-viewport {
  width: 100%;
  min-height: 260px;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.input,
.textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.textarea {
  min-height: 110px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.99);
}

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

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-choice {
  padding: 16px;
  font-size: 1.05rem;
  margin-bottom: 10px;
  text-align: left;
  justify-content: space-between;
}

.btn-choice span.sub {
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.9;
}

.btn-trosak {
  background: #0369a1;
  color: #fff;
}

.btn-ulaz {
  background: #0f766e;
  color: #fff;
}

.btn-neutral {
  background: #334155;
  color: #fff;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--success-bg);
  color: #14532d;
  border-color: #86efac;
}

.alert-warn {
  background: var(--warn-bg);
  color: #78350f;
  border-color: #fcd34d;
}

.alert-danger {
  background: var(--danger-bg);
  color: #7f1d1d;
  border-color: #fca5a5;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 12px 0;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.meta-item .label {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.meta-item .value {
  font-weight: 700;
  font-size: 0.98rem;
  word-break: break-word;
}

.amount-big {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
}

.stack-sm > * + * {
  margin-top: 10px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
}

.history-list li:last-child {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-ok { background: var(--success-bg); color: #14532d; }
.badge-warn { background: var(--warn-bg); color: #78350f; }
.badge-err { background: var(--danger-bg); color: #7f1d1d; }
.badge-info { background: #e0f2fe; color: #075985; }

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

.stat-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.stat-box strong {
  display: block;
  font-size: 1.25rem;
}

.stat-box span {
  font-size: 0.78rem;
  color: var(--muted);
}

.row-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-inline .btn {
  width: auto;
  white-space: nowrap;
}

details.history-details summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

details.history-details summary::-webkit-details-marker {
  display: none;
}

details.history-details summary::after {
  content: '▾';
  font-size: 0.9rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

details.history-details[open] summary::after {
  transform: rotate(180deg);
}

details.history-details[open] .details-body {
  margin-top: 12px;
}

