/* Freelandt CRM — mobile-first clean design */

:root {
  /* Freelandt brand — same palette & type as freelandt.com */
  --bg: #f1ece0;
  --card: #fbf9f2;
  --off: #e6e0d3;
  --ink: #2b3226;
  --muted: #6d7268;
  --line: rgba(43, 50, 38, .16);
  --navy: #233032;
  --teal: #394647;
  --yellow: #e9b94d;
  --sage: #cdd4cb;
  --primary: #233032;
  --primary-ink: #f1ece0;
  --danger: #b3452f;
  --ok: #5c7a52;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(43, 50, 38, .10);
  --font-display: "Poppins", sans-serif;
  --font-body: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; margin: 8px 0 0; }

/* ---------- auth ---------- */
#auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--bg);
}
.auth-hero {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0; width: 100%;
  max-width: 880px; border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow);
}
.auth-brand {
  background: var(--navy); color: var(--bg);
  padding: 44px 36px; display: flex; flex-direction: column;
  justify-content: center; position: relative;
}
.auth-brand .brand {
  font-family: var(--font-display); font-weight: 800; font-size: .95rem;
  letter-spacing: .02em; color: var(--bg); text-decoration: none; margin-bottom: 26px;
  align-self: flex-start; opacity: .85;
}
.auth-brand .brand span { color: var(--yellow); }
.auth-brand h1 {
  font-family: var(--font-display); font-size: 46px; line-height: 1.05;
  margin: 0 0 14px; font-weight: 800; color: var(--bg);
}
.auth-brand h1 em { color: var(--yellow); font-style: normal; }
.auth-brand p {
  margin: 0; font-size: 16px; line-height: 1.5; color: var(--sage);
}
.auth-ticker {
  margin-top: 26px !important; font-family: var(--font-display);
  font-weight: 700; font-size: .68rem !important; letter-spacing: .12em;
  color: var(--yellow) !important;
}
.auth-card {
  background: var(--card); padding: 44px 36px; display: flex;
  flex-direction: column; justify-content: center;
}
.auth-card h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 26px; color: var(--ink); }
.auth-card p { margin: 0 0 18px; }
@media (max-width: 720px) {
  .auth-hero { grid-template-columns: 1fr; max-width: 400px; }
  .auth-brand { padding: 34px 26px; }
  .auth-brand h1 { font-size: 34px; }
  .auth-card { padding: 30px 26px; }
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.topbar .brand { color: var(--navy); }
/* Centered title (owner request 2026-12-04) */
.topbar { position: sticky; }
.topbar .brand { position: absolute; left: 50%; transform: translateX(-50%); pointer-events: none; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-link { text-decoration: none; font-size: 20px; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }

/* ---------- buttons & forms ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 14px; font-size: 15px; cursor: pointer;
}
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
  font-weight: 600; font-family: var(--font-display); letter-spacing: .02em;
}
.btn.primary:hover { background: var(--teal); border-color: var(--teal); }
.btn.primary:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 10px; font-size: 14px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
label input, label textarea, label select {
  display: block; width: 100%; margin-top: 4px;
  padding: 10px 12px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-family: inherit; font-weight: 400;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }

/* ---------- cards & boards ---------- */
.board { margin-bottom: 22px; }
.board h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.count-pill {
  background: var(--line); color: var(--muted); border-radius: 999px;
  font-size: 13px; padding: 1px 9px; font-weight: 600;
}
.lead-card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 9px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.lead-card .name { font-weight: 700; font-size: 16px; }
.lead-card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 14px; }
.status-chip {
  display: inline-block; border-radius: 999px; padding: 2px 10px;
  font-size: 13px; font-weight: 600; background: var(--line); color: var(--ink);
}
.status-chip.opportunity { background: #e8f0fe; color: #1967d2; }
.status-chip.lead         { background: #e6f4ea; color: #188038; }
.status-chip.hold         { background: #fef7e0; color: #b06000; }
.status-chip.negotiation  { background: #f3e8fd; color: #8430ce; }
.status-chip.signed       { background: #e6f4ea; color: #0d652d; }
.status-chip.lost         { background: #fce8e6; color: #c5221f; }
.overdue { color: var(--danger); font-weight: 600; }
.done-task { text-decoration: line-through; color: var(--muted); }

/* ---------- section / list ---------- */
.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.section h3 { margin: 0 0 10px; font-size: 16px; }
.list-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.list-item:first-of-type { border-top: 0; }
.list-item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.list-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty { padding: 18px 0 6px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; position: sticky; top: 55px; z-index: 10; background: var(--bg); padding: 8px 0; }
.tab-btn {
  border: 0; background: transparent; padding: 8px 13px; font-size: 15px;
  border-radius: 999px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

.back-link { display: inline-block; margin: 6px 0; color: var(--primary); text-decoration: none; font-size: 15px; }

/* ---------- modal ---------- */
#modal-root .overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 28, .45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
@media (min-width: 520px) { #modal-root .overlay { align-items: center; } }
.modal {
  background: var(--card); width: 100%; max-width: 440px;
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto;
}
@media (min-width: 520px) { .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---------- detail header ---------- */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.detail-header h1 { font-size: 22px; margin: 4px 0; }
.kv { margin: 4px 0; font-size: 15px; overflow-wrap: anywhere; }
.kv b { font-weight: 600; }

/* ---------- search ---------- */
.search-wrap { margin: 0 0 44px; }
#search-input {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  font-family: inherit;
}
#search-input:focus { outline: 2px solid var(--primary); border-color: transparent; }
#search-results .lead-card { margin-bottom: 8px; }

/* ---------- modal header ---------- */
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-x {
  background: none; border: 0; cursor: pointer; padding: 0;
  font-size: 16px; line-height: 1; color: var(--muted);
}
.modal-x:hover { color: var(--ink); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 22px 14px; text-align: center; color: var(--muted);
  font-size: 14px; margin: 12px 0; transition: border-color .15s, background .15s;
}
.dropzone.drag-over { border-color: var(--navy); background: rgba(35, 48, 50, .06); color: var(--ink); }

/* ---------- plain ✕ delete buttons ---------- */
.x-btn {
  background: none; border: 0; cursor: pointer; padding: 2px 6px;
  font-size: 15px; line-height: 1.2; color: var(--muted);
}
.x-btn:hover { color: var(--danger); }

/* ---------- sidebar ---------- */
.menu-btn { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--navy); padding: 0 8px; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 240px;
  background: #fff; border-right: 1px solid var(--line);
  padding: 18px 16px; z-index: 60; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sidebar a { text-decoration: none; color: var(--ink); padding: 10px 12px; border-radius: 10px; font-weight: 500; }
.sidebar a:hover { background: rgba(35, 48, 50, .06); }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }

/* ---------- tabs ---------- */
.tab-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.tab-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
/* `hidden` attribute must win over display:flex on the sidebar */
.sidebar[hidden], .sidebar-overlay[hidden] { display: none; }

/* breathing room under the search bar before the list below it */
.search-wrap { margin-bottom: 44px; }
#search-results { margin-top: 0; }

/* ---------- dashboard two-column (owner request 2026-12-04) ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.dash-boards { min-width: 0; }
.dash-tasks { position: sticky; top: 96px; }
.dash-task { text-decoration: none; color: inherit; }
.dash-task:hover .grow b { text-decoration: underline; }
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-tasks { position: static; }
}

/* ---------- questionnaire tab (owner request 2026-12-04) ---------- */
.q-h { margin: 20px 0 10px; font-size: 15px; }
.q-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 16px; }
/* Uniform page tiles (owner request 2026-12-04): equal-size boxes, aligned
   labels, consistent height — no ragged wrapping. */
.q-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 14px; }
@media (min-width: 720px) { .q-checks { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1020px) { .q-checks { grid-template-columns: repeat(4, 1fr); } }
/* Checkbox flush to the left edge of each tile, page name immediately
   after it with one uniform gap (owner request 2026-12-04). */
.q-checks .check {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; margin: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; min-height: 42px; box-sizing: border-box;
  background: var(--card); line-height: 1.2;
  transition: border-color .12s ease, background .12s ease;
}
/* The global `label input` rule (width:100%, padding, border) was blowing the
   checkbox up into a giant box — reset it to a real 16px checkbox pinned at
   the very left of the tile. Owner request 2026-12-04. */
.q-checks .check input {
  flex: 0 0 auto; margin: 0;
  appearance: auto; width: 16px; height: 16px; min-width: 16px;
  padding: 0; border: initial; border-radius: initial; background: initial;
  font-size: initial; box-shadow: none;
}
.q-checks .check span { flex: 1 1 auto; text-align: left; }
.q-checks .check:hover { border-color: var(--navy); }
.q-checks .check:has(input:checked) { border-color: var(--navy); background: rgba(35, 48, 50, .05); font-weight: 600; }
.q-checks .check input { margin: 0; }

/* Photos row pairing (owner request 2026-12-04): Logo sits beside Brand
   colors, and the Brand colors box gets the wider share of the row. */
.q-grid-photos { grid-template-columns: 1fr 1.4fr; }
.q-grid-photos label:nth-child(1),
.q-grid-photos label:nth-child(3) { grid-column: 1; }
.q-grid-photos label:nth-child(2),
.q-grid-photos label:nth-child(4) { grid-column: 2; }
@media (max-width: 720px) {
  .q-grid-photos { grid-template-columns: 1fr; }
  .q-grid-photos label { grid-column: 1 !important; }
}
