/* Big Brand Tales CRM */
:root {
  --orange: #ff6b00;
  --orange-dark: #e05e00;
  --navy: #1b2340;
  --navy-2: #2a3458;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --line: #e3e6ee;
  --text: #1b2340;
  --muted: #6b7390;
  --ok: #138a52;
  --ok-bg: #e7f6ee;
  --err: #c62f2f;
  --err-bg: #fdecec;
  --warn: #9a6200;
  --warn-bg: #fff4e0;
  --google: #1a73e8;
  --wa: #128c4b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 35, 64, .06), 0 2px 8px rgba(27, 35, 64, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--navy); }
a:hover { color: var(--orange-dark); }
h1 { font-size: 1.5rem; margin: .1rem 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
code { background: #eef0f5; padding: .05em .35em; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.mt { margin-top: 1rem; }
.grow { flex: 1; min-width: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 800; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--orange); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 10px; top: 7px; border-left: 9px solid #fff; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.brand-name small { font-weight: 600; opacity: .7; margin-left: .15rem; }
.nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #d6dbea; text-decoration: none; padding: .4rem .7rem; border-radius: 7px; white-space: nowrap; font-weight: 600; font-size: .93rem;
}
.nav a:hover { color: #fff; background: var(--navy-2); }
.nav a.active { color: #fff; background: var(--navy-2); box-shadow: inset 0 -2px 0 var(--orange); }
.badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .35em; border-radius: 99px; background: var(--orange); color: #fff; font-size: .75rem; text-align: center; }
.top-actions { display: flex; align-items: center; gap: .6rem; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: #fff; color: var(--text);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: .4rem; z-index: 30;
}
.usermenu .menu a, .usermenu .menu button {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem; border: 0; background: none; color: var(--text);
  text-decoration: none; font: inherit; border-radius: 6px; cursor: pointer;
}
.usermenu .menu a:hover, .usermenu .menu button:hover { background: var(--bg); }
.menu-head { padding: .4rem .6rem .6rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; font-weight: 600; }
.avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--orange); color: #fff; font-weight: 700; font-size: .8rem; flex: none;
}
.avatar-sm { width: 24px; height: 24px; font-size: .68rem; background: var(--navy-2); }

/* ---------- layout ---------- */
.main { padding: 1.2rem 1rem 3rem; max-width: 1500px; margin: 0 auto; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pagehead p { margin: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel.narrow { max-width: 680px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.panel-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1rem; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + .panel { margin-top: 1rem; }

/* ---------- forms ---------- */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid #cfd4e0; border-radius: 8px;
  padding: .55rem .65rem; min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255, 107, 0, .35); border-color: var(--orange); }
label { display: block; font-weight: 600; font-size: .9rem; }
label > input, label > select, label > textarea { margin-top: .3rem; font-weight: 400; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.check input { width: auto; min-height: 0; margin-top: .25rem; }
.stack { display: grid; gap: .9rem; }
.stack-sm { display: grid; gap: .4rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.span-2 { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; }
fieldset.followup { border: 1px dashed #cfd4e0; border-radius: 8px; padding: .6rem .7rem .7rem; display: grid; grid-template-columns: 150px 120px 1fr; gap: .5rem; margin: 0; }
fieldset.followup legend { font-weight: 600; font-size: .9rem; padding: 0 .3rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters input[type=search] { width: 240px; }
.filters select, .filters input[type=date] { width: auto; }
.inline-label { display: flex; align-items: center; gap: .35rem; font-weight: 500; }
.inline-label input { margin: 0; }
.inline { display: inline; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; padding: .45rem .95rem;
  border-radius: 8px; border: 1px solid #cfd4e0; background: #fff; color: var(--navy); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 32px; padding: .25rem .7rem; font-size: .88rem; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: #fff; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #0e723d; color: #fff; border-color: #0e723d; }
.btn-danger { color: var(--err); border-color: #efc2c2; }
.btn-danger:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.btn-block { width: 100%; }
.linkbtn { background: none; border: 0; padding: .35rem 0; font: inherit; color: var(--navy); cursor: pointer; text-decoration: underline; }
.quick { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- flash ---------- */
.flash { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe5cf; }
.flash-err { background: var(--err-bg); color: var(--err); border-color: #f2c4c4; }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: #f3dcac; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .8rem; align-items: start; }
.col { min-width: 0; background: #eceef4; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); min-height: 160px; }
.col-head { display: flex; align-items: center; gap: .45rem; padding: .7rem .8rem .5rem; border-top: 3px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.col-title { font-weight: 700; }
.col-count { background: #fff; border-radius: 99px; padding: 0 .5rem; font-size: .8rem; font-weight: 700; color: var(--muted); }
.col-sum { margin-left: auto; font-size: .8rem; color: var(--muted); font-weight: 600; }
.col-new .col-head { border-top-color: #8a93ad; }
.col-contacted .col-head { border-top-color: #3f7bd9; }
.col-qualified .col-head { border-top-color: var(--orange); }
.col-proposal .col-head { border-top-color: #8a4fd6; }
.col-won .col-head { border-top-color: var(--ok); }
.col-lost .col-head { border-top-color: #9aa0b3; }
.col-junk .col-head { border-top-color: var(--err); }
.col-body { padding: .2rem .55rem .7rem; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; align-content: start; flex: 1; }
.col-body.drop-over { background: rgba(255, 107, 0, .08); outline: 2px dashed var(--orange); outline-offset: -4px; border-radius: 8px; }
.card { min-width: 0; background: #fff; border-radius: 9px; padding: .65rem .7rem .55rem; box-shadow: var(--shadow); border: 1px solid var(--line); cursor: grab; }
.card.dragging { opacity: .5; }
.card.saving { opacity: .6; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-name { display: block; font-size: .96rem; }
.card-sub { display: block; color: var(--muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { min-width: 0; display: flex; flex-wrap: wrap; gap: .3rem; margin: .45rem 0 .35rem; }
.card-foot { display: flex; align-items: center; gap: .45rem; }
.stage-pick { width: auto; min-height: 28px; padding: .1rem .3rem; font-size: .78rem; margin-left: auto; border-color: var(--line); color: var(--muted); }
.tag { display: inline-block; font-size: .74rem; font-weight: 600; padding: .05rem .45rem; border-radius: 5px; background: #eef0f5; color: #4b5371; }
.tag-google { background: #e8f0fe; color: var(--google); }
.tag-money { background: var(--ok-bg); color: var(--ok); }
.tag-due { background: var(--err-bg); color: var(--err); }
.empty { color: var(--muted); text-align: center; font-size: .88rem; padding: .8rem 0; margin: 0; }

/* ---------- lead page ---------- */
.stage-bar { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: 1rem; }
.stage-step {
  font: inherit; font-size: .88rem; font-weight: 600; padding: .45rem .8rem; border-radius: 99px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); cursor: pointer; min-height: 36px;
}
.stage-step:hover { border-color: var(--navy); color: var(--navy); }
.stage-step.current { background: var(--navy); border-color: var(--navy); color: #fff; }
.stage-step.stage-won.current { background: var(--ok); border-color: var(--ok); }
.stage-step.stage-junk.current { background: var(--err); border-color: var(--err); }
.stage-step.stage-qualified.current { background: var(--orange); border-color: var(--orange); }
.note-form { display: grid; gap: .5rem; margin-bottom: 1rem; }
.note-form .row { display: flex; gap: .5rem; justify-content: flex-end; }
.note-form select { width: auto; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; max-height: 520px; overflow-y: auto; }
.timeline li { display: flex; gap: .6rem; }
.tl-icon { flex: none; width: 28px; height: 28px; display: grid; place-items: center; background: var(--bg); border-radius: 50%; font-size: .85rem; }
.tl-body { white-space: normal; word-break: break-word; }
.facts { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; margin: 0; }
.facts dt { color: var(--muted); font-weight: 600; font-size: .88rem; }
.facts dd { margin: 0; }
.danger-zone { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; white-space: nowrap; }
.table-sm th, .table-sm td { padding: .4rem .5rem; font-size: .84rem; }
.table th.param-row { text-transform: none; letter-spacing: 0; font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f3f8; }
.trunc { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 700; background: #eef0f5; color: #4b5371; white-space: nowrap; }
.pill-contacted { background: #e6efff; color: #2a5fb4; }
.pill-qualified { background: #fff0e5; color: #c45200; }
.pill-proposal { background: #f2eafd; color: #6b35b5; }
.pill-won { background: var(--ok-bg); color: var(--ok); }
.pill-junk { background: var(--err-bg); color: var(--err); }

/* ---------- misc pages ---------- */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--orange); }
.code { background: #141a30; color: #e7eaf5; padding: .9rem 1rem; border-radius: 8px; overflow-x: auto; font-size: .84rem; line-height: 1.55; white-space: pre; }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; display: grid; gap: .35rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: flex; align-items: center; gap: .8rem; box-shadow: var(--shadow); }
.stat-num { font-size: 1.9rem; font-weight: 800; color: var(--orange); line-height: 1; }
.stat-label { color: var(--muted); font-size: .85rem; line-height: 1.3; }
.log { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; font-size: .9rem; }
.log li.ok span { color: var(--ok); font-weight: 700; }
.log li.err { color: var(--err); }
.fu-list { list-style: none; padding: 0; margin: 0; }
.fu-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.fu-list li:last-child { border-bottom: 0; }
.text-due { color: var(--err); }
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; gap: .7rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.people li.inactive { opacity: .55; }
.actions-menu { position: relative; }
.actions-menu summary { list-style: none; }
.actions-menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .7rem; width: 250px; z-index: 5; display: grid; gap: .4rem; }

/* ---------- auth ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--navy) 0%, #2b3561 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 1.8rem 1.6rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.brand-lg { color: var(--navy); margin-bottom: 1rem; font-size: 1.1rem; }
.brand-lg:hover { color: var(--navy); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; }
  .nav { order: 3; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .brand-name small { display: none; }
  .main { padding: 1rem .75rem 3rem; }
  .form-grid, .row-2 { grid-template-columns: 1fr; }
  fieldset.followup { grid-template-columns: 1fr 1fr; }
  fieldset.followup input[name=followup_note] { grid-column: 1 / -1; }
  .board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; max-height: none; }
  .filters input[type=search] { width: 100%; }
  .facts { grid-template-columns: 1fr; gap: .1rem; }
  .facts dd { margin-bottom: .5rem; }
  h1 { font-size: 1.3rem; }
}
.stack > .btn:not(.btn-block) { justify-self: start; }
.card-foot .muted { white-space: nowrap; }
.stage-pick { width: 88px; min-width: 0; flex: none; }
.card-foot { min-width: 0; flex-wrap: wrap; row-gap: .3rem; }
