:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --brass: #b8860b;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #22272e;
  --muted: #6b7380;
  --line: #e3e6ea;
  --green: #1e7f3c;
  --green-bg: #e2f3e8;
  --red: #b42318;
  --red-bg: #fdebe9;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--navy); text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand { font-weight: 700; font-size: 17px; color: #fff; }
.topbar .brand span { color: #e9c46a; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  color: #d6def0;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar .who { font-size: 13px; color: #c7d2e8; }
.topbar form { margin: 0; }

/* ---------- Layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px; }
.page-title { font-size: 21px; font-weight: 700; margin: 2px 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .num { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat .lbl { font-size: 13px; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cfd5dc;
  border-radius: 7px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
}
textarea { min-height: 110px; resize: vertical; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border: 0;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--navy-dark); }
.btn.gold { background: var(--brass); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: #eef1f5; color: var(--navy); }
.btn.danger { background: var(--red); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #fafbfc; }
tr:hover td { background: #f7f9fb; }
.table-card { padding: 0; overflow-x: auto; }

/* ---------- Badges / status ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.pending { background: #fff4e0; color: #9a6700; }
.badge.done { background: var(--green-bg); color: var(--green); }
.badge.role { background: #e8edf5; color: var(--navy); }

.flip {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  border: 0;
}
.flip.yes { background: var(--green-bg); color: var(--green); }
.flip.no { background: var(--red-bg); color: var(--red); }
.flip.readonly { cursor: default; opacity: .8; }

/* ---------- Image grid ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.img-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.img-card .thumb { width: 100%; height: 140px; object-fit: cover; display: block; background: #eceff3; }
.img-card .meta { padding: 9px 11px; }
.img-card .meta .nm { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-card .meta .sub { font-size: 12px; color: var(--muted); }
.img-card .acts { display: flex; gap: 12px; flex-wrap: wrap; padding: 0 11px 11px; }

.thumb-mini { width: 54px; height: 40px; object-fit: cover; border-radius: 5px; background: #eceff3; display: block; }

/* ---------- Flash ---------- */
.flash { padding: 11px 15px; border-radius: 8px; margin-bottom: 15px; font-size: 14px; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.err { background: var(--red-bg); color: var(--red); }
.flash ul { margin: 4px 0 0 18px; padding: 0; }

/* ---------- Login / setup ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.auth-card { background: #fff; border-radius: 14px; padding: 34px; width: 400px; max-width: 92vw; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.auth-card p.sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); font-size: 13px; }
.url-chip {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  background: #f0f2f5;
  padding: 3px 8px;
  border-radius: 6px;
  word-break: break-all;
}
.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13.5px;
}
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }
details.skipped { margin-top: 8px; font-size: 13px; }
.copy-done { color: var(--green); font-weight: 700; }

/* Copy keyword icon */
.copy-kw {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 6px;
  padding: 1px 7px;
  margin-left: 6px;
  font-size: 15px;
  cursor: pointer;
  vertical-align: middle;
}
.copy-kw:hover { background: #eef1f5; }
.copy-kw.copied { color: var(--green); border-color: var(--green); }

/* Upload result popup (stays until OK is pressed) */
.popup-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 25, 40, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.popup-box {
  background: #fff; border-radius: 14px; padding: 28px 30px 24px;
  width: 420px; max-width: 100%; text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.popup-icon {
  width: 58px; height: 58px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700;
}
.popup-box.ok .popup-icon { background: var(--green-bg); color: var(--green); }
.popup-box.bad .popup-icon { background: var(--red-bg); color: var(--red); }
.popup-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.popup-box.ok .popup-title { color: var(--green); }
.popup-box.bad .popup-title { color: var(--red); }
.popup-text { color: var(--text); font-size: 14.5px; }
.popup-ok { margin-top: 18px; min-width: 120px; font-size: 15px; padding: 10px 22px; }

/* Upload + Delete on one line in keyword rows */
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.row-actions form { margin: 0; }
input[type=file].file-mini { width: 200px; padding: 5px 6px; font-size: 13px; }

/* Social media description box */
.caption-row td { border-top: none !important; padding-top: 0 !important; background: #fbfcfd; }
.caption-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 2px 0 4px; }
.caption-box { display: flex; gap: 8px; align-items: flex-start; }
.caption-box .caption-text { min-height: 58px; font-size: 13px; line-height: 1.45; flex: 1; margin: 0; }
.caption-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 64px; }
.caption-note { font-size: 11px; text-align: center; }
.img-card .caption-box { flex-direction: column; }
.img-card .caption-actions { flex-direction: row; align-items: center; }

/* One rounded box per keyword / image: main row + description row together */
.table-card.grouped { padding: 4px 12px 8px; }
.group-table { border-collapse: separate; border-spacing: 0; background: transparent; }
.group-table th { border-bottom: 1px solid var(--line); }
.group-table td { border-bottom: none; }
.group-table tr:hover td { background: inherit; }
.group-table tr.grp-top td { background: #fff; border-top: 1.5px solid #cfd6e0; }
.group-table tr.grp-top td:first-child { border-left: 1.5px solid #cfd6e0; border-top-left-radius: 12px; }
.group-table tr.grp-top td:last-child { border-right: 1.5px solid #cfd6e0; border-top-right-radius: 12px; }
.group-table tr.grp-bottom td { background: #f8fafc; border-bottom: 1.5px solid #cfd6e0; padding-bottom: 12px; }
.group-table tr.grp-bottom td:first-child { border-left: 1.5px solid #cfd6e0; border-bottom-left-radius: 12px; }
.group-table tr.grp-bottom td:last-child { border-right: 1.5px solid #cfd6e0; border-bottom-right-radius: 12px; }
.group-table tr.grp-gap td { height: 14px; padding: 0; border: none; background: transparent; }

/* Prompt box and description box side by side inside one keyword box */
.text-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .text-pair { grid-template-columns: 1fr; } }

/* Website checkboxes grouped by business (Users page) */
.biz-group { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
.biz-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13.5px; }

/* Dashboard progress bar */
.bar { display: inline-block; width: 90px; height: 8px; background: #eceff3; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bar-fill { height: 100%; background: var(--green); }
.stats { flex-wrap: wrap; }
.stat .of { font-size: 18px; font-weight: 600; color: var(--muted); }
.stat .pct { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.bar.wide { display: block; width: 100%; height: 9px; margin: 8px 0 0; }
.small-stats .stat .num { font-size: 20px; }

/* Dashboard progress circle */
.rings-wrap { display: flex; align-items: center; gap: 34px; flex-wrap: wrap; }
.rings { max-width: 100%; height: auto; }
.rings-num { font-size: 30px; font-weight: 800; fill: var(--navy); }
.rings-sub { font-size: 12px; fill: var(--muted); }
.rings-legend { flex: 1; min-width: 260px; }
.rl-row { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--line); }
.rl-num { width: 22px; height: 22px; border-radius: 50%; background: #eef1f5; color: var(--navy); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rl-label { font-weight: 600; font-size: 14px; }
.rl-val { font-size: 13px; color: var(--text); margin-top: 2px; }

/* Dashboard animated progress circle (pure CSS + SVG) */
.pie-wrap { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.pie-stage { position: relative; width: 360px; max-width: 100%; }
.pie3 { width: 100%; height: auto; display: block; overflow: visible; }
.pie-slice { transform-origin: 180px 180px; scale: .6; opacity: 0; cursor: pointer;
  transition: translate .25s ease, filter .25s ease; animation: piePop .7s cubic-bezier(.2,1.3,.4,1) forwards; }
.pie-slice:hover { translate: var(--dx) var(--dy); filter: brightness(1.08) saturate(1.1); }
@keyframes piePop { to { scale: 1; opacity: 1; } }
.pie-labels { pointer-events: none; opacity: 0; animation: pieFade .6s ease .9s forwards; }
@keyframes pieFade { to { opacity: 1; } }
.pie-label { font-size: 13px; font-weight: 800; fill: #fff; paint-order: stroke; stroke: rgba(10,20,40,.35); stroke-width: 3px; letter-spacing: .2px; }
.pie-val { font-size: 12.5px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(10,20,40,.35); stroke-width: 3px; }
.pie-center { font-size: 30px; font-weight: 800; fill: var(--navy); }
.pie-center-sub { font-size: 11.5px; fill: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.pie-orbit { fill: none; stroke: #b9c4d3; stroke-width: 1.5; stroke-dasharray: 2 9; transform-origin: 180px 180px; animation: pieSpin 40s linear infinite; }
.pie-orbit-2 { stroke: #d7a43b; stroke-dasharray: 60 420; stroke-width: 2.5; stroke-linecap: round; animation-duration: 6s; opacity: .8; }
@keyframes pieSpin { to { transform: rotate(360deg); } }
.pie-hub-glow { fill: #5eeaa0; opacity: .35; transform-origin: 180px 180px; animation: piePulse 2.8s ease-in-out infinite; }
@keyframes piePulse { 0%,100% { transform: scale(1); opacity: .25; } 50% { transform: scale(1.12); opacity: .5; } }
.pie-tip { position: absolute; pointer-events: none; background: #0f1b33; color: #fff; font-size: 12.5px; line-height: 1.5;
  padding: 7px 10px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.2); white-space: nowrap; z-index: 5; }
.pie-note { flex: 1; min-width: 220px; font-size: 14px; line-height: 2; }
.pie-key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.pie-spin-btn { position: absolute; top: 0; right: 0; z-index: 4; border: 1px solid var(--line); background: #fff; color: var(--navy);
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 99px; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.pie-spin-btn:hover { background: #f4f6f9; }
.pie-still .pie-orbit, .pie-still .pie-hub-glow { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .pie-slice, .pie-labels { animation: none; scale: 1; opacity: 1; }
  .pie-orbit, .pie-hub-glow { animation: none; }
}

/* Copy URL and Download kept apart so the wrong one is not pressed by mistake */
.btn-stack { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

/* Bulk delete */
.bulk-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0; }
.img-card { position: relative; }
.bulk-card-cb { position: absolute; top: 8px; left: 8px; z-index: 2; background: rgba(255,255,255,.92); border-radius: 6px; padding: 3px 5px; margin: 0; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.bulk-card-cb input { width: 16px; height: 16px; margin: 0; vertical-align: middle; }

/* Text link instead of a picture (faster pages) */
.img-link { display: inline-block; font-weight: 700; font-size: 13px; color: var(--green, #15803d); background: #e8f6ee; border-radius: 99px; padding: 4px 10px; white-space: nowrap; text-decoration: none; }
.img-link:hover { background: #d4efdf; }

/* Top loading bar */
#pageLoadBar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: #d7a43b; z-index: 9999; opacity: 0; }
#pageLoadBar.run { opacity: 1; width: 85%; transition: width 4s cubic-bezier(.1,.7,.2,1); }
