:root {
  --bg: #0f1420;
  --panel: #171d2b;
  --panel-2: #1e2638;
  --line: #2a3450;
  --text: #e7ecf5;
  --muted: #93a0bb;
  --accent: #4f8cff;
  --accent-2: #36d6a0;
  --warn: #f0a24b;
  --danger: #ef5d6b;
  --ok: #36d6a0;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
/* The [hidden] attribute must always win over component display rules
   (.gate/.run-banner set display:grid/flex, which would otherwise override it). */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
h1, h2 { margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
.muted { color: var(--muted); margin: 0; }
.brand { font-weight: 700; letter-spacing: 0.02em; display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); }
.brand .sub { color: var(--muted); font-weight: 500; padding-left: 10px; border-left: 1px solid var(--line); }
.logo { height: 22px; width: auto; display: block; }
.logo-lg { height: 30px; }

/* Login gate */
.gate { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2740, var(--bg)); }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 40px; width: 360px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.gate-card h1 { font-size: 22px; margin-top: 12px; }
.gate-card p { color: var(--muted); margin: 6px 0 24px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 8px;
  font: inherit; cursor: pointer; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }

/* Buttons / inputs */
.btn { font: inherit; border-radius: 8px; padding: 8px 16px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-ok { background: var(--ok); color: #06241a; border: 0; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.select, input.field, textarea.field { background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
textarea.field { min-height: 70px; resize: vertical; }

/* Cards / groups */
.group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; }
.group h3 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.param { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 16px; }
.param label { font-weight: 600; }
.param .help { color: var(--muted); font-size: 12.5px; }
.param-row { display: flex; gap: 10px; align-items: flex-start; }
.param-row .field { flex: 1; }
.locked { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.locked:first-of-type { border-top: 0; }
.locked .lock { color: var(--warn); font-size: 12px; }

/* Proposals */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.seo { color: #8fb7ff; border-color: #355; } .badge.content { color: #b69cff; }
.badge.keyword { color: #7fe7c4; } .badge.ads { color: #f0a24b; }
.badge.risk-high { color: var(--danger); border-color: var(--danger); }
.badge.risk-medium { color: var(--warn); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.exec-cms_create { color: var(--accent-2); border-color: var(--accent-2); }
.badge.exec-page_auto { color: var(--accent); border-color: var(--accent); }
.badge.exec-manual { color: var(--warn); border-color: var(--warn); }
.card-foot { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-foot .spinner { display: inline-block; vertical-align: middle; margin-right: 4px; }
.instr { width: 100%; white-space: pre-wrap; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 12.5px; }
.card h4 { margin: 0; font-size: 15px; }
.card .target { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.trash { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 14px; opacity: .5; padding: 2px 4px; line-height: 1; }
.trash:hover { opacity: 1; }
.diff { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.diff .old { color: var(--danger); } .diff .new { color: var(--ok); }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }

/* Pipeline graph */
.graph { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; padding: 8px; }
.graph svg { display: block; }
.node rect { rx: 9; }
.legend { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.run-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.run-banner { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 6px; }
.run-line { display: flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); text-align: center; padding: 40px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 50; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* Filters + meta */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.when { color: var(--muted); font-size: 12px; }
#proposals-count { margin-bottom: 10px; font-size: 12.5px; }
.diff.old { color: var(--danger); }
.diff.new { color: var(--ok); }

/* Question-mark tooltip */
.qmark { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 6px;
  border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 11px; font-weight: 600;
  cursor: help; vertical-align: middle; }
.qmark:hover { color: var(--text); border-color: var(--accent); }
/* Instant CSS tooltip (the native title= tooltip has a ~1s delay). */
.qmark::after {
  content: attr(data-help);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: 240px; padding: 8px 10px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-size: 12px; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: normal;
  text-align: left; white-space: normal; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0; visibility: hidden; transition: opacity .1s; z-index: 60; pointer-events: none;
}
.qmark:hover::after { opacity: 1; visibility: visible; }

/* Modal / editor */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 10, 18, .72); }
.modal-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: min(820px, 92vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-actions:empty { display: none; }
.field-block { margin-bottom: 16px; }
.field-block h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field-block p { margin: 0 0 6px; }
.bullets { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.bullets li { line-height: 1.5; }
.editor { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  min-height: 220px; max-height: 50vh; overflow-y: auto; line-height: 1.6; }
.editor:focus { outline: none; border-color: var(--accent); }
.editor h2, .editor h3 { margin: 14px 0 6px; }
.editor p { margin: 0 0 10px; }
.editor a { color: var(--accent); }

/* Cover image */
.cover-row { display: flex; gap: 14px; align-items: center; }
.cover-preview { width: 180px; height: 102px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); display: grid; place-items: center; overflow: hidden; flex: none; }
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: flex; flex-direction: column; gap: 8px; }
.cover-prompt { margin-top: 12px; display: grid; gap: 6px; }
.cover-prompt label { font-size: 12px; color: var(--muted); }
