* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
  color: #1c1e21;
  line-height: 1.5;
}
header {
  background: linear-gradient(135deg, #1877f2, #0a3d91);
  color: #fff;
  padding: 20px 24px;
}
header h1 { font-size: 22px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
header .sub { opacity: 0.9; font-size: 13px; margin-top: 4px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: #ffb300; color: #000; font-weight: 600;
}
.badge.real { background: #00c853; color: #fff; }

main { max-width: 1000px; margin: 20px auto; padding: 0 16px; display: grid; gap: 20px; }
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card h2 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card h3 { font-size: 14px; margin: 16px 0 8px; color: #1877f2; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: #444; gap: 4px; }
label.full { grid-column: 1 / -1; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
input, select, textarea {
  padding: 8px 10px; border: 1px solid #ccd0d5; border-radius: 6px; font-size: 13px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #1877f2; }
label.check input { width: auto; }

button {
  margin-top: 16px; background: #1877f2; color: #fff; border: none;
  padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { background: #166fe0; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.msg { margin-left: 12px; font-size: 13px; }
.msg.ok { color: #00a152; } .msg.err { color: #d32f2f; }

.muted { color: #666; font-size: 13px; margin-bottom: 10px; }

/* Gói cước */
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.plan { border: 2px solid #e4e6eb; border-radius: 10px; padding: 16px; display: flex; flex-direction: column; }
.plan.cur { border-color: #00a152; }
.plan h4 { font-size: 16px; margin-bottom: 4px; }
.plan .price { font-size: 22px; font-weight: 700; color: #1877f2; margin-bottom: 8px; }
.plan .price small { font-size: 12px; font-weight: 400; color: #888; }
.plan ul { list-style: none; font-size: 12.5px; color: #444; margin-bottom: 12px; display: grid; gap: 4px; }
.plan ul li::before { content: '✓ '; color: #00a152; font-weight: 700; }
.plan .buy { margin-top: auto; }
.order-box { margin-top: 14px; background: #f7f8fa; border: 1px solid #e4e6eb; border-radius: 8px; padding: 14px; text-align: center; }
.order-box img { max-width: 220px; width: 100%; border: 1px solid #eee; border-radius: 8px; background:#fff; }
.order-box .ck { font-size: 13px; text-align: left; display: inline-block; margin-top: 10px; }
.order-box .ck b { color: #d32f2f; }
.pay-status { margin-top: 10px; font-weight: 600; }
.badge.warn { background: #ff9800; color: #fff; }
.badge.red { background: #d32f2f; color: #fff; }

/* Đăng nhập / đăng ký */
.auth-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #1877f2, #0a3d91); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.auth-box { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.auth-box h1 { font-size: 24px; margin-bottom: 4px; }
.auth-tabs { display: flex; gap: 6px; margin: 16px 0; background: #f0f2f5; border-radius: 8px; padding: 4px; }
.auth-tab { flex: 1; background: none; color: #444; margin: 0; padding: 8px; border-radius: 6px; font-size: 14px; }
.auth-tab.active { background: #1877f2; color: #fff; }
#authForm { display: grid; gap: 12px; }
#authForm label { font-size: 13px; font-weight: 600; color: #444; display: grid; gap: 4px; }
#authForm button[type=submit] { margin-top: 6px; }
.tpl-box { background: #eef4ff; border: 1px solid #cfe0ff; border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.tpl-note { margin-top: 10px; font-size: 12.5px; color: #333; background: #fff; border-left: 3px solid #1877f2; border-radius: 6px; padding: 8px 10px; line-height: 1.5; }
.ind-btns { display: block; }
.ind-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ind-label { font-size: 12px; font-weight: 600; color: #555; margin-bottom: 6px; }
.ind-btn { background: #fff; border: 1px solid #cfe0ff; color: #1877f2; border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; margin: 0; }
.ind-btn:hover { background: #e7f0ff; }
.ind-btn.active { background: #1877f2; color: #fff; border-color: #1877f2; }
.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 10px; }
.tpl-card { position: relative; background: #fff; border: 1px solid #e4e6eb; border-radius: 8px; padding: 10px; cursor: pointer; transition: .15s; }
.tpl-del { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; line-height: 1; padding: 0; margin: 0; border: none; border-radius: 50%; background: #ffe3e3; color: #d32f2f; font-size: 15px; cursor: pointer; }
.tpl-del:hover { background: #d32f2f; color: #fff; }
.tpl-card:hover { border-color: #1877f2; box-shadow: 0 2px 8px rgba(24,119,242,.15); }
.tpl-card.active { border-color: #1877f2; background: #f0f6ff; }
.tpl-card b { font-size: 13px; display: block; margin-bottom: 3px; }
.tpl-card small { font-size: 11px; color: #777; line-height: 1.4; }
.tpl-card .tag { display: inline-block; font-size: 10px; background: #eef4ff; color: #1877f2; padding: 1px 7px; border-radius: 8px; margin-top: 5px; }
.rules-box { background: #f7f8fa; border: 1px dashed #ccd0d5; border-radius: 8px; padding: 12px; }
.rules-logic { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.rules-logic select { width: auto; }
.rule-row { display: grid; grid-template-columns: 2fr 90px 1.2fr 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.rule-row select, .rule-row input { padding: 7px 8px; font-size: 13px; }
.rule-del { background: #d32f2f; color: #fff; border: none; border-radius: 6px; cursor: pointer; height: 34px; font-size: 16px; line-height: 1; }
.rule-del:hover { background: #b71c1c; }
.rules-badge { font-size: 11px; color: #d32f2f; }
@media (max-width: 700px) { .rule-row { grid-template-columns: 1fr 70px 1fr 32px; } }
.tabs { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 10px; padding: 8px 12px; background: #f0f2f5; border-radius: 6px; }
.tabs .check { font-size: 13px; }
.hint { font-weight: 400; color: #888; font-size: 11px; margin-top: 2px; }

/* Dashboard báo cáo */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #f7f8fa; border: 1px solid #e4e6eb; border-radius: 8px; padding: 12px; }
.stat .v { font-size: 20px; font-weight: 700; color: #1877f2; }
.stat .l { font-size: 11px; color: #666; margin-top: 2px; }
.stat.green .v { color: #00a152; } .stat.red .v { color: #d32f2f; } .stat.orange .v { color: #ff9800; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.hl { font-size: 12px; padding: 10px; border-radius: 8px; border-left: 3px solid #ccc; background: #fafbfc; }
.hl.good { border-color: #00a152; background: #e6f7ec; }
.hl.bad { border-color: #d32f2f; background: #ffeaea; }
.hl b { display: block; font-size: 11px; color: #666; font-weight: 600; margin-bottom: 3px; }
.table-wrap { overflow-x: auto; }
#reportTable { width: 100%; border-collapse: collapse; font-size: 12px; }
#reportTable th, #reportTable td { padding: 8px 10px; text-align: right; border-bottom: 1px solid #eee; white-space: nowrap; }
#reportTable th:first-child, #reportTable td:first-child { text-align: left; }
#reportTable th { background: #f0f2f5; font-size: 11px; color: #444; position: sticky; top: 0; }
#reportTable tbody tr:hover { background: #f7f8fa; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.ACTIVE { background: #00a152; } .dot.PAUSED { background: #d32f2f; }

.list { display: grid; gap: 12px; }
.empty { color: #888; font-size: 13px; }
.camp {
  border: 1px solid #e4e6eb; border-radius: 8px; padding: 14px; display: grid; gap: 8px;
}
.camp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.camp-head strong { font-size: 15px; }
.pill { font-size: 11px; padding: 2px 10px; border-radius: 10px; font-weight: 600; }
.pill.ACTIVE { background: #e3f9e5; color: #00a152; }
.pill.PAUSED { background: #ffeaea; color: #d32f2f; }
.meta { font-size: 12px; color: #666; display: flex; gap: 16px; flex-wrap: wrap; }
.bar { height: 8px; background: #e4e6eb; border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: #00c853; transition: width .3s; }
.bar > div.warn { background: #ff9800; } .bar > div.over { background: #d32f2f; }
.camp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.camp-actions button { margin: 0; padding: 6px 12px; font-size: 12px; }
.btn-pause { background: #d32f2f; } .btn-pause:hover { background: #b71c1c; }
.btn-check { background: #607d8b; } .btn-check:hover { background: #455a64; }
.reason { font-size: 12px; color: #d32f2f; font-style: italic; }
.rules-badge { font-size: 11px; color: #d32f2f; }
.scale-badge { font-size: 11px; color: #00796b; font-weight: 600; }
.btn-scale { background: #00897b; } .btn-scale:hover { background: #00695c; }
.recs { display: grid; gap: 5px; margin-top: 4px; }
.rec { font-size: 12px; padding: 6px 10px; border-radius: 6px; line-height: 1.35; }
.rec-good { background: #e6f7ec; color: #00713c; border-left: 3px solid #00a152; }
.rec-warn { background: #fff6e5; color: #8a5b00; border-left: 3px solid #ff9800; }
.rec-bad  { background: #ffeaea; color: #b3261e; border-left: 3px solid #d32f2f; }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  header { padding: 14px 16px; }
  header h1 { font-size: 19px; }
  main { margin: 12px auto; padding: 0 10px; gap: 14px; }
  .card { padding: 14px; }
  .card h2 { font-size: 16px; }
  /* iOS không tự phóng to khi focus nếu input >= 16px */
  input, select, textarea { font-size: 16px; }
  .camp-actions button { flex: 1 1 auto; }
  #reportTable th, #reportTable td { padding: 7px 8px; }
  .rules-logic select, .rules-logic { width: 100%; }
  .rules-logic select { flex: 1 1 auto; }
}
