/* ========================================================================
   Landed — Client Acquisition Toolkit
   Design: warm paper ground, indigo-blue brand accent (from Misan's
   Marketing Apps mark), system font stack
   (kept dependency-free so this runs on any static host, offline-friendly)
   ======================================================================== */

:root {
  --bg: #faf9f6;
  --bg-raised: #ffffff;
  --ink: #1b1d1c;
  --ink-soft: #55534c;
  --line: #e4e0d6;
  --line-strong: #cfc9ba;
  --accent: #4636e3;
  --accent-ink: #ffffff;
  --accent-soft: #eae6fc;
  --status-contacted: #5b7db1;
  --status-proposal: #b8862b;
  --status-won: #1f8a5c;
  --status-lost: #9a938a;
  --shadow: 0 1px 2px rgba(27, 29, 28, 0.04), 0 8px 24px rgba(27, 29, 28, 0.06);
  --radius: 10px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-doc: Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --bg-raised: #1e2123;
    --ink: #ecebe6;
    --ink-soft: #a8a49a;
    --line: #33362f;
    --line-strong: #46493f;
    --accent: #8d82ff;
    --accent-ink: #15102e;
    --accent-soft: #262048;
    --status-contacted: #7fa0d6;
    --status-proposal: #d9a748;
    --status-won: #34d399;
    --status-lost: #7c766c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #16181a; --bg-raised: #1e2123; --ink: #ecebe6; --ink-soft: #a8a49a;
  --line: #33362f; --line-strong: #46493f; --accent: #8d82ff; --accent-ink: #15102e;
  --accent-soft: #262048; --status-contacted: #7fa0d6; --status-proposal: #d9a748;
  --status-won: #34d399; --status-lost: #7c766c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
  --bg: #faf9f6; --bg-raised: #ffffff; --ink: #1b1d1c; --ink-soft: #55534c;
  --line: #e4e0d6; --line-strong: #cfc9ba; --accent: #4636e3; --accent-ink: #ffffff;
  --accent-soft: #eae6fc; --status-contacted: #5b7db1; --status-proposal: #b8862b;
  --status-won: #1f8a5c; --status-lost: #9a938a;
  --shadow: 0 1px 2px rgba(27,29,28,.04), 0 8px 24px rgba(27,29,28,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2 { text-wrap: balance; margin: 0; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark { display: flex; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-tag { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }

.powered-by {
  display: flex; align-items: baseline; gap: 5px; text-decoration: none;
  font-size: 11px; color: var(--ink-soft); white-space: nowrap; margin-right: 8px;
}
.powered-by strong { color: var(--ink); font-weight: 700; }
.powered-by:hover strong { color: var(--accent); }
@media (max-width: 900px) { .powered-by { display: none; } }

.tabs { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tab-btn {
  border: none; background: transparent; color: var(--ink-soft);
  padding: 8px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { background: var(--accent); color: var(--accent-ink); }

.profile-btn {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--ink);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.profile-btn:hover { border-color: var(--accent); color: var(--accent); }

.theme-toggle {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--ink-soft); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
#themeIconSun, #themeIconMoon { display: none; }
:root[data-theme="dark"] #themeIconSun { display: block; }
:root:not([data-theme="dark"]) #themeIconMoon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeIconSun { display: block; }
  :root:not([data-theme="light"]) #themeIconMoon { display: none; }
}

/* ---------- layout ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.panel { display: none; }
.panel.is-active { display: block; }
.panel-head { max-width: 640px; margin-bottom: 28px; }
.panel-head h1 { font-size: 24px; letter-spacing: -0.01em; margin-bottom: 8px; }
.panel-head p { color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; margin: 0; }

.workspace { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .workspace { grid-template-columns: 1fr; } }

/* ---------- form card ---------- */
.form-card, .output-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.field .optional { font-weight: 400; color: var(--ink-soft); }
.field input[type="text"], .field select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font-size: 14px; font-family: inherit;
}
.field input[type="text"]:focus, .field select:focus { border-color: var(--accent); }
.field input[type="file"] { font-size: 13px; color: var(--ink-soft); }

.segmented { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg-btn {
  flex: 1; padding: 8px 10px; border: none; background: var(--bg); color: var(--ink-soft);
  font-size: 13px; font-weight: 600; cursor: pointer; border-right: 1px solid var(--line-strong);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.is-active { background: var(--accent); color: var(--accent-ink); }

/* ---------- output card ---------- */
.output-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.output-label { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }
.ghost-btn {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  padding: 7px 13px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.primary-btn {
  border: none; background: var(--accent); color: var(--accent-ink);
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.07); }

#scriptOutput {
  width: 100%; min-height: 320px; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; padding: 16px;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.65;
  color: var(--ink); background: var(--bg);
}
.hint { font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 0; }

/* ---------- proposal services list ---------- */
.services-list { display: flex; flex-direction: column; gap: 10px; }
.service-row {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  background: var(--bg);
}
.service-row-top { display: flex; align-items: center; gap: 9px; }
.service-row-top input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.service-row-top label { font-size: 13.5px; font-weight: 700; cursor: pointer; }
.service-row-unit { margin-left: auto; font-size: 11.5px; color: var(--ink-soft); }
.service-price {
  display: none; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.service-row.is-checked .service-price { display: flex; }
.service-price input[type="range"] { flex: 1; accent-color: var(--accent); }
.service-price-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; min-width: 68px; text-align: right; }
.service-price-range { font-size: 11px; color: var(--ink-soft); }

/* ---------- proposal document ---------- */
.proposal-frame { background: #d8d3c6; border-radius: 8px; padding: 20px; }
@media (prefers-color-scheme: dark) { .proposal-frame { background: #0e0f10; } }
:root[data-theme="dark"] .proposal-frame { background: #0e0f10; }
:root[data-theme="light"] .proposal-frame { background: #d8d3c6; }

.proposal-doc {
  background: #fffdf8; color: #1b1d1c; font-family: var(--font-doc);
  max-width: 640px; margin: 0 auto; padding: 48px 44px; border-radius: 2px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
}
.proposal-doc .doc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 2px solid #4636e3; padding-bottom: 16px; margin-bottom: 22px; }
.proposal-doc .doc-logo { max-width: 140px; max-height: 60px; object-fit: contain; }
.proposal-doc .doc-agency-name { font-weight: 700; font-size: 18px; }
.proposal-doc .doc-agency-contact { font-size: 12px; color: #6b6a63; margin-top: 2px; }
.proposal-doc .doc-date { font-size: 12px; color: #6b6a63; text-align: right; white-space: nowrap; }
.proposal-doc h2 { font-size: 22px; margin-bottom: 4px; }
.proposal-doc .doc-for { font-size: 13.5px; color: #4a4943; margin-bottom: 24px; }
.proposal-doc table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.proposal-doc th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #6b6a63; border-bottom: 1px solid #d8d3c6; padding: 0 0 8px; }
.proposal-doc td { padding: 12px 0; border-bottom: 1px solid #ece8dd; vertical-align: top; font-size: 13.5px; }
.proposal-doc td.doc-desc { color: #4a4943; font-size: 12.5px; margin-top: 2px; }
.proposal-doc td.doc-price { text-align: right; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.proposal-doc .doc-item-name { font-weight: 700; }
.proposal-doc .doc-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-bottom: 28px; font-size: 13.5px; }
.proposal-doc .doc-totals .total-line strong { font-size: 16px; margin-left: 8px; }
.proposal-doc .doc-footer { font-size: 12px; color: #6b6a63; border-top: 1px solid #ece8dd; padding-top: 14px; }
.proposal-doc .doc-empty { color: #8a8478; font-style: italic; font-size: 14px; }

/* ---------- tracker ---------- */
.tracker-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.summary-chip {
  border: 1px solid var(--line); background: var(--bg-raised); border-radius: 999px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  display: flex; align-items: center; gap: 7px;
}
.summary-chip strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.summary-chip .dot { width: 8px; height: 8px; border-radius: 50%; }

.add-prospect-form {
  display: grid; grid-template-columns: 1.4fr 1fr 1.4fr auto; gap: 10px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.add-prospect-form input, .add-prospect-form select {
  padding: 9px 11px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font-size: 13.5px; font-family: inherit;
}
@media (max-width: 700px) { .add-prospect-form { grid-template-columns: 1fr; } }

.tracker-table-wrap { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tracker-table { width: 100%; border-collapse: collapse; }
.tracker-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.tracker-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
.tracker-table tr:last-child td { border-bottom: none; }
.tracker-table td.t-notes { color: var(--ink-soft); max-width: 220px; }
.tracker-table td.t-date { color: var(--ink-soft); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status-select {
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 10px 5px 22px;
  font-size: 12.5px; font-weight: 700; background-color: var(--bg); color: var(--ink);
  background-repeat: no-repeat; background-position: 8px center; background-size: 8px 8px;
}
.status-select.st-contacted { background-image: radial-gradient(circle, var(--status-contacted) 100%, transparent 100%); }
.status-select.st-proposal { background-image: radial-gradient(circle, var(--status-proposal) 100%, transparent 100%); }
.status-select.st-won { background-image: radial-gradient(circle, var(--status-won) 100%, transparent 100%); }
.status-select.st-lost { background-image: radial-gradient(circle, var(--status-lost) 100%, transparent 100%); }
.row-delete { border: none; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.row-delete:hover { color: #c0392b; background: rgba(192,57,43,.08); }
.empty-state { text-align: center; color: var(--ink-soft); font-size: 13.5px; padding: 32px 16px; margin: 0; }

/* ---------- access gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.gate.is-unlocked { display: none; }
.gate-card {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.gate-mark { display: inline-flex; margin-bottom: 14px; }
.gate-card h1 { font-size: 20px; margin-bottom: 6px; }
.gate-card p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 18px; }
.gate-card input[type="password"] {
  width: 100%; padding: 11px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font-size: 14px; text-align: center; margin-bottom: 12px;
}
.gate-card input[type="password"]:focus { border-color: var(--accent); }
.gate-card .primary-btn { width: 100%; padding: 11px 14px; font-size: 14px; }
.gate-error { color: #c0392b; margin: 12px 0 0; display: none; }
.gate-error.is-visible { display: block; }

/* ---------- how-to-use guide ---------- */
.guide { display: flex; flex-direction: column; gap: 22px; max-width: 720px; }
.guide-section {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.guide-section h2 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 8px; }
.guide-number {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.guide-section > p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 12px; }
.guide-section ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.guide-section li { font-size: 13.5px; line-height: 1.55; }
.guide-first p, .guide-note p { margin-bottom: 0; }
.guide-note { background: var(--accent-soft); border-color: transparent; }
.ui-ref {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 12.5px; padding: 1px 7px; border-radius: 5px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(20, 20, 18, 0.45);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--bg-raised); border-radius: 14px; width: 100%; max-width: 420px;
  padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { font-size: 18px; }
.modal-sub { font-size: 13px; color: var(--ink-soft); margin: 0 0 18px; }
.icon-btn { border: none; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--ink); background: var(--accent-soft); }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; }
.logo-preview-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
#pf-logo-preview { max-height: 40px; max-width: 120px; object-fit: contain; display: none; border-radius: 4px; }
#pf-logo-preview.has-logo { display: block; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 200;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- print ---------- */
@media print {
  body * { visibility: hidden; }
  .proposal-doc, .proposal-doc * { visibility: visible; }
  .proposal-doc { position: absolute; top: 0; left: 0; width: 100%; max-width: 100%; box-shadow: none; padding: 20px 6px; }
}
