* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green: #1a472a;
  --green-light: #2d6a4f;
  --bg: #f7f9f7;
  --card: #fff;
  --border: #e0e4e0;
  --text: #1a1a1a;
  --muted: #6b7280;
  --danger: #b91c1c;
  --ok: #15803d;
  --warn: #c2410c;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.view { min-height: 100vh; }
.hidden { display: none !important; }

/* LOGIN */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
}
.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 22px; color: var(--green); margin-bottom: 4px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 24px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.login-card input {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--green); border-color: var(--green); }
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--green-light); }
.error { color: var(--danger); margin-top: 12px; font-size: 13px; min-height: 18px; }

/* APP */
header {
  background: var(--green);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
header h1 { font-size: 18px; font-weight: 600; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
nav button:hover { background: rgba(255,255,255,.1); }
nav button.active { background: #fff; color: var(--green); }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }
h2 { font-size: 20px; margin-bottom: 16px; color: var(--green); }
h3 { font-size: 15px; margin: 24px 0 12px; color: var(--text); }

/* Dashboard cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--card);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.card .kpi { font-size: 28px; font-weight: 700; color: var(--green); }
.card .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Tables */
table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-collapse: collapse;
  overflow: hidden;
}
th, td { padding: 10px 12px; text-align: left; font-size: 13px; }
th { background: #f1f5f1; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr + tr { border-top: 1px solid var(--border); }

/* Forms */
form { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 20px; flex-wrap: wrap; }
form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
form select, form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-width: 160px;
}
form button {
  padding: 9px 18px;
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
form button:hover { background: var(--green-light); }

/* Preview list */
#preview-list { display: grid; gap: 12px; }
.preview-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: flex-start;
}
.preview-item.approved { border-color: var(--ok); background: #f0fdf4; }
.preview-item.rejected { opacity: .5; }
.preview-item .to { font-weight: 600; }
.preview-item .subject { color: var(--muted); font-size: 13px; margin-top: 4px; }
.preview-item .body-preview {
  margin-top: 8px;
  padding: 12px;
  background: #fafafa;
  border-radius: 6px;
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
}
.preview-item .actions { display: flex; gap: 6px; }
.preview-item .actions button { padding: 4px 10px; font-size: 12px; }

#btn-launch {
  margin-top: 24px;
  padding: 14px 28px;
  font-size: 16px;
  background: var(--ok);
}

/* WhatsApp filters */
.wa-filters { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-warn { background: #fed7aa; color: var(--warn); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-muted { background: #f1f5f9; color: var(--muted); }

/* Kill switch */
.sec-kill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 2px solid var(--danger);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc; transition: .3s; border-radius: 34px;
}
.slider:before {
  position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px;
  background: white; transition: .3s; border-radius: 50%;
}
.switch input:checked + .slider { background: var(--danger); }
.switch input:checked + .slider:before { transform: translateX(26px); }

/* Status chips */
.chip-green { background: #dcfce7; color: #15803d; padding: 4px 10px; border-radius: 12px; font-weight: 600; font-size: 12px; }
.chip-amber { background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 12px; font-weight: 600; font-size: 12px; }
.chip-red   { background: #fee2e2; color: #991b1b; padding: 4px 10px; border-radius: 12px; font-weight: 600; font-size: 12px; }

.primary-btn {
  background: var(--green); color: white; border: 0;
  padding: 10px 18px; border-radius: 6px; cursor: pointer; font-weight: 500;
  margin-bottom: 16px;
}
.primary-btn:hover { background: var(--green-light); }

#cb-status { background: #fff; border: 1px solid var(--border); padding: 16px; border-radius: 8px; margin-bottom: 16px; }

@media (max-width: 720px) {
  header { padding: 12px 16px; }
  main { padding: 12px; }
  form { flex-direction: column; align-items: stretch; }
  form label, form select, form input, form button { width: 100%; }
  nav button { font-size: 12px; padding: 5px 10px; }
}
