/* Square One Sales — stylesheet */
:root {
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --hairline:    #e1e0d9;
  --border:      rgba(11,11,11,0.10);
  --accent:      #2199eb;   /* Square One brand blue */
  --accent-dark: #1780ce;
  --accent-deep: #1266a8;
  --alert:       #eb6834;   /* attention orange (needs-action flags) */
  --blue:        #2a78d6;
  --good:        #0ca30c;
  --good-text:   #006300;
  --warning:     #fab219;
  --critical:    #d03b3b;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(11,11,11,0.07);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--ink); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
  padding: 3px 7px; border-radius: 7px; letter-spacing: 0.5px;
}
.brand-logo { height: 30px; width: auto; display: block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--ink-2); padding: 6px 12px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: var(--page); text-decoration: none; color: var(--ink); }
.nav a.active { background: #e3f1fd; color: var(--accent-deep); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.mob-admin { display: none; font-size: 18px; text-decoration: none; }
@media (max-width: 700px) { .mob-admin { display: inline-block; } }
.userchip { color: var(--ink-2); font-size: 13px; }
.nav-out { color: var(--muted); font-size: 13px; }

/* ---------- Layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.page-head .spacer { flex: 1; }
h2.section { font-size: 15px; margin: 26px 0 10px; color: var(--ink-2); text-transform: none; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 16px 18px; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 16px; }
.tile .t-label { font-size: 13px; color: var(--ink-2); }
.tile .t-value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .t-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.t-alert .t-value { color: var(--critical); }
.tile.t-warn .t-value { color: #8a6100; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.badge-overdue  { background: #fbe4e4; color: #9c2424; }
.badge-today    { background: #fdf0d3; color: #7a5600; }
.badge-upcoming { background: #eef1f0; color: var(--ink-2); }
.badge-noaction { background: #fdeee7; color: #a13c14; }
.stage-open { background: #e7eef9; color: #1c4f8f; }
.stage-won  { background: #e2f3e2; color: var(--good-text); }
.stage-lost { background: #f0efec; color: var(--ink-2); }
.badge-role { background: #eee9fb; color: #43349b; }
.badge-stale { background: #fbe4e4; color: #9c2424; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  padding: 8px 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--page); text-decoration: none; }
.btn-accent { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-accent:hover { background: var(--accent-deep); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--page); }
.btn-danger { color: var(--critical); }

label.f { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 8px; background: #fff;
}
label.f textarea { min-height: 90px; resize: vertical; }
label.f input:focus, label.f select:focus, label.f textarea:focus {
  outline: 2px solid #a8d4f7; border-color: var(--accent);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: #e2f3e2; color: var(--good-text); }
.flash-err { background: #fbe4e4; color: #9c2424; }

/* ---------- Tables ---------- */
table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.list th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--hairline); background: var(--surface);
}
.list td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
.list tr:last-child td { border-bottom: none; }
.list tr:hover td { background: #faf7f4; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Kanban board ---------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 18px; align-items: flex-start; }
.col {
  min-width: 250px; width: 250px; flex-shrink: 0;
  background: #f2f1ed; border-radius: var(--radius); padding: 8px;
}
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; }
.col-head .col-name { font-weight: 700; font-size: 13px; }
.col-head .col-count { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 0 8px; }
.col-head .col-sum { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.cards { min-height: 30px; display: flex; flex-direction: column; gap: 8px; }
.lead-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; display: block; color: var(--ink);
}
.lead-card:hover { text-decoration: none; border-color: #a8cfef; }
.lead-card.dragging { opacity: 0.5; }
.lead-card .lc-name { font-weight: 650; font-size: 14px; }
.lead-card .lc-meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.lead-card .lc-value { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lead-card .lc-foot { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lead-card .lc-owner { font-size: 11px; color: var(--muted); margin-left: auto; }

/* ---------- Dashboard action lists ---------- */
.action-group { margin-bottom: 20px; }
.action-group h3 { font-size: 14px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.action-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 14px; margin-bottom: 6px; box-shadow: var(--shadow);
}
.action-row .a-lead { font-weight: 650; }
.action-row .a-act { color: var(--ink-2); flex: 1; min-width: 180px; }
.action-row .a-who { font-size: 12px; color: var(--muted); }
.rail-overdue { border-left: 3px solid var(--critical); }
.rail-today   { border-left: 3px solid var(--warning); }
.rail-up      { border-left: 3px solid var(--hairline); }
.rail-none    { border-left: 3px solid var(--alert); }

/* ---------- Pipeline mini-bar (dashboard) ---------- */
.stagebar { display: flex; gap: 10px; flex-wrap: wrap; }
.stagebar a {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 14px; color: var(--ink); box-shadow: var(--shadow);
}
.stagebar a:hover { text-decoration: none; border-color: #a8cfef; }
.stagebar .sb-n { font-weight: 700; font-size: 18px; }
.stagebar .sb-l { font-size: 12px; color: var(--ink-2); }

/* ---------- Lead detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: 10px 0; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.activity li:last-child { border-bottom: none; }
.activity .act-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.act-type { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-right: 6px; }

.next-action-panel { border-left: 4px solid var(--accent); }
.warn-noaction { background: #fdeee7; border: 1px solid #f2c9b3; color: #a13c14; padding: 10px 14px; border-radius: 8px; font-weight: 600; margin-bottom: 12px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input {
  font: inherit; padding: 7px 10px; border: 1px solid var(--hairline); border-radius: 8px; background: var(--surface);
}

.dropzone { border: 2px dashed var(--hairline); box-shadow: none; }
.ai-options { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .ai-options { grid-template-columns: 1fr; } }
#micbtn.recording { background: #fbe4e4; border-color: var(--critical); color: #9c2424; animation: micpulse 1.2s infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(208,59,59,0.3); } 50% { box-shadow: 0 0 0 8px rgba(208,59,59,0); } }
.dropzone.dragover { border-color: var(--accent); background: #e3f1fd; }

/* projections meter */
.meter { height: 14px; border-radius: 999px; background: #b9dcf8; overflow: hidden; margin: 8px 0 6px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.m-good > span { background: var(--good); }
.meter.m-good { background: #cfead0; }
.proj-row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.proj-row strong { color: var(--ink); }

/* ---------- Calendar ---------- */
.calwrap { overflow: hidden; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calhead div { padding: 8px 10px; font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--hairline); text-align: left; }
.calcell { min-height: 92px; border-bottom: 1px solid var(--hairline); border-right: 1px solid var(--hairline); padding: 6px; }
.calcell:nth-child(7n) { border-right: none; }
.calempty { background: #f7f6f3; }
.calday { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.caltoday { background: #e3f1fd; }
.caltoday .calday { color: var(--accent-deep); }
.calitem {
  display: block; background: #e7eef9; color: #1c4f8f; border-radius: 6px;
  font-size: 11px; line-height: 1.3; padding: 3px 6px; margin-bottom: 3px; font-weight: 600;
}
.calitem span { font-weight: 400; color: #52514e; }
.calitem:hover { text-decoration: none; outline: 1px solid #a8cfef; }
.calitem.calover { background: #fbe4e4; color: #9c2424; }
.calitem.calvisit { background: #e2f3e2; color: #006300; }
@media (max-width: 700px) {
  .calcell { min-height: 64px; padding: 3px; }
  .calitem { font-size: 10px; padding: 2px 4px; }
  .calitem span { display: none; }
}

.login-box { max-width: 380px; margin: 8vh auto 0; }
.login-box .brand-big { text-align: center; font-size: 20px; font-weight: 800; margin-bottom: 18px; }

.empty { color: var(--muted); padding: 18px; text-align: center; }

/* ---------- Mobile lead cards ---------- */
.lead-cards { display: none; }
.mlead { display: block; padding: 12px 14px; margin-bottom: 8px; color: var(--ink); }
.mlead:hover { text-decoration: none; }
.mlead-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; }
.mlead-mid { color: var(--ink-2); font-size: 13px; margin-top: 3px; }
.mlead-bot { margin-top: 6px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) {
  .lead-cards { display: block; }
  .tablewrap { display: none; }
}

/* ---------- Board move arrows & scroll ---------- */
.board { scroll-snap-type: x proximity; scroll-behavior: smooth; }
.col { scroll-snap-align: start; }
.lc-move { display: flex; gap: 6px; margin-top: 8px; }
.lc-move button {
  flex: 1; border: 1px solid var(--hairline); background: var(--page); border-radius: 7px;
  font-size: 13px; padding: 5px 0; cursor: pointer; color: var(--ink-2); font-weight: 700;
}
.lc-move button:hover { background: #e3f1fd; color: var(--accent-deep); border-color: #a8cfef; }
.boardnav {
  position: fixed; bottom: 84px; right: 14px; z-index: 90; display: flex; gap: 8px;
}
@media (min-width: 701px) { .boardnav { bottom: 24px; right: 24px; } }
.boardnav button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); box-shadow: 0 2px 8px rgba(11,11,11,0.15);
  font-size: 18px; cursor: pointer; color: var(--ink-2);
}
.boardnav button:hover { color: var(--accent-deep); border-color: #a8cfef; }

/* ---------- Mobile bottom tab bar ---------- */
.tabbar { display: none; }
@media (max-width: 700px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .nav { display: none; }               /* main nav moves to the bottom bar */
  .topbar-right .btn { display: none; } /* + Lead lives in the bottom bar   */
  .wrap { padding: 16px 12px 90px; }    /* room for the tab bar             */
  .userchip { display: none; }

  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--surface); border-top: 1px solid var(--hairline);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(11,11,11,0.06);
  }
  .tabbar a {
    flex: 1; text-align: center; font-size: 11px; font-weight: 600;
    color: var(--ink-2); padding: 5px 2px; border-radius: 10px; text-decoration: none;
  }
  .tabbar a span { display: block; font-size: 20px; line-height: 1.2; }
  .tabbar a.on { color: var(--accent-deep); background: #e3f1fd; }
  .tabbar a.tab-add span {
    background: var(--accent-dark); color: #fff; width: 34px; height: 34px;
    border-radius: 50%; margin: 0 auto 1px; line-height: 34px; font-size: 22px;
  }
}
