:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --border: #e9ecef;
  --text: #212529;
  --muted: #6c757d;
  --primary: #2c7be5;
  --success: #00b374;
  --danger: #e63757;
  --warning: #f6c343;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* NAV */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 600; font-size: 16px; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
}
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: #e8f0fd; color: var(--primary); font-weight: 500; }

/* LAYOUT */
.container { max-width: 900px; margin: 0 auto; padding: 24px 16px; }

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }
.next-draw { font-size: 13px; color: var(--muted); }

/* CARDS */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.card-actions { margin-top: 16px; }

/* PREDICTION */
.prediction-card { text-align: center; }
.prediction-digits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 16px 0;
}
.digit-box {
  width: 72px; height: 72px;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  font-size: 36px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.digit-sep { font-size: 18px; color: var(--muted); }
.agent-pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.pill.pass { background: #d6f5e9; color: #00614a; }
.pill.fail { background: #fde8ec; color: #9b1f34; }
.pred-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.no-pred { color: var(--muted); padding: 24px 0; font-size: 15px; }

/* STATS ROW */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* TRAIL */
.trail { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.trail-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  cursor: default;
}
.trail-dot.hit  { background: #d6f5e9; color: #00614a; }
.trail-dot.miss { background: #fde8ec; color: #9b1f34; }

/* TABLE */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.result-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}
.result-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.result-table tr:last-child td { border-bottom: none; }
.hit-row td { background: #f0fdf7; }
.miss-row td { background: #fff8f8; }
.hit  { color: var(--success); font-weight: 600; }
.miss { color: var(--danger);  font-weight: 600; }

/* PERIOD BADGE */
.period-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.period-badge.1st  { background: #e8f0fd; color: var(--primary); }
.period-badge.16th { background: #fef5d4; color: #7a5800; }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 13px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border 0.15s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--primary); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* BUTTONS */
.btn {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1a68d1; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e9ecef; }
.btn-full { width: 100%; text-align: center; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* SETTINGS */
.settings-section { margin-bottom: 28px; }
.settings-section-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.toggle-group { display: flex; align-items: center; justify-content: space-between; }
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* AGENT CARDS */
.agent-card { margin-bottom: 16px; }
.agent-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.agent-name { font-size: 16px; font-weight: 600; }
.agent-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.pass { background: #d6f5e9; color: #00614a; }
.status-badge.fail { background: #fde8ec; color: #9b1f34; }
.agent-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.agent-stat { text-align: center; }
.agent-variation { font-size: 12px; color: var(--muted); padding: 8px 0; border-top: 1px solid var(--border); }
.agent-history { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }

/* ALERTS */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-success { background: #d6f5e9; color: #00614a; }
.alert-error   { background: #fde8ec; color: #9b1f34; }
.alert-info    { background: #e8f0fd; color: #0c4da2; }

/* RESULT SUMMARY */
.result-summary .result-outcome {
  font-size: 28px;
  font-weight: 700;
  margin: 12px 0;
}
.stats-mini { margin-top: 12px; font-size: 13px; display: flex; gap: 20px; }
.next-sug { margin-top: 12px; font-size: 13px; color: var(--muted); }

/* PRED PREVIEW */
.pred-preview {
  background: #f0f4ff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
.pred-preview-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.pred-preview-digits { font-size: 22px; font-weight: 700; color: var(--primary); }

/* FILTER ROW */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.filter-row select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.total-count { margin-left: auto; font-size: 13px; color: var(--muted); }
