/* Karen OS: Marketing (marketing.js). The standard page header, then a white card with the toolbar and a dense table with a quiet
   header. Built on the shared classes in styles.css (.btn, .link, .msg, .dot, .schip). No inline styles. */

.mk { max-width: 1600px; min-width: 0; }
.mk-win { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.mk-count:not(:empty)::before { content: " \00b7  "; white-space: pre; }
.mk-count { font-variant-numeric: tabular-nums; }

.mk-tools { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; }
.mk-find { flex: 1 1 200px; min-width: 0; max-width: 260px; }
.mk-find input { width: 100%; }
.mk-tabs { display: flex; flex-wrap: wrap; gap: 2px 4px; min-width: 0; }
.mk-tab { border: 0; background: transparent; color: var(--muted); font: 600 14px var(--font); padding: 0 12px; min-height: 40px; border-bottom: 3px solid transparent; cursor: pointer; }
.mk-tab:hover { color: var(--ink); }
.mk-tab.on { color: var(--green-900); border-bottom-color: var(--green-700); }
.mk-tab:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }
.mk-n { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.mk-act { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-left: auto; }
.mk-act select { min-height: 40px; width: 190px; }
.mk .msg { margin: 0; padding: 8px 16px 0; }
.mk .msg:empty { display: none; }
/* Marketing "view" only: one quiet line under the toolbar instead of controls that would fail */
.mk .mk-ro { margin: 0; padding: 8px 16px 0; }

.mk-tbl { position: relative; overflow: auto; max-height: calc(100vh - 280px); min-height: 160px; }
.mk-t { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
.mk-t th { position: sticky; top: 0; z-index: 1; background: var(--ground); color: var(--grey-ink); border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; text-transform: none; padding: 8px 10px; white-space: nowrap; font-weight: 700; }
.mk-t td { border-bottom: 1px solid var(--divider); padding: 8px 10px; background: var(--surface); font-size: 14px; vertical-align: middle; }
.mk-t tbody tr[data-id] { cursor: pointer; }
.mk-t tbody tr[data-id]:hover td, .mk-t tbody tr.sel td { background: var(--green-100); }
.mk-t tbody tr[data-id]:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }
.mk-t td.mk-po { min-width: 260px; overflow-wrap: anywhere; }
.mk-t td.mk-po small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.mk-t td.mk-pl { min-width: 150px; }
.mk-t td.mk-wh, .mk-t td.mk-sx { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mk-st { display: inline-flex; align-items: center; gap: 6px; white-space: normal; }
.mk-res { color: var(--grey-ink); }
.mk-muted { color: var(--muted); }
.mk-empty { margin: 0; padding: 18px 16px; font-size: 14px; color: var(--muted); }
.mk-setup { padding: 18px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.mk-setup p { margin: 0; font-size: 14px; color: var(--muted); }

.mk-t tr.mk-open td { padding: 0; border-left: 4px solid var(--green-700); background: var(--surface); }
.mk-d { padding: 14px 16px; min-width: 0; }
.mk-why { margin: 0 0 12px; font-size: 14px; color: var(--grey-ink); }
.mk-dg { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px 16px; }
.mk-dg > * { min-width: 0; }
.mk-pic { display: flex; flex-direction: column; gap: 4px; }
.mk-pic img, .mk-ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-ctl); border: 1px dashed var(--input); background: var(--ground); display: grid; place-items: center; }
.mk-ph svg { width: 40px; height: 40px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mk-pic small { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.mk-pic small.mk-perm { color: var(--grey-ink); font-weight: 600; }
.mk-f { min-width: 0; margin-top: 10px; }
.mk-ed .mk-f:first-child { margin-top: 0; }
.mk-f label, .mk-plats legend { display: block; font-size: 12px; font-weight: 600; color: var(--grey-ink); margin: 0 0 3px; padding: 0; }
.mk-f input, .mk-f select, .mk-f textarea { width: 100%; }
.mk-f input[type="datetime-local"] { max-width: 260px; }
.mk-plats { border: 0; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 18px; }
.mk-plats legend { width: 100%; }
.mk-chk { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14px; cursor: pointer; }
.mk-counts { margin: 8px 0 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 16px; }
.mk-counts .over { color: var(--red); font-weight: 700; }
.mk-cap { margin: 0; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mk-facts { margin: 10px 0 0; font-size: 14px; color: var(--grey-ink); }
.mk-probs { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; color: var(--amber); font-size: 14px; font-weight: 600; }
.mk-probs:empty { display: none; }
.mk-d .msg { padding: 8px 0 0; }
.mk-da { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 12px; }
.mk-da .btn.primary { min-height: 44px; }
.mk-da .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.mk-da .link { min-height: 40px; display: inline-flex; align-items: center; }
.mk-da .link:disabled { opacity: 0.5; cursor: default; }
.mk-da .mk-x { margin-left: auto; font-size: 20px; min-width: 40px; justify-content: center; }

@media (max-width: 720px) {
  .mk-dg { grid-template-columns: minmax(0, 1fr); }
  .mk-act { margin-left: 0; width: 100%; }
  .mk-tbl { max-height: none; }
  .mk-pic img, .mk-ph { aspect-ratio: 16 / 9; }
  /* Each post stacks: its text, then places, time and status underneath, so nothing hides off to the side */
  .mk-t { min-width: 0; }
  .mk-t thead { display: none; }
  .mk-t, .mk-t tbody, .mk-t tr, .mk-t td { display: block; }
  .mk-t tr[data-id] { border-bottom: 1px solid var(--divider); padding: 10px 0; background: var(--surface); }
  .mk-t tbody tr[data-id]:hover, .mk-t tbody tr.sel { background: var(--green-100); }
  .mk-t td { border: 0; padding: 2px 16px; background: transparent; }
  .mk-t tbody tr[data-id]:hover td, .mk-t tbody tr.sel td { background: transparent; }
  .mk-t td.mk-po { min-width: 0; }
  .mk-t td.mk-pl, .mk-t td.mk-wh, .mk-t td.mk-sx { white-space: normal; font-size: 13px; color: var(--grey-ink); }
  .mk-t tr.mk-open { border-bottom: 1px solid var(--divider); }
  .mk-t tr.mk-open td { padding: 0; }
}

/* ---------- Photos tab: the photo library, and the photo picker on a draft ---------- */
.mk-up { padding: 12px 16px 4px; }
.mk-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px; border: 1px dashed var(--input); border-radius: var(--r-ctl); background: var(--ground); }
.mk-drop.on { border-color: var(--green-700); background: var(--green-100); }
.mk-drop .btn { min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; }
.mk-drop select { min-height: 40px; width: 200px; }
.mk-dh { font-size: 14px; color: var(--muted); }
.mk-drop .link { margin-left: auto; min-height: 40px; display: inline-flex; align-items: center; }
.mk-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 14px 16px 18px; }
.mk-card { border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mk-th { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--ground); display: grid; place-items: center; }
.mk-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk-th .mk-ph { border: 0; background: transparent; width: 100%; height: 100%; aspect-ratio: auto; }
.mk-card input, .mk-card select { width: 100%; min-width: 0; }
.mk-card select { min-height: 36px; font-size: 13px; }
.mk-pr { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.mk-pm { margin: 0; font-size: 13px; }
.mk-pn { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.mk-card .link { align-self: flex-start; min-height: 36px; display: inline-flex; align-items: center; }
.mk-pt { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.mk-up-ro { display: flex; justify-content: flex-end; }
.mk-up-ro .link { min-height: 40px; display: inline-flex; align-items: center; }

@media (max-width: 720px) {
  .mk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 10px; }
  .mk-drop .link { margin-left: 0; }
  .mk-drop select { width: 100%; }
}

/* ---------- SEO tab (marketing-seo.js): suggestions from n8n, with a status to change ---------- */
.mk-seo-tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.mk-seo-tools select { min-height: 40px; width: 165px; }
.mk-seo-t { min-width: 700px; }
.mk-seo-t td.mk-po { min-width: 280px; }
.mk-seo-t td.mk-seo-pg { min-width: 160px; max-width: 280px; overflow-wrap: anywhere; color: var(--grey-ink); font-size: 13px; }
.mk-seo-t td.mk-seo-im { white-space: nowrap; }
.mk-seo-t td.mk-seo-wh { white-space: nowrap; color: var(--grey-ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.mk-seo-t td.mk-seo-sx { white-space: nowrap; }
.mk-seo-st { min-height: 40px; width: 150px; }
.mk-seo-t tr.mk-seo-done td.mk-po b { font-weight: 600; color: var(--muted); }
.mk-seo-d { display: flex; flex-direction: column; gap: 12px; }
.mk-seo-f h3 { margin: 0 0 3px; font-size: 12px; font-weight: 600; color: var(--grey-ink); }
.mk-seo-d .mk-da { margin-top: 0; }
.mk-seo-t tbody tr[data-sid] { cursor: pointer; }
.mk-seo-t tbody tr[data-sid]:hover td, .mk-seo-t tbody tr.sel td { background: var(--green-100); }
.mk-seo-t tbody tr[data-sid]:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }

@media (max-width: 720px) {
  .mk-seo-tools { width: 100%; }
  .mk-seo-tools select { flex: 1 1 140px; width: auto; }
  .mk-seo-t { min-width: 0; }
  .mk-seo-t tr[data-sid] { border-bottom: 1px solid var(--divider); padding: 10px 0; background: var(--surface); }
  .mk-seo-t tbody tr[data-sid]:hover, .mk-seo-t tbody tr.sel { background: var(--green-100); }
  .mk-seo-t td.mk-seo-pg, .mk-seo-t td.mk-seo-im, .mk-seo-t td.mk-seo-wh, .mk-seo-t td.mk-seo-sx { white-space: normal; max-width: none; min-width: 0; font-size: 13px; }
  .mk-seo-t td.mk-seo-wh::before { content: "Reported "; }
  .mk-seo-t tbody tr[data-sid]:hover td, .mk-seo-t tbody tr.sel td { background: transparent; }
  .mk-seo-st { width: 100%; max-width: 240px; }
}

/* Audiences tab (marketing-audiences.js): the contact list and the import panel. Built on the SEO tab's table. */
.mk-seo-t tbody tr[data-aid] { cursor: pointer; }
.mk-seo-t tbody tr[data-aid]:hover td, .mk-seo-t tbody tr.sel td { background: var(--green-100); }
.mk-seo-t tbody tr[data-aid]:focus-visible { outline: 2px solid var(--green-700); outline-offset: -2px; }
.mk-seo-t td small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.mk-aud-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; padding: 10px 16px; border-bottom: 1px solid var(--divider); font-size: 14px; }
.mk-aud-sum { margin-left: 12px; white-space: nowrap; }
.mk-aud-imp { border-bottom: 1px solid var(--divider); border-left: 4px solid var(--green-700); max-width: 640px; }
.mk-aud-f { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 0; max-width: 460px; }
.mk-aud-f label { font-size: 13px; font-weight: 600; color: var(--grey-ink); }
.mk-aud-f small { color: var(--muted); font-size: 13px; }
.mk-aud-f select, .mk-aud-f input, .mk-aud-f textarea { min-height: 40px; font: inherit; }
.mk-err { color: var(--red, #A3321F); font-weight: 600; margin-top: 8px; }
.mk-ok { margin-top: 8px; }
@media (max-width: 720px) {
  .mk-seo-t tr[data-aid] { border-bottom: 1px solid var(--divider); padding: 10px 0; background: var(--surface); }
  .mk-seo-t tbody tr[data-aid]:hover, .mk-seo-t tbody tr.sel { background: var(--green-100); }
  .mk-seo-t tbody tr[data-aid]:hover td, .mk-seo-t tbody tr.sel td { background: transparent; }
  .mk-seo-t tr[data-aid] td.mk-seo-wh::before { content: none; }
}

/* Campaigns tab (marketing-campaigns.js): the editor beside a live preview of the email. */
.mk-cg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 28px; align-items: start; }
.mk-seo-t td.mk-cg-st, .mk-seo-t td.mk-cg-st .dotw { white-space: normal; }
.mk-seo-t td.mk-cg-st { min-width: 170px; max-width: 300px; }
.mk-cg-form { min-width: 0; max-width: 560px; }
.mk-cg-form .mk-aud-f { max-width: none; }
.mk-cg-form textarea { width: 100%; resize: vertical; }
.mk-cg-form input[type="text"], .mk-cg-form input[type="url"], .mk-cg-form input[type="email"], .mk-cg-form input[type="datetime-local"], .mk-cg-form select { width: 100%; max-width: 100%; }
.mk-cg-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 0 12px; }
.mk-cg-aud { border: 1px solid var(--divider); border-radius: var(--r-ctl); margin: 14px 0 0; padding: 8px 12px 12px; min-width: 0; }
.mk-cg-aud legend { font-size: 13px; font-weight: 600; color: var(--grey-ink); padding: 0 6px; }
.mk-cg-tags { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0; max-height: 132px; overflow: auto; }
.mk-cg-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; min-height: 32px; }
.mk-cg-prev { min-width: 0; position: sticky; top: 8px; }
.mk-cg-mail { border: 1px solid var(--divider); border-radius: var(--r-ctl); overflow: auto; max-height: 78vh; background: var(--surface); }
.mk-cg-set { border-bottom: 1px solid var(--divider); border-left: 4px solid var(--green-700); max-width: 640px; }
@media (max-width: 960px) {
  .mk-cg { grid-template-columns: minmax(0, 1fr); }
  .mk-cg-prev { position: static; }
  .mk-cg-two { grid-template-columns: minmax(0, 1fr); }
}
.mk-cg-rep { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 14px 0 4px; }
.mk-cg-n { display: flex; flex-direction: column; min-width: 76px; }
.mk-cg-n b { font-size: 22px; font-weight: 800; line-height: 1.1; }
.mk-cg-n span { font-size: 13px; color: var(--muted); }
.mk-cg-n.bad b { color: var(--red, #A1251B); }
.mk-cg-send { border-top: 1px solid var(--divider); margin-top: 18px; padding-top: 4px; }
.mk-cg-send h3 { margin: 12px 0 4px; }
/* Email builder: blocks you drag into order */
.mk-bl { margin: 14px 0 0; }
.mk-bl-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mk-bl-card { position: relative; border: 1px solid var(--line, #E2E8E3); border-radius: var(--r-ctl, 10px); background: var(--surface, #fff); }
.mk-bl-card.dragging { z-index: 5; border-color: var(--green-700); background: var(--green-100); pointer-events: none; opacity: .92; }
.mk-bl-card.drop-before::before, .mk-bl-card.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 2px; background: var(--green-700); }
.mk-bl-card.drop-before::before { top: -7px; }
.mk-bl-card.drop-after::after { bottom: -7px; }
.mk-bl-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--divider); min-width: 0; }
.mk-bl-n { font-size: 13px; }
.mk-bl-acts { margin-left: auto; display: flex; gap: 2px; }
.mk-bl-grip, .mk-bl-b { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; border: 0; background: transparent; color: var(--grey-ink); border-radius: 8px; cursor: pointer; }
.mk-bl-grip { cursor: grab; touch-action: none; }
.mk-bl-card.dragging .mk-bl-grip { cursor: grabbing; }
.mk-bl-grip:hover, .mk-bl-b:hover:not(:disabled) { background: var(--green-100); color: var(--green-900); }
.mk-bl-b:disabled { opacity: .35; cursor: default; }
.mk-bl-body { padding: 0 12px 12px; }
.mk-bl-body .mk-aud-f { max-width: none; }
.mk-bl-body textarea, .mk-bl-body input[type="text"], .mk-bl-body input[type="url"], .mk-bl-body select { width: 100%; max-width: 100%; }
.mk-bl-body textarea { resize: vertical; }
.mk-bl-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.mk-bl-pic { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.mk-bl-thumb { width: 120px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--divider); }
.mk-bl-file { position: relative; cursor: pointer; display: inline-flex; align-items: center; }
.mk-bl-file:focus-within { outline: 2px solid var(--green-700); outline-offset: 2px; }
.mk-bl-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
@media (max-width: 900px) { .mk-bl-three { grid-template-columns: minmax(0, 1fr); } }
.mk-bl-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 4px; }
@media (max-width: 720px) { .mk-bl-cols { grid-template-columns: minmax(0, 1fr); } .mk-bl-n { display: none; } }
/* The preview is an email, not part of the table it sits in: undo the table's own cell look so only the email's own styles apply */
.mk-t .mk-cg-mail td, .mk-t .mk-cg-mail th, .mk-t tr.mk-open .mk-cg-mail td, .mk-t tr.mk-open .mk-cg-mail th { padding: 0; border: 0; background: transparent; font-size: inherit; vertical-align: inherit; }
@media (pointer: coarse) { .mk-bl-grip, .mk-bl-b { min-width: 44px; min-height: 44px; } }

/* Phone: search first, the tabs in one scrolling row, so the posts start on the first screen */
@media (max-width: 560px) {
  .mk-find { flex-basis: 100%; max-width: none; }
  .mk-tabs { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .mk-tab { white-space: nowrap; flex: 0 0 auto; }
  .mk-act { margin-left: 0; }
}
