:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --ok: #16a34a;
  --bad: #dc2626;
  --idle: #9ca3af;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.header {
  background: linear-gradient(135deg, #3b82f6, var(--primary));
  color: #fff;
  border-bottom-left-radius: 26px;
  border-bottom-right-radius: 26px;
  box-shadow: var(--shadow);
  transition: padding 0.25s ease, border-radius 0.25s ease;
}

.header h1 {
  margin: 0;
  text-align: center;
  font-size: 25px;
  line-height: 1.1;
  transition: font-size 0.25s ease, letter-spacing 0.25s ease;
}

.content {
  padding: 5px;
  display: grid;
  gap: 5px;
  transition: padding-top 0.25s ease;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border: 1px solid rgba(229, 231, 235, 0.7);
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.row:last-child {
  margin-bottom: 0;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  padding-left: 2px;
}

input[type='text'],
input[type='date'],
select {
  width: 100%;
  min-height: 50px;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 18px;
  letter-spacing: 0.3px;
  color: var(--text);
  outline: none;
  background: #fff;
}

input[type='text']:focus,
input[type='date']:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.scan-btn {
  min-width: 64px;
  min-height: 64px;
  border: none;
  border-radius: 16px;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  box-shadow: var(--shadow);
}

.status-card {
  text-align: center;
}

.status-indicator {
  width: 50px;
  height: 50px;
  margin: 4px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  font-weight: 700;
  color: #fff;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.status-idle {
  background: var(--idle);
}

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

.status-bad {
  background: var(--bad);
}

.flash {
  transform: scale(1.06);
}

.status-title {
  margin: 0 0 8px;
  font-size: 25px;
}

.status-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
  word-break: break-word;
}

.footer-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.action-btn {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 20px 24px;
  font-weight: 700;
  box-shadow: var(--shadow);
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.4px;
  color: #ffffff;
}

.action-btn.reset {
  background: #111827;
}

.action-btn.history {
  background: var(--primary);
}

.action-btn:active {
  transform: scale(0.98);
}

.history-card.hidden {
  display: none;
}

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

.history-title {
  margin: 0;
  font-size: 22px;
}

.history-close {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  background: #111827;
  color: #fff;
}

.history-filters {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.filter-group-search {
  grid-column: 1 / -1;
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.small-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
}

.small-btn.secondary {
  background: #111827;
}

.delete-btn {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bad);
  color: #fff;
  white-space: nowrap;
}

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

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

.history-table th {
  background: #f9fafb;
  color: var(--text);
  font-weight: 700;
}

.history-empty {
  text-align: center !important;
  color: var(--muted);
  padding: 18px 12px;
}

.result-ok {
  color: var(--ok);
  font-weight: 700;
}

.result-bad {
  color: var(--bad);
  font-weight: 700;
}

/* ===== Mode historique ===== */

.app.history-mode .header {
  padding: 28px 16px;
  border-bottom-left-radius: 32px;
  border-bottom-right-radius: 32px;
}

.app.history-mode .header h1 {
  font-size: 32px;
  letter-spacing: 0.5px;
}

.app.history-mode .content {
  padding-top: 10px;
}

@media (max-width: 500px) {
  #historyBtn{
    display: none;
  }
}