.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s ease;
  font-size: var(--text-sm);
  background: var(--bg-soft);
  color: var(--text-strong);
  text-decoration: none;
}

.btn:hover { text-decoration: none; box-shadow: var(--shadow-md); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-accent { background: var(--rust); color: #fff8ef; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.2rem; font-size: var(--text-base); }
.btn-block { width: 100%; }

.form-group { margin-bottom: var(--space-4); }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: var(--text-sm);
}
.form-input,
.form-select,
textarea.form-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}
.pin-input {
  letter-spacing: 0.4em;
  font-size: 1.4rem;
  text-align: center;
  font-weight: 700;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header, .card-body { padding: var(--space-4); }
.card-header { border-bottom: 1px solid var(--border); }
.card-title { margin: 0; }

.stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.stat-label { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.45rem; font-weight: 800; margin-top: 4px; }
.stat-value.pos { color: var(--lime); }
.stat-value.neg { color: #ff6b6b; }

.alert {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  border: 1px solid transparent;
}
.alert-success { background: var(--lime-soft); color: #0b7a24; border-color: #7be08f; }
[data-theme="dark"] .alert-success { color: #9ff0b0; border-color: #1e6b32; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
[data-theme="dark"] .alert-danger { background: #3a1515; color: #fecaca; border-color: #7f1d1d; }
.alert-warning { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
[data-theme="dark"] .alert-warning { background: #3a2410; color: #fdba74; border-color: #9a3412; }
.alert-info { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; }
.table tbody tr:nth-child(even) { background: var(--table-stripe); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-pass, .badge-won, .badge-proceed { background: var(--lime-soft); color: #0b7a24; }
.badge-fail, .badge-lost, .badge-abort { background: #fee2e2; color: #991b1b; }
.badge-warn, .badge-reduce { background: #ffedd5; color: #9a3412; }
.badge-pending { background: #e5e7eb; color: #374151; }
[data-theme="dark"] .badge-pass,
[data-theme="dark"] .badge-won,
[data-theme="dark"] .badge-proceed { color: #9ff0b0; }
[data-theme="dark"] .badge-fail,
[data-theme="dark"] .badge-lost,
[data-theme="dark"] .badge-abort { background: #3a1515; color: #fecaca; }
[data-theme="dark"] .badge-warn,
[data-theme="dark"] .badge-reduce { background: #3a2410; color: #fdba74; }
[data-theme="dark"] .badge-pending { background: #1e293b; color: #cbd5e1; }

.match-list { display: grid; gap: var(--space-3); }
.match-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.match-card.is-selected { border-color: var(--lime); box-shadow: 0 0 0 2px rgba(0, 200, 45, 0.25); }
.match-top {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  justify-content: space-between;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  margin-top: var(--space-3);
}
.filter-chip {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.filter-chip.pass { color: #0b7a24; }
.filter-chip.fail { color: #991b1b; }
[data-theme="dark"] .filter-chip.pass { color: #9ff0b0; }
[data-theme="dark"] .filter-chip.fail { color: #fecaca; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  text-align: center;
  background: var(--bg-soft);
}
.sticky-bar {
  position: sticky;
  bottom: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
}

.slip {
  max-width: 520px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.slip-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-6);
}
.tabs a {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
}
.tabs a.is-active { background: var(--charcoal); color: #fff8ef; }

.accordion details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  padding: var(--space-3) var(--space-4);
}
.accordion summary { cursor: pointer; font-weight: 700; }

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  background: #64748b;
  border-radius: 999px;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
}
.switch input:checked + span { background: var(--lime); }
.switch input:checked + span::after { transform: translateX(20px); }

.chart-box { height: 220px; }
.update-log {
  background: var(--bg-soft);
  padding: var(--space-3);
  overflow: auto;
  max-height: 240px;
  font-size: 12px;
}

@media print {
  .app-header, .app-sidebar, .no-print { display: none !important; }
  .app { display: block; }
  .slip { box-shadow: none; }
}
