:root {
  --bg: #f6f7f9; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --pri: #0f766e; --pri-2: #115e59; --pri-soft: #ccfbf1;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --err: #b91c1c; --err-soft: #fee2e2; --info-soft: #e0f2fe; --info: #0369a1;
  --r: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 6px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--pri); }
.boot { padding: 40px; text-align: center; color: var(--muted); }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.hidden { display: none !important; }

/* khung chính */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0b3b38; color: #e6fffb; padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 4px 8px 16px; }
.brand img { width: 28px; height: 28px; }
.nav button { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; font: inherit; margin-bottom: 2px; }
.nav button:hover { background: rgba(255,255,255,.08); }
.nav button.on { background: var(--pri); font-weight: 600; }
.side .me { position: absolute; bottom: 14px; left: 10px; right: 10px; font-size: 12px; opacity: .85; padding: 0 8px; }
.side .me button { margin-top: 6px; }
.main { padding: 20px 24px 60px; max-width: 1280px; width: 100%; }
.topbar { display: none; }

@media (max-width: 860px) {
  .layout { display: block; }
  .side { position: static; height: auto; padding: 8px; }
  .brand { padding: 4px 6px 8px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav button { white-space: nowrap; width: auto; margin: 0; }
  .side .me { position: static; display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 0; }
  .side .me button { margin: 0; }
  .main { padding: 14px 12px 60px; }
}

/* thẻ, bảng */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 24px; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s { font-size: 12px; color: var(--pri-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f9fafb; font-weight: 600; color: #374151; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* nút, ô nhập */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #cbd5e1; background: #f8fafc; }
button.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
button.pri:hover { background: var(--pri-2); }
button.danger { color: var(--err); border-color: #fecaca; }
button.danger:hover { background: var(--err-soft); }
button.sm { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: .55; cursor: not-allowed; }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri-soft); border-color: var(--pri); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }
@media (max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: auto; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 5px; background: #f3f4f6; border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.checks label.on { background: var(--pri-soft); color: var(--pri-2); font-weight: 600; }
.checks input { margin: 0; }

/* nhãn trạng thái */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f3f4f6; color: #374151; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.tag { display: inline-block; background: #f3f4f6; border-radius: 6px; padding: 1px 7px; font-size: 12px; margin: 1px 3px 1px 0; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* chiến dịch */
.camp { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.camp .title { font-weight: 700; font-size: 15px; }
.bar { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--pri); }
.camp .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; }
@media (max-width: 700px) { .camp { grid-template-columns: 1fr; } .camp .acts { justify-content: flex-start; } }
.preview-img { max-width: 220px; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 8px; }
.msg-preview { white-space: pre-wrap; background: #e7f3ff; border-radius: 14px; padding: 8px 12px; max-width: 420px; font-size: 13px; }

/* hộp thoại */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 860px; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }

/* đăng nhập */
.auth { max-width: 380px; margin: 9vh auto; }
.auth .card { padding: 24px; }
.auth .brand { color: var(--pri-2); justify-content: center; font-size: 18px; }

.toast { position: fixed; right: 16px; bottom: 16px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 99; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--err); }
pre.code { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 300px; white-space: pre-wrap; word-break: break-all; }
