:root {
  --primary: #0d2842;
  --accent: #f6bd3b;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #15803d;
  --danger: #b91c1c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 12px; font: inherit; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
button { font: inherit; cursor: pointer; }
footer { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; }
.topbar { height: 70px; display: flex; justify-content: space-between; align-items: center; padding: 0 32px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.logo { font-weight: 900; color: var(--primary); line-height: 1; }
.logo span { display:block; font-size: 12px; color: var(--muted); letter-spacing:.08em; text-transform: uppercase; margin-top:4px; }
.topbar nav { display:flex; align-items:center; gap: 16px; }
.topbar form { margin:0; }
.topbar nav button { border:0; background:transparent; color: var(--muted); }
.container { width:min(1180px, 94vw); margin: 32px auto; }
.card, .auth-card, .new-card { background: var(--card); border: 1px solid var(--border); box-shadow: 0 18px 60px rgba(15, 23, 42, .08); border-radius: 26px; padding: 26px; }
.hero-panel { display:grid; grid-template-columns: 1fr 320px; gap: 26px; align-items: stretch; padding: 36px; border-radius: 32px; background: linear-gradient(135deg, #0d2842, #153957); color: #fff; margin-bottom: 28px; overflow:hidden; position:relative; }
.hero-panel:after { content:""; position:absolute; width:240px; height:240px; right:-80px; top:-70px; background: var(--accent); border-radius:50%; opacity:.88; }
.hero-panel h1 { font-size: clamp(30px, 5vw, 56px); line-height: .98; margin: 0 0 16px; max-width: 760px; }
.hero-panel p { max-width: 640px; color: #dbeafe; }
.new-card { color: var(--text); position:relative; z-index:2; display:grid; gap:12px; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing:.09em; text-transform: uppercase; font-size: 12px; margin: 0 0 8px; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom: 20px; }
.section-head h1, .section-head h2 { margin:0; }
.table-wrap { overflow:auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 12px; text-align:left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.btn { display:inline-flex; justify-content:center; align-items:center; border:1px solid var(--border); background:#fff; border-radius: 12px; padding: 11px 15px; color: var(--primary); font-weight: 800; }
.btn.primary { background: var(--primary); color:#fff; border-color: var(--primary); }
.btn.success { background: var(--success); color:#fff; border-color: var(--success); }
.btn.ghost { background:#f8fafc; }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.wide { width:100%; margin-top: 12px; }
.badge { display:inline-block; background:#eef2ff; color:#3730a3; padding:6px 10px; border-radius:999px; font-size:12px; font-weight:800; }
.alert { padding: 12px 14px; border-radius: 12px; margin: 12px 0; }
.alert.error { background:#fee2e2; color:var(--danger); }
.alert.success { background:#dcfce7; color:#166534; }
.stack { display:grid; gap:14px; }
.grid-5 { display:grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.auth-body { min-height:100vh; display:grid; place-items:center; background: radial-gradient(circle at top left, #f6bd3b 0 16%, transparent 17%), linear-gradient(135deg, #0d2842, #0f172a); }
.auth-card { width:min(440px, 92vw); text-align:center; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card p { color: var(--muted); }
.brand-mark { width:82px; height:82px; margin:0 auto 18px; display:grid; place-items:center; border-radius:26px; background: linear-gradient(135deg, var(--primary), var(--accent)); color:#fff; font-weight:900; line-height:.75; }
.brand-mark span { color:#fff; font-size:12px; }
.proposal-layout { width:min(1500px, 96vw); margin: 22px auto; display:grid; grid-template-columns: minmax(390px, 560px) 1fr; gap: 22px; align-items:start; }
.chat-panel, .editor-panel { min-height: calc(100vh - 130px); }
.chat-box { height: 430px; overflow:auto; border:1px solid var(--border); border-radius: 20px; padding: 16px; background: #f8fafc; display:flex; flex-direction:column; gap:10px; }
.msg { max-width: 86%; padding: 12px 14px; border-radius: 18px; white-space: pre-wrap; line-height:1.4; }
.msg.assistant { background:#fff; border:1px solid var(--border); color:#111827; align-self:flex-start; }
.msg.user { background: var(--primary); color:#fff; align-self:flex-end; }
.chat-input { margin-top: 14px; }
.voice-row { display:flex; align-items:center; gap:10px; margin-top: 10px; }
.icon-btn { width:42px; height:42px; border-radius: 14px; border:1px solid var(--border); background:#fff; font-weight:900; }
.icon-btn.recording { background:#fee2e2; border-color:#fecaca; color:#b91c1c; animation: pulse 1s infinite; }
.voice-status { color:var(--muted); font-size:13px; flex:1; min-height:20px; }
.upload-card { background:#fffbeb; border:1px solid #fde68a; border-radius:20px; padding:16px; margin-top:14px; }
.upload-card p { color:#7c2d12; font-size:13px; }
.file-chip { display:inline-block; padding:6px 10px; border-radius:999px; background:#fff; border:1px solid #fde68a; margin:8px 6px 0 0; font-size:12px; }
.draft-json { width:100%; min-height: 660px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height:1.5; background:#0f172a; color:#e2e8f0; }
.actions { display:flex; gap: 10px; flex-wrap:wrap; }
.actions.bottom { margin-top:12px; }
.processing-modal { position:fixed; inset:0; background:rgba(15,23,42,.66); display:grid; place-items:center; z-index:99; }
.processing-modal[hidden] { display:none; }
.processing-box { width:min(520px, 92vw); background:#fff; border-radius:32px; padding:38px; text-align:center; box-shadow:0 30px 90px rgba(0,0,0,.28); }
.loader { width:60px; height:60px; border:6px solid #e5e7eb; border-top-color:var(--accent); border-radius:50%; margin:0 auto 20px; animation: spin 1s linear infinite; }
.public-body { background:#f8fafc; }
.public-proposal { width:min(920px, 94vw); margin: 32px auto; display:grid; gap:18px; }
.public-cover { background: linear-gradient(135deg, var(--primary), #153957); color:#fff; border-radius:32px; padding:42px; display:grid; grid-template-columns: 1.2fr .8fr; gap:22px; position:relative; overflow:hidden; }
.public-cover:after { content:""; position:absolute; width:220px; height:220px; right:-70px; top:-70px; background:var(--accent); border-radius:50%; opacity:.9; }
.public-cover h1 { font-size:42px; line-height:1; margin:0 0 14px; }
.public-info { background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.2); padding:22px; border-radius:22px; z-index:2; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (max-width: 980px) {
  .hero-panel, .proposal-layout, .public-cover { grid-template-columns:1fr; }
  .grid-5 { grid-template-columns:1fr 1fr; }
  .topbar { padding:0 16px; }
}

.grid-2 { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.muted-text { color: var(--muted); font-size: 14px; }
.api-config-card code { background:#f1f5f9; border:1px solid var(--border); padding:2px 6px; border-radius:8px; }
.api-status-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom: 4px; }
.status-pill { display:inline-flex; align-items:center; border-radius:999px; padding:7px 11px; font-size:12px; font-weight:900; background:#f1f5f9; color:#475569; border:1px solid var(--border); }
.status-pill.ok { background:#dcfce7; color:#166534; border-color:#bbf7d0; }
.status-pill.bad { background:#fee2e2; color:#991b1b; border-color:#fecaca; }
.toggle-row { display:flex; gap:10px; align-items:center; border:1px solid var(--border); padding:12px; border-radius:16px; background:#f8fafc; }
.toggle-row input, .inline-check input { width:auto; }
.secret-box { border:1px solid var(--border); background:#fbfdff; padding:16px; border-radius:20px; }
.secret-help { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; color:var(--muted); font-size:13px; margin-top:10px; }
.inline-check { display:flex; align-items:center; gap:8px; width:auto; }
.api-note { background:#fffbeb; border:1px solid #fde68a; color:#7c2d12; padding:14px; border-radius:16px; font-size:14px; }
@media (max-width: 780px) { .grid-2 { grid-template-columns:1fr; } .topbar nav { gap: 10px; font-size: 13px; } }

/* Visual proposal editor */
.empty-draft { border:1px dashed var(--border); border-radius:24px; padding:28px; background:#f8fafc; text-align:center; color:var(--muted); }
.visual-editor { display:grid; gap:18px; }
.editor-card { border:1px solid var(--border); border-radius:22px; background:linear-gradient(180deg,#ffffff,#fbfdff); padding:18px; box-shadow:0 12px 36px rgba(15,23,42,.04); }
.premium-preview { background:linear-gradient(135deg, rgba(13,40,66,.05), rgba(246,189,59,.10)); border-color:#dbeafe; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
.mini-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.mini-head h3 { margin:0; }
.scope-edit-block { border:1px solid var(--border); border-radius:18px; padding:14px; margin-bottom:12px; background:#fff; }
.scope-edit-block .scope-title { font-weight:800; color:var(--primary); }
.editable-table input { border-radius:10px; padding:9px; min-width:90px; }
.editable-table th:last-child, .editable-table td:last-child { width:46px; text-align:center; }
.btn.danger, .btn.small.danger { color:#991b1b; border-color:#fecaca; background:#fff1f2; }
.total-input { display:block; max-width:280px; margin-left:auto; margin-top:14px; font-weight:900; color:var(--primary); }
.muted-text { color: var(--muted); }
.editor-panel textarea { min-height:120px; line-height:1.45; }
@media (max-width: 980px) { .grid-3 { grid-template-columns:1fr; } .editable-table { min-width:760px; } }
.plan-test-result { margin-top: 12px; border: 1px solid var(--border); border-radius: 16px; background: #f8fafc; color: #334155; padding: 12px; font-size: 13px; white-space: pre-wrap; }
.plan-test-result.ok { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.plan-test-result.bad { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
