[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c1e21;
  --muted: #65676b;
  --line: #e4e6eb;
  --brand: #1b5ef0;
  --brand-ink: #ffffff;
  --brand-soft: #e8efff;
  --red: #d93025;
  --red-soft: #fdecea;
  --green: #138a3e;
  --green-soft: #e6f4ea;
  --violet: #6b3fd4;
  --violet-soft: #efe9fc;
  --blue-soft: #e3f0fd;
  --gray-soft: #eef0f3;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Lao", "Leelawadee UI", "Phetsarath OT", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--brand); }
code { background: var(--gray-soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
h2 small, h2 .count { color: var(--muted); font-weight: 500; font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; margin: 0; accent-color: var(--brand); }
button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  font-weight: 600;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--brand); color: var(--brand-ink); }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.ghost:hover { background: var(--gray-soft); }
.ghost.danger { color: var(--red); }
.sm { padding: 5px 10px; font-size: 13px; }
.link { background: none; border: none; padding: 0; color: var(--brand); font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.err { color: var(--red); }
.warn { background: #fff7e0; border: 1px solid #f2d68a; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.loading-screen { text-align: center; color: var(--muted); margin-top: 20vh; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand span { color: var(--brand); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.top nav button { background: none; color: var(--muted); padding: 7px 12px; }
.top nav button:hover { background: var(--gray-soft); color: var(--ink); }
.top nav button.on { background: var(--brand-soft); color: var(--brand); }
.who { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.role { font-size: 12px; background: var(--gray-soft); padding: 2px 8px; border-radius: 99px; color: var(--muted); }
.dry { background: #fff3cd; color: #7a5b00; text-align: center; font-size: 13px; padding: 6px; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.empty { text-align: center; padding: 40px 20px; }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login button { width: 100%; margin-top: 18px; }

/* compose layout */
.compose { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.compose .timing { grid-column: 1 / -1; }
@media (max-width: 900px) { .compose { grid-template-columns: 1fr; } }

.seg { display: inline-flex; background: var(--gray-soft); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: none; color: var(--muted); padding: 6px 14px; font-size: 14px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.media { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb, .add { width: 92px; height: 92px; border-radius: 8px; overflow: hidden; position: relative; background: var(--gray-soft); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 22px;
}
.add {
  display: flex; align-items: center; justify-content: center; margin: 0; cursor: pointer;
  border: 2px dashed #c7ccd4; color: var(--muted); font-size: 28px; font-weight: 400; background: #fafbfc;
}
.add:hover { border-color: var(--brand); color: var(--brand); }
.progress { font-size: 13px; color: var(--brand); align-self: center; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.row h2 { margin: 0; flex: 1; }
.row select { width: auto; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--ink); font-size: 14px; cursor: pointer; }

.pages { display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow: auto; }
.pageItem { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pageItem.sel { border-color: var(--brand); background: #f7f9ff; }
.pick { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--ink); font-weight: 500; font-size: 14px; cursor: pointer; }
.pageItem textarea { margin-top: 8px; font-size: 14px; }
.av { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }

.timing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.timeline ol { margin: 10px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.timeline li { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: var(--gray-soft); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.timeline li b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline li span { white-space: nowrap; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.tag.gray { background: var(--gray-soft); color: var(--muted); }
.tag.blue { background: var(--blue-soft); color: var(--brand); }
.tag.violet { background: var(--violet-soft); color: var(--violet); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }

/* history */
.jobs { display: flex; flex-direction: column; }
.job { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.job:first-child { border-top: none; }
.jthumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--gray-soft); display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; }
.jhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jcap { font-size: 14px; margin: 2px 0; white-space: pre-wrap; word-break: break-word; }
.jmeta { font-size: 12px; color: var(--muted); }
.jerr { font-size: 13px; color: var(--red); background: var(--red-soft); padding: 6px 8px; border-radius: 6px; margin-top: 6px; }
.jact { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.jact a { font-size: 13px; font-weight: 600; }
.batch { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 14px 0 4px; border-top: 2px solid var(--line); }
.batch:first-child { border-top: none; padding-top: 0; }

/* drafts */
.drafts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.draft { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.draft .dcap { font-size: 14px; white-space: pre-wrap; max-height: 120px; overflow: hidden; color: var(--ink); }
.draft .dmedia { display: flex; gap: 4px; }
.draft .dmedia img, .draft .dmedia div { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; background: var(--gray-soft); }
.draft .dfoot { display: flex; gap: 6px; margin-top: auto; align-items: center; }
.draft .dfoot .hint { flex: 1; margin: 0; }

/* admin */
.steps { padding-left: 20px; font-size: 14px; }
.steps li { margin: 4px 0; }
.plist, .ulist { display: flex; flex-direction: column; }
.prow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.prow:first-child { border-top: none; }
.pname { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pname small { color: var(--muted); }
.switch { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-size: 13px; color: var(--ink); font-weight: 500; cursor: pointer; }
.urow { padding: 12px 0; border-top: 1px solid var(--line); }
.urow:first-child { border-top: none; }
.uhead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
.uperm { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; margin: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.chip:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.inline { display: grid; grid-template-columns: 1fr 1fr 150px auto; gap: 8px; }
@media (max-width: 700px) { .inline { grid-template-columns: 1fr; } }
.settings { max-width: 560px; }

/* toast */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 40px); }
.toast { background: #1c1e21; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 420px; }
.toast.err { background: var(--red); }

@media (max-width: 600px) {
  main { padding: 12px; }
  .job { grid-template-columns: 40px 1fr; }
  .jthumb { width: 40px; height: 40px; }
  .jact { grid-column: 2; flex-direction: row; align-items: center; }
}

.fbbtn {
  display: inline-flex; align-items: center; gap: 8px; margin: 6px 0;
  background: #1877f2; color: #fff; text-decoration: none; font-weight: 700;
  padding: 11px 20px; border-radius: 8px;
}
.fbbtn::before { content: "f"; font: 800 18px/1 Helvetica, Arial, sans-serif; background: #fff; color: #1877f2; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: flex-end; justify-content: center; }
.fbbtn:hover { filter: brightness(1.08); }
details.alt { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
details.alt summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }

/* báo cáo quảng cáo */
.adsbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.adsbar select { width: auto; max-width: 100%; }
.adsrange { display: inline-flex; gap: 6px; align-items: center; }
.adsrange input { width: auto; }
.adsconn { margin: 10px 0 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kl { font-size: 13px; color: var(--muted); font-weight: 600; }
.kv { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.charts .card { margin-bottom: 16px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart path { fill: var(--brand); }
.chart .bar.hover path { fill: #0f47c2; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .base { stroke: var(--line); stroke-width: 1; }
.cmax { font-size: 12px; color: var(--muted); margin: -6px 0 4px; }
.ctip { position: absolute; pointer-events: none; background: #1c1e21; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.adtable { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.adtable th, .adtable td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.adtable th { background: #fafbfc; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; }
.adtable th:hover { color: var(--ink); }
.adtable .namecol { text-align: left; position: sticky; left: 0; background: var(--card); min-width: 220px; max-width: 320px; white-space: normal; z-index: 1; }
.adtable th.namecol { background: #fafbfc; z-index: 2; }
.adtable tbody tr:hover td { background: #f7f9ff; }
.adtable tfoot td { font-weight: 700; background: #fafbfc; border-bottom: none; }
.rn { font-weight: 600; color: var(--ink); }
.rs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; font-size: 12px; color: var(--muted); }

/* gợi ý tối ưu */
.advice h3 { font-size: 15px; margin: 18px 0 8px; display: flex; gap: 6px; align-items: center; }
.advice .row h2 { flex: 1; }
.tgt { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.tgt input { width: 150px; }
.advsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.advsum > div { background: var(--gray-soft); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.advl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.adv { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.advh { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.advr { font-size: 14px; color: var(--muted); margin-top: 4px; }
.adva { font-size: 14px; margin-top: 2px; }

/* nhiều nick */
.logins { display: flex; flex-direction: column; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.login-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.login-row:first-child { border-top: none; }
.adsnicks { margin-top: 12px; }
.adsnicks .logins { margin-top: 10px; }

/* lý do chi tiết + thanh toán */
.advdt { font-size: 13px; font-weight: 600; margin-top: 6px; }
.advd { margin: 2px 0 4px; padding-left: 20px; font-size: 13.5px; color: var(--ink); }
.advd li { margin: 2px 0; }
.billing .row h2 { flex: none; margin-right: 4px; }
.bill-kpis { margin: 10px 0 6px; }
.ks { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kv-sm { font-size: 16px; }
.muted { color: var(--muted); font-weight: 500; font-size: 16px; }
.meter { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bill-form { grid-template-columns: 1fr 1fr auto; margin-top: 8px; }

/* gợi ý đăng bài */
.pn { display: flex; flex-direction: column; min-width: 0; }
.pn .lg { display: inline-block; font-size: 11px; color: var(--muted); background: var(--gray-soft); padding: 0 6px; border-radius: 99px; font-weight: 600; width: fit-content; }
.rh { font-size: 12px; color: var(--muted); font-weight: 400; }
.stale { font-size: 13px; background: #fff7e0; border: 1px solid #f2d68a; border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chk { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.chk.err { border-color: #f3b8b3; background: #fffafa; }
.chk .tag { flex: none; margin-top: 1px; }
.chk .hint { margin: 2px 0 0; }
.hitw mark { background: var(--red-soft); color: var(--red); padding: 0 4px; border-radius: 4px; font-weight: 600; }
.golden { background: #fffbea; border: 1px solid #f5e3a3; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.golden .gl { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.chip.gold { background: #fff; border: 1px solid #e8c95c; color: var(--ink); font-weight: 500; padding: 5px 12px; border-radius: 99px; font-size: 13px; }
.chip.gold:hover { background: #fff3c4; }
.chip.gold b { color: var(--green); margin-left: 4px; }
.jstats { font-size: 12.5px; color: var(--ink); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.jstats .hint { flex-basis: 100%; margin: 0; }
select.lang { width: auto; padding: 5px 8px; font-size: 13px; }

/* ngôn ngữ + cài app */
.langbtn { background: var(--gray-soft); color: var(--ink); border: 1px solid var(--line); padding: 4px 10px; font-size: 13px; border-radius: 99px; }
.langbtn:hover { background: var(--brand-soft); color: var(--brand); }
.loginlang { display: flex; justify-content: flex-end; margin: -6px -6px 6px 0; }
.installbtn { background: var(--brand); color: #fff; padding: 4px 10px; font-size: 13px; border-radius: 99px; }
.remote .url { font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--gray-soft); padding: 10px 12px; border-radius: 8px; word-break: break-all; }
.remote .qr { margin-top: 12px; width: 180px; height: 180px; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.remote .qr img, .remote .qr canvas { width: 100% !important; height: 100% !important; }

/* điện thoại */
@media (max-width: 700px) {
  input, textarea, select { font-size: 16px; } /* tránh iPhone tự phóng to khi gõ */
  .top { padding: 8px 12px calc(0px) 12px; gap: 6px 10px; }
  .brand { font-size: 15px; flex: 1; }
  .who { font-size: 13px; gap: 6px; }
  .top nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 6px; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav button { flex: none; padding: 8px 12px; }
  main { padding: 10px; }
  .card { padding: 14px; border-radius: 10px; }
  .timing-grid { grid-template-columns: 1fr; gap: 6px; }
  .thumb, .add { width: 84px; height: 84px; }
  .pages { max-height: none; }
  .pageItem { padding: 10px; }
  .pick input[type=checkbox] { width: 20px; height: 20px; }
  .compose .timing .actions {
    position: sticky; bottom: 0; z-index: 5; margin: 14px -14px -14px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line); border-radius: 0 0 10px 10px;
  }
  .compose .timing .actions button { flex: 1; padding: 12px; }
  #toasts { bottom: calc(80px + env(safe-area-inset-bottom)); right: 12px; left: 12px; }
  .toast { max-width: none; }
  .chk { padding: 8px 10px; }
  .golden .chips .chip { flex: 1 1 auto; }
}
@media (max-width: 700px) { .who .role { display: none; } }

.btnlink { display: inline-block; text-decoration: none; padding: 7px 14px; border-radius: 8px; font-weight: 600; }
