/* Knowly web app styles - minimal, dependency-free. */
:root {
  --blue: #2563eb; --blue-dark: #1d4ed8;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc;
  --ok: #16a34a; --warn: #d97706; --info: #0891b2; --danger: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; height: 66px; }
.brand { font-weight: 700; font-size: 18px; color: var(--blue); display: flex; align-items: center; }
.brand-logo { height: 44px; display: block; }
.auth-logo { display: block; margin: 4px auto 14px; width: 320px; max-width: 100%; height: auto; }
.auth-topnav { position: absolute; top: 16px; right: 24px; display: flex; align-items: center; gap: 14px; }
@media (max-width: 480px) { .auth-topnav { position: static; justify-content: center; margin: 12px 0 0; } }
.auth-subtitle { font-size: 18px; text-align: center; margin: 0 0 16px; }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.mainnav a.active, .mainnav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.whoami-link { color: var(--muted); font-weight: 600; }
.whoami-link:hover { color: var(--ink); text-decoration: none; }
.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; }
.website-row { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.website-row input[type=url] { flex: 1; min-width: 260px; }
.website-hint { font-size: 13px; }

.container { max-width: 960px; margin: 0 auto; padding: 28px 24px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.kb-setting { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: -6px 0 18px; cursor: pointer; }
.kb-setting input { width: 16px; height: 16px; }
.kb-setting input.days-input { width: 64px; height: auto; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; transition: background-color .3s ease, border-color .3s ease; }
.kb-setting input.days-input.saved-flash { border-color: var(--ok); background: #dcfce7; }
.kb-setting.conv-retention { margin: 14px 0 0; }
.widget-brand { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.brand-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.widget-icon-preview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); background: #fff; }
.brand-title { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.brand-title label { font-size: 13px; color: var(--muted); }
.title-row { display: flex; gap: 8px; }
.title-row input { flex: 1; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }

/* Buttons */
.btn { background: var(--blue); color: #fff; border: none; padding: 9px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled,
.btn:disabled:hover { background: #cbd5e1; color: #eef2f7; cursor: not-allowed; opacity: 0.7; }
.btn-link:disabled,
.btn-link:disabled:hover { color: #94a3b8; cursor: not-allowed; text-decoration: none; }
.btn-accent { background: var(--warn); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-oauth { background: #fff; color: var(--ink); border: 1px solid var(--line); display: block; text-align: center; margin-top: 8px; }
.btn-link { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 14px; padding: 0 6px; }
.btn-link.danger { color: var(--danger); }
.row-actions { white-space: nowrap; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.data-table th { background: var(--bg); color: var(--muted); font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }

/* Admin tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { background: none; border: none; padding: 10px 14px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.admin-panel { overflow-x: auto; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-warn { background: #fef3c7; color: var(--warn); }
.badge-info { background: #cffafe; color: var(--info); }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: block; color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
a.stat-card:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(37,99,235,.12); text-decoration: none; }
.stat-num { font-size: 34px; font-weight: 700; color: var(--blue); }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 4px; }
.dash-plan { color: var(--muted); font-size: 14px; margin: -8px 0 18px; }

/* Panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin: 20px 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.code { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--bg); }

/* Auth cards */
.auth-card { max-width: 380px; margin: 48px auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-card h1 { text-align: center; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.form input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.oauth-buttons { margin-top: 16px; }
.agree-row { flex-direction: row !important; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.agree-row input { width: 16px; height: 16px; }

/* Privacy / policy page */
.policy { max-width: 760px; margin: 0 auto; }
.policy h2 { font-size: 18px; margin: 24px 0 8px; }
.policy p, .policy li { color: var(--ink); line-height: 1.65; font-size: 15px; }
.policy ul { padding-left: 20px; }

/* Notices */
.notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 12px 0; }
.notice.ok { background: #dcfce7; color: var(--ok); }
.notice.err { background: #fee2e2; color: var(--danger); }

/* Conversation transcript */
.transcript { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; height: 440px; overflow-y: auto; }
.bubble { max-width: 75%; padding: 9px 12px; border-radius: 12px; margin: 8px 0; font-size: 14px; white-space: pre-wrap; }
.bubble .bubble-who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.bubble.visitor { background: var(--bg); border: 1px solid var(--line); }
.bubble.ai { background: #eef2ff; margin-left: auto; }
.bubble.agent { background: #dcfce7; margin-left: auto; }
.reply-form { display: flex; gap: 8px; margin-top: 12px; }
.reply-form input { flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.meta { margin-bottom: 12px; font-size: 13px; }

/* ---- Public landing page ---- */
a.btn { display: inline-block; text-decoration: none; }
.btn-lg { padding: 12px 24px; font-size: 16px; border-radius: 10px; }
.btn-outline { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn-outline:hover { background: #eff6ff; }
.btn-white { background: #fff; color: var(--blue); }
.btn-white:hover { background: #eff6ff; }

.landing { background: #fff; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; max-width: 1080px; margin: 0 auto; }
.landing-brand img { height: 100px; display: block; }
.landing-nav-actions { display: flex; align-items: center; gap: 16px; }

.hero { text-align: center; padding: 64px 24px 56px; max-width: 820px; margin: 0 auto; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; background: #eff6ff; color: var(--blue); border: 1px solid #dbeafe; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500; margin-bottom: 18px; }
.hero-badge svg { width: 14px; height: 14px; }
.hero h1 { font-size: 42px; line-height: 1.15; margin: 0 0 20px; color: var(--ink); }
.hero-sub { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 auto 32px; max-width: 640px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; max-width: 1080px; margin: 0 auto; padding: 24px; }
.feature-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.feature-accent { width: 40px; height: 5px; border-radius: 999px; margin-bottom: 14px; }
.feature-card h3 { font-size: 17px; margin: 0 0 8px; color: var(--ink); }
.feature-card p { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0; }

.steps { max-width: 1080px; margin: 32px auto; padding: 24px; text-align: center; }
.steps h2 { font-size: 26px; margin: 0 0 28px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.step { padding: 8px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 700; font-size: 18px; margin-bottom: 12px; }
.step p { font-size: 15px; line-height: 1.5; color: var(--muted); margin: 0; }

.privacy-band { background: var(--ink); color: #fff; text-align: center; padding: 56px 24px; margin: 24px 0; }
.privacy-band h2 { font-size: 26px; margin: 0 0 10px; }
.privacy-lead { max-width: 660px; margin: 0 auto 30px; font-size: 17px; line-height: 1.6; opacity: .9; }
.privacy-points { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px; max-width: 920px; margin: 0 auto; }
.privacy-points > div { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.privacy-points strong { font-size: 16px; }
.privacy-points span { font-size: 14px; opacity: .8; line-height: 1.5; }

.cta-band { background: var(--blue); color: #fff; text-align: center; padding: 56px 24px; margin-top: 24px; }
.cta-band h2 { font-size: 26px; margin: 0 0 10px; }
.cta-band p { font-size: 16px; opacity: .92; margin: 0 0 24px; }

.contact { max-width: 620px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.contact h2 { font-size: 26px; margin: 0 0 8px; }
.contact-lead { color: var(--muted); margin: 0 0 24px; }
.contact-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.contact-form input, .contact-form textarea { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; font-family: inherit; }
.contact-form button { align-self: center; margin-top: 6px; }

/* Honeypot anti-bot field: present in the DOM, invisible + unfocusable */
.hp-field { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

.landing-footer { text-align: center; padding: 28px 24px; color: var(--muted); font-size: 14px; }
.landing-footer a { color: var(--muted); }

/* Pricing / billing */
.pricing { max-width: 1000px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.pricing h1 { font-size: 34px; margin: 0 0 10px; }
.billing-toggle { display: inline-flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 20px 0 28px; }
.billing-toggle.small { margin: 0; }
.bt-opt { background: none; border: none; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--muted); }
.bt-opt.active { background: var(--blue); color: #fff; }
.save-badge { background: #dcfce7; color: var(--ok); border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-left: 6px; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; text-align: left; }
.plan-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.plan-card.featured { border-color: var(--blue); box-shadow: 0 4px 18px rgba(37,99,235,.12); }
.plan-card.is-current { background: var(--bg); }
.plan-tag, .plan-card .plan-tag { position: absolute; top: -11px; left: 24px; background: var(--blue); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.plan-card h3 { margin: 0; font-size: 18px; }
.plan-price { font-size: 15px; color: var(--muted); }
.plan-price .price { font-size: 30px; font-weight: 700; color: var(--ink); }
.plan-price .per { font-size: 14px; }
.plan-feats { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 8px; }
.plan-feats li { font-size: 14px; color: var(--ink); padding-left: 22px; position: relative; }
.plan-feats li::before { content: "✓"; color: var(--ok); position: absolute; left: 0; font-weight: 700; }
.usage-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

@media (max-width: 560px) {
  .hero h1 { font-size: 32px; }
  .landing-nav { padding: 14px 20px; }
}
