/* Callnomics Solutions Portal — self-contained UI, no CDN */
:root {
  /* Callnomics Solutions palette — deep navy + sky blue, from the brand logo */
  --bg: #0c1729;
  --bg-2: #111f36;
  --panel: #13223c;
  --panel-2: #182a49;
  --line: rgba(148, 180, 224, 0.14);
  --text: #eaf1fb;
  --muted: #93a5c2;
  --brand: #58b7f5;
  --brand-2: #9bd7ff;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --glow-1: rgba(88, 183, 245, .14);
  --glow-2: rgba(155, 215, 255, .07);
  --brand-soft: color-mix(in srgb, var(--brand) 14%, transparent);
  --brand-border: color-mix(in srgb, var(--brand) 30%, transparent);
  --radius: 14px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Fit any screen (phone / tablet / desktop) ──
   Stops a single wide child from forcing the page wider than the device
   (the flex/grid min-width:auto trap that makes mobile browsers zoom out). */
html, body { max-width: 100%; overflow-x: hidden; }
.main { min-width: 0; max-width: 100%; }
.shell, .grid, .kpis, .two-col, .form-grid, .filters, .topbar, .card { min-width: 0; }
.grid > *, .kpis > *, .two-col > *, .form-grid > *, .filters > *, .topbar > * { min-width: 0; }
img, svg, video, canvas, iframe { max-width: 100%; }
pre { max-width: 100%; overflow-x: auto; }
table { max-width: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1100px 500px at 80% -10%, var(--glow-1), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--glow-2), transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.owner-banner {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, rgba(251, 191, 36, .16), rgba(251, 191, 36, .08));
  border-bottom: 1px solid rgba(251, 191, 36, .35);
  color: #fcd34d; font-size: .85rem; padding: 8px 18px;
}
.owner-banner a { color: #fde68a; margin-left: 14px; text-decoration: underline; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.5rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 420px; background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 20px; padding: 38px 34px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-weight: 800; color: #0b1020; font-size: 1.1rem;
}
.logo-name { font-weight: 700; font-size: 1.02rem; letter-spacing: .04em; }
.logo-name span { color: var(--brand-2); }
.logo-sub { font-size: .62rem; font-weight: 600; letter-spacing: .34em; color: var(--brand); margin-top: 1px; }
.logo-mark.client-logo { background: transparent; color: var(--brand); padding: 3px; }
.logo-mark.client-logo svg, .logo-mark.client-logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.logo-mark.cn-logo { background: transparent; padding: 0; }
.logo-mark.cn-logo svg { width: 100%; height: 100%; display: block; }
.login-logo { margin-bottom: 8px; }
.login-logo .logo-mark { width: 46px; height: 46px; }
.login-logo .logo-name { font-size: 1.3rem; }
.nav-link .ico { display: inline-flex; }
.nav-link .ico svg { width: 17px; height: 17px; }
.login-sub { color: var(--muted); margin: 4px 0 26px; font-size: .9rem; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 11px 18px;
  font: inherit; font-weight: 600; cursor: pointer; color: #0b1020;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.full { width: 100%; }
.btn.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  font-weight: 500;
}
.btn.sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.error-box {
  background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .35);
  color: #fca5a5; border-radius: 10px; padding: 10px 13px; font-size: .85rem;
  margin-bottom: 14px;
}
.demo-creds {
  margin-top: 22px; padding: 13px 15px; border-radius: 10px; font-size: .78rem;
  background: rgba(109, 139, 255, .07); border: 1px dashed rgba(109, 139, 255, .3);
  color: var(--muted); line-height: 1.7;
}
.demo-creds code { color: var(--brand-2); }

/* ── App shell ── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: rgba(10, 14, 30, .75); border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 10px 18px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--muted); font-size: .92rem; font-weight: 500;
}
.nav-link:hover { background: var(--brand-soft); color: var(--text); }
.nav-link.active {
  background: linear-gradient(90deg, var(--brand-soft), transparent);
  color: var(--text); border: 1px solid var(--brand-border);
}
.nav-link .ico { width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }
.userbox {
  border-top: 1px solid var(--line); padding: 14px 10px 4px; font-size: .84rem;
}
.userbox .who { font-weight: 600; }
.main { padding: 26px 30px 60px; max-width: 1220px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }

/* ── Cards / grid ── */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.kpi .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 1.7rem; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.kpi .up { color: var(--good); }
.two-col { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } .shell { grid-template-columns: 64px 1fr; } .nav-label, .sidebar .logo-name, .userbox { display: none; } }

/* ── Mobile (phones) ── */
.mobile-bar { display: none; }
.nav-scrim { display: none; }
@media (max-width: 640px) {
  .mobile-bar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; height: 54px; z-index: 58;
    align-items: center; gap: 14px; padding: 0 16px;
    background: #0a0e1e; border-bottom: 1px solid var(--line);
  }
  .mobile-bar .hamburger { font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--text); padding: 2px 4px; }
  .mobile-bar .mobile-title { font-weight: 700; font-size: .95rem; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 65; width: 260px; max-width: 82vw;
    height: 100vh; height: 100dvh;
    -webkit-transform: translateX(-100%); transform: translateX(-100%);
    transition: transform .22s ease; overflow-y: auto;
  }
  #nav-toggle:checked ~ .shell .sidebar { -webkit-transform: translateX(0); }
  /* re-show full labels inside the drawer (they were hidden at the 980px tier) */
  .nav-label, .sidebar .logo-name, .userbox { display: block; }
  #nav-toggle:checked ~ .shell .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.6); }
  #nav-toggle:checked ~ .shell .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55);
  }

  .main { padding: 14px 14px 48px; margin-top: 54px; max-width: 100%; }
  .owner-banner { font-size: .78rem; padding: 8px 12px; }
  .topbar { margin-bottom: 16px; }
  .topbar h1 { font-size: 1.4rem; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px; }
  .kpi .value { font-size: 1.4rem; }

  /* keep wide tables usable: horizontal scroll instead of overflowing the page */
  .main table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  /* stack forms and filter rows vertically, full-width inputs */
  .form-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select, .filters .btn { width: 100%; min-width: 0; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom-on-focus */
}

/* ── Bar chart ── */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar {
  width: 100%; border-radius: 6px 6px 2px 2px; min-height: 3px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 25%, transparent));
}
.chart .bar-label { font-size: .62rem; color: var(--muted); white-space: nowrap; transform: rotate(-38deg); height: 22px; }
.chart .bar-count { font-size: .68rem; color: var(--muted); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th { text-align: left; color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
a.card { display: block; color: inherit; transition: border-color .15s, transform .1s; }
a.card:hover { border-color: var(--brand-border); transform: translateY(-2px); }
.table-scroll { overflow-x: auto; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; border: 1px solid transparent; }
.b-new { background: rgba(109, 139, 255, .15); color: #a5b8ff; border-color: rgba(109, 139, 255, .3); }
.b-contacted { background: rgba(34, 211, 238, .12); color: #67e8f9; border-color: rgba(34, 211, 238, .3); }
.b-qualified { background: rgba(251, 191, 36, .12); color: #fcd34d; border-color: rgba(251, 191, 36, .3); }
.b-booked { background: rgba(192, 132, 252, .14); color: #d8b4fe; border-color: rgba(192, 132, 252, .3); }
.b-converted { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .3); }
.b-lost { background: rgba(248, 113, 113, .12); color: #fca5a5; border-color: rgba(248, 113, 113, .3); }
.b-active { background: rgba(52, 211, 153, .13); color: #6ee7b7; border-color: rgba(52, 211, 153, .3); }
.b-paused { background: rgba(251, 191, 36, .12); color: #fcd34d; border-color: rgba(251, 191, 36, .3); }
.b-completed { background: rgba(52, 211, 153, .13); color: #6ee7b7; }
.b-scheduled { background: rgba(109, 139, 255, .15); color: #a5b8ff; }
.b-draft { background: rgba(148, 163, 224, .12); color: var(--muted); }

/* ── Funnel ── */
.funnel-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.funnel-row .fname { width: 84px; font-size: .8rem; color: var(--muted); }
.funnel-row .ftrack { flex: 1; height: 22px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.funnel-row .ffill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.funnel-row .fnum { width: 110px; text-align: right; font-size: .82rem; }

/* ── Forms inline ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; padding: 8px 11px; font-size: .87rem; }

/* ── Assistant chat ── */
.chat-box { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 6px 4px 16px; }
.msg { max-width: 78%; padding: 11px 15px; border-radius: 14px; line-height: 1.55; font-size: .92rem; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #0b1020; font-weight: 500; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant strong, .msg.assistant b { color: var(--brand-2); }
.chat-input { display: flex; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: .78rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); cursor: pointer; background: transparent; font-family: inherit; }
.chip:hover { border-color: var(--brand); color: var(--text); }

/* ── Alerts / creds ── */
.creds-box {
  background: rgba(52, 211, 153, .08); border: 1px solid rgba(52, 211, 153, .35);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.creds-box code { background: var(--bg-2); padding: 2px 8px; border-radius: 6px; color: var(--brand-2); font-size: .95em; }
details.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 16px; }
details.panel summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; }
details.panel summary::before { content: "＋ "; color: var(--brand-2); }
details.panel[open] summary::before { content: "－ "; }
details.panel .panel-body { padding: 4px 18px 18px; }
/* ── Brand identity picker (Admin Console) ── */
.brand-picker { border-top: 1px solid var(--line); padding-top: 14px; }
input[type="color"].color-input {
  padding: 3px; height: 42px; cursor: pointer; background: var(--bg-2);
}
.brand-preview { display: flex; gap: 8px; align-items: center; min-height: 42px; }
.brand-preview .swatch {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  display: inline-block;
}
.brand-logo-thumb {
  width: 42px; height: 42px; border-radius: 10px; border: 1px dashed var(--line);
  display: inline-grid; place-items: center; overflow: hidden; background: var(--bg-2);
}
.brand-logo-thumb img, .brand-logo-thumb svg { width: 100%; height: 100%; object-fit: contain; }

.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.section-title { margin: 26px 0 12px; font-size: 1.02rem; }
.pill-note { font-size: .76rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; display: inline-block; }

/* Show/hide password toggle — used on login, change-password, and admin reset */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 58px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--accent, #4aa8ef); font-size: .74rem;
  font-weight: 600; cursor: pointer; padding: 4px 6px; letter-spacing: .02em;
}
.pw-toggle:hover { text-decoration: underline; }

/* Button that visually matches a text link (used for POST-based sign out) */
.linkbtn { background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  color: var(--accent, #4aa8ef); font: inherit; text-decoration: none; }
.linkbtn:hover { text-decoration: underline; }
