:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --ok-bg: #f0fdf4;
  --ok-border: #22c55e;
  --ok-text: #15803d;
  --err-bg: #fef2f2;
  --err-border: #ef4444;
  --err-text: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(180deg, #eff6ff 0%, var(--bg) 260px);
  color: var(--text);
  max-width: 1140px;
  margin: 2rem auto;
  padding: 0 1.25rem 3rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.form-sheet {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.form-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.form-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.muted {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.toolbar-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn:hover {
  background: var(--surface-alt);
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.btn-danger:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

fieldset {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 1.5rem 0;
  padding: 1.5rem 1.75rem;
  overflow-x: auto;
}

legend {
  float: left;
  width: 100%;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--primary);
  padding: 0 0 0.85rem 0;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

fieldset > *:not(legend) {
  clear: both;
}

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

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

tr:last-child td { border-bottom: none; }

th {
  background: var(--surface-alt);
  color: #475569;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: #f8fafc; }

td.center, th.center { text-align: center; width: 64px; }

tr.is-pf {
  background: var(--accent-soft);
  font-weight: 600;
}

tr.is-pf:hover { background: #dbeafe; }

tr.auto-pf {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  background: var(--surface-alt);
  color: #334155;
  border: 1px solid var(--border-strong);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.25rem;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.feedback-item {
  border-left: 4px solid;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.fb-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.fb-err {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.kpi-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
}

.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.55rem;
}

.progress-fill {
  height: 100%;
  background: #16a34a;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.pill-ok { background: #dcfce7; color: #166534; }
.pill-miss { background: #fee2e2; color: #991b1b; }

.filter-bar {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: end;
  border-radius: var(--radius-sm);
}

code {
  background: var(--surface-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  body { margin: 1rem auto; padding: 0 0.75rem; }
  .form-header, fieldset { padding: 1.15rem; }
  .form-header h1 { font-size: 1.15rem; }
}
