/* ============================================================
   KontenFlow — app styles (light SaaS look, indigo brand)
   ============================================================ */
:root {
  --brand: #4f46e5; --brand-600: #4338ca; --brand-50: #eef2ff; --brand-100: #e0e7ff; --brand-200: #c7d2fe;
  --bg: #f8fafc; --card: #ffffff; --border: #e2e8f0; --border-soft: #f1f5f9;
  --text: #0f172a; --text-2: #334155; --text-3: #64748b; --text-4: #94a3b8;
  --green: #059669; --green-50: #ecfdf5; --green-200: #a7f3d0;
  --amber: #d97706; --amber-50: #fffbeb; --amber-200: #fde68a;
  --red: #dc2626; --red-50: #fef2f2; --red-200: #fecaca;
  --blue: #2563eb; --blue-50: #eff6ff;
  --purple: #7c3aed; --purple-50: #f5f3ff;
  --slate-100: #f1f5f9; --slate-200: #e2e8f0;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 4px 20px -2px rgba(15,23,42,.05), 0 2px 6px -1px rgba(15,23,42,.03);
  --shadow-lg: 0 10px 25px -3px rgba(15,23,42,.10);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 256px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.hide-sm { display: inline; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .25s ease; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 17px; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 28px; max-width: 1400px; width: 100%; }
.menu-btn, .sidebar-close, .sidebar-backdrop { display: none; }

.brand { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 18px; border-bottom: 1px solid var(--border-soft); }
.brand-logo { width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), #818cf8); color: #fff; display: grid; place-items: center; font-size: 16px; box-shadow: 0 6px 14px -4px rgba(79,70,229,.5); }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--text-4); font-weight: 500; }

.profile-switch { padding: 14px 12px 6px; }
.profile-switch-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-4); padding: 0 6px; display: block; margin-bottom: 6px; }
.profile-switch-box { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--green); color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; flex-shrink: 0; }
.profile-select { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 700; font-size: 13px; color: var(--text); min-width: 0; cursor: pointer; }
.profile-select:focus { outline: none; }
.profile-switch-meta { font-size: 11px; color: var(--text-4); padding: 6px 8px 0; }

.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-4); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--text-2); font-weight: 500; font-size: 13.5px; margin-bottom: 2px; transition: background .15s; }
.nav-item i { width: 18px; text-align: center; color: var(--text-4); font-size: 14px; }
.nav-item:hover { background: var(--slate-100); color: var(--text); }
.nav-item.active { background: var(--brand-50); color: var(--brand); font-weight: 700; }
.nav-item.active i { color: var(--brand); }
.sidebar-foot { padding: 10px 12px 14px; border-top: 1px solid var(--border-soft); }
.version { font-size: 10.5px; color: var(--text-4); padding: 8px 12px 0; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head h3 i { color: var(--brand); }
.card.clickable { cursor: pointer; transition: transform .18s, box-shadow .18s; }
.card.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.page-intro { margin-bottom: 20px; }
.page-intro p { color: var(--text-3); }

.stat { padding: 16px 18px; }
.stat .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .value small { font-size: 12px; font-weight: 600; color: var(--text-4); margin-left: 4px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 11px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: all .15s; white-space: nowrap; line-height: 1.2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px -4px rgba(79,70,229,.5); }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-secondary { background: var(--card); border-color: var(--border); color: var(--text-2); }
.btn-secondary:hover:not(:disabled) { background: var(--slate-100); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--slate-100); }
.btn-danger { background: var(--red-50); color: var(--red); border-color: var(--red-200); }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { background: transparent; border: 0; color: var(--text-3); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: inline-grid; place-items: center; font-size: 14px; }
.icon-btn:hover { background: var(--slate-100); color: var(--text); }
.btn .fa-spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label, label.lbl { font-size: 12px; font-weight: 700; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-4); font-weight: 400; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-2); transition: all .12s; }
.chip:hover { border-color: var(--brand-200); }
.chip.active { background: var(--brand-50); color: var(--brand); border-color: var(--brand-200); }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.style-tile { padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; cursor: pointer; font-weight: 600; font-size: 12.5px; background: var(--card); display: flex; align-items: center; gap: 8px; transition: all .12s; }
.style-tile i { color: var(--text-4); }
.style-tile:hover { border-color: var(--brand-200); }
.style-tile.active { background: var(--brand-50); border-color: var(--brand); color: var(--brand); }
.style-tile.active i { color: var(--brand); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap; }
.badge-idea     { background: var(--slate-100); color: var(--text-3); border-color: var(--border); }
.badge-creating { background: var(--amber-50); color: var(--amber); border-color: var(--amber-200); }
.badge-ready    { background: var(--blue-50); color: var(--blue); border-color: #bfdbfe; }
.badge-posted   { background: var(--green-50); color: var(--green); border-color: var(--green-200); }
.badge-settled  { background: var(--purple-50); color: var(--purple); border-color: #ddd6fe; }
.badge-neutral  { background: var(--slate-100); color: var(--text-2); border-color: var(--border); }
.badge-brand    { background: var(--brand-50); color: var(--brand); border-color: var(--brand-200); }
.badge-low      { background: var(--green-50); color: var(--green); border-color: var(--green-200); }
.badge-review   { background: var(--amber-50); color: var(--amber); border-color: var(--amber-200); }
.badge-high     { background: var(--red-50); color: var(--red); border-color: var(--red-200); }
.badge-active { background: var(--green-50); color: var(--green); border-color: var(--green-200); }
.badge-paused { background: var(--amber-50); color: var(--amber); border-color: var(--amber-200); }
.badge-completed { background: var(--purple-50); color: var(--purple); border-color: #ddd6fe; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-4); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fafbfd; }
.table .actions { white-space: nowrap; text-align: right; }
.status-select { padding: 4px 8px; font-size: 12px; border-radius: 8px; width: auto; font-weight: 600; }

/* ---------- Alerts / empties ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert-danger { background: var(--red-50); border-color: var(--red-200); color: #991b1b; }
.alert-warn { background: var(--amber-50); border-color: var(--amber-200); color: #92400e; }
.alert-info { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-600); }
.alert-success { background: var(--green-50); border-color: var(--green-200); color: #065f46; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty i { font-size: 28px; color: var(--text-4); margin-bottom: 10px; display: block; }
.empty h4 { color: var(--text-2); margin-bottom: 4px; }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--slate-100); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #818cf8); border-radius: 99px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; animation: fadeIn .15s; }
.modal { background: var(--card); border-radius: 18px; width: 100%; max-width: 620px; box-shadow: 0 25px 60px -10px rgba(15,23,42,.35); animation: pop .18s; }
.modal.wide { max-width: 860px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; gap: 9px; align-items: center; animation: pop .2s; max-width: 380px; }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1200px 600px at 20% -10%, var(--brand-100), transparent), var(--bg); padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 32px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.login-card h2 { margin-top: 4px; }
.login-card .form { margin-top: 18px; }

/* ---------- Idea cards ---------- */
.idea-card { display: flex; flex-direction: column; gap: 10px; }
.idea-card .hook { font-style: italic; color: var(--text-2); border-left: 3px solid var(--brand-200); padding-left: 10px; }
.idea-card .meta { font-size: 12px; color: var(--text-3); }
.idea-card .foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.similar-box { background: var(--amber-50); border: 1px solid var(--amber-200); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: #92400e; }

/* ---------- Builder ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--text-4); background: var(--card); border: 1px solid var(--border); }
.step .n { width: 20px; height: 20px; border-radius: 6px; background: var(--slate-100); display: grid; place-items: center; font-size: 11px; }
.step.done { color: var(--green); border-color: var(--green-200); } .step.done .n { background: var(--green-50); }
.step.current { color: var(--brand); border-color: var(--brand-200); background: var(--brand-50); } .step.current .n { background: var(--brand-100); }
.image-card { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: #fbfcfe; }
.image-card .image-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.image-card .image-head .n { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--brand); text-transform: uppercase; }
.image-card input.role { width: auto; font-size: 12px; padding: 4px 8px; }
.image-card input.headline { font-weight: 700; font-size: 15px; margin-bottom: 8px; }
.image-card textarea { font-size: 13px; min-height: 90px; }
.flag { border: 1px solid var(--amber-200); background: var(--amber-50); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.flag.applied { border-color: var(--green-200); background: var(--green-50); }
.flag.kept { border-color: var(--border); background: var(--slate-100); opacity: .85; }
.flag .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--text-4); }
.flag .orig { font-weight: 600; color: var(--red); }
.flag .sugg { font-weight: 600; color: var(--green); }
.flag p { margin: 2px 0 8px; }
.prompt-box { background: var(--text); color: #e2e8f0; border-radius: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; }
.disclaimer { font-size: 11.5px; color: var(--text-4); margin-top: 8px; }
.risk-banner { border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; border: 1px solid; }
.risk-banner.low { background: var(--green-50); border-color: var(--green-200); color: #065f46; }
.risk-banner.review { background: var(--amber-50); border-color: var(--amber-200); color: #92400e; }
.risk-banner.high { background: var(--red-50); border-color: var(--red-200); color: #991b1b; }
.risk-banner strong { font-size: 14px; letter-spacing: .04em; }
.summary-line { font-size: 12.5px; color: var(--text-3); }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.filters select, .filters input { padding: 8px 11px; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .sidebar-close { display: inline-grid; margin-left: auto; }
  .menu-btn { display: inline-grid; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .stat .value { font-size: 22px; }
  .modal-backdrop { padding: 12px; }
}
@media (min-width: 861px) and (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
