/* ============================================================
   CallSynclaire — "Synclaire" app design system
   Editorial: Fraunces display + DM Sans body; bone / ink / brass.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

:root {
  --bone: #FAF8F5;
  --bone-2: #F1ECE3;
  --paper: #ffffff;
  --ink: #1A1A18;
  --ink-2: #26241f;
  --ink-3: #322f28;
  --brass: #C5923A;
  --brass-deep: #9D7124;
  --brass-soft: #F3E7CF;
  --muted: #6E6A62;
  --muted-2: #97928a;
  --on-ink: #EDE9E1;
  --on-ink-muted: rgba(237, 233, 225, .62);
  --line: rgba(26, 26, 24, .12);
  --line-soft: rgba(26, 26, 24, .07);
  --line-dark: rgba(237, 233, 225, .12);
  --green: #2f9e6b; --green-bg: #e6f4ec;
  --red: #c2472f; --red-bg: #fbe9e5;
  --amber: #a9791f; --amber-bg: #f7edd6;

  --display: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26,26,24,.04), 0 10px 30px -18px rgba(26,26,24,.25);
  --shadow-lg: 0 30px 70px -30px rgba(26,26,24,.4);
  --sidebar-w: 264px;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sans); background: var(--bone); color: var(--ink); line-height: 1.55; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--sans); font-weight: 600; font-size: .9rem; line-height: 1;
  padding: .7rem 1.25rem; border-radius: 999px; cursor: pointer; border: 1px solid transparent;
  transition: transform .15s, box-shadow .15s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brass); color: var(--ink); box-shadow: 0 8px 20px -10px rgba(197,146,58,.6); }
.btn-primary:hover { box-shadow: 0 12px 26px -10px rgba(197,146,58,.75); }
.btn-dark { background: var(--ink); color: var(--bone); }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn-ghost:hover { background: rgba(26,26,24,.05); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: .5rem .85rem; font-size: .82rem; }
.btn-lg { padding: .95rem 1.7rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.icon-btn { background: transparent; border: none; cursor: pointer; font-size: 1.1rem; color: var(--muted); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(26,26,24,.06); color: var(--ink); }

/* ---------------------------------------------------------------- app shell */
.app-body { background: var(--bone); }
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--ink); color: var(--on-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 1.25rem 0;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: .25rem 1.5rem 1.25rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brass); color: var(--ink); display: grid; place-items: center; font-family: var(--display); font-weight: 600; }
.brand-name { font-family: var(--display); font-size: 1.25rem; font-weight: 500; color: var(--on-ink); }
.nav { flex: 1; overflow-y: auto; padding: .5rem .75rem; display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--on-ink-muted); padding: 1.1rem .75rem .35rem; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .58rem .75rem; border-radius: 10px; color: var(--on-ink-muted); font-weight: 500; font-size: .9rem; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(237,233,225,.06); color: var(--on-ink); }
.nav-link.is-active { background: rgba(197,146,58,.16); color: #fff; }
.nav-link.is-active .nav-ico { color: var(--brass); }
.nav-ico { width: 20px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 1rem 1.25rem 0; border-top: 1px solid var(--line-dark); margin-top: .5rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brass); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.user-meta { display: flex; flex-direction: column; overflow: hidden; }
.user-meta strong { font-size: .88rem; color: var(--on-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: .75rem; color: var(--on-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .btn-ghost { color: var(--on-ink-muted); border: 1px solid var(--line-dark); }
.sidebar-foot .btn-ghost:hover { background: rgba(237,233,225,.06); color: var(--on-ink); }

.app-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; height: 64px; padding: 0 clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bone) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.topbar-title { font-family: var(--display); font-size: 1.05rem; font-weight: 500; }
.menu-toggle { display: none; }
.app-main { flex: 1; padding: clamp(1.25rem, 3vw, 2.25rem); max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.page-title { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.page-sub { color: var(--muted); margin-top: .35rem; font-size: .95rem; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-pad { padding: 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.5rem; border-bottom: 1px solid var(--line-soft); }
.card-head h2, .card-head h3 { font-size: 1.15rem; }
.card-body { padding: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 2rem 0 1rem; }
.section-head h2 { font-size: 1.35rem; }
.eyebrow, .section-label { display: inline-flex; align-items: center; gap: .5rem; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brass-deep); }

/* ---------------------------------------------------------------- stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 1.35rem; box-shadow: var(--shadow); }
.stat-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--brass-soft); color: var(--brass-deep); display: grid; place-items: center; font-size: 1.1rem; margin-bottom: .9rem; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-family: var(--display); font-size: 2rem; font-weight: 500; margin-top: .2rem; }
.stat-delta { font-size: .8rem; font-weight: 600; margin-top: .35rem; }
.stat-delta.up { color: var(--green); } .stat-delta.down { color: var(--red); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: .85rem 1.25rem; background: var(--bone); border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data td { padding: .95rem 1.25rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:last-child td, table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; transition: background .12s; }
table.data tr.clickable:hover { background: var(--bone); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.pager-btns { display: flex; gap: .5rem; }
.toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .74rem; font-weight: 600; padding: .28rem .6rem; border-radius: 999px; white-space: nowrap; }
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-danger { background: var(--red-bg); color: var(--red); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-neutral { background: var(--bone-2); color: var(--muted); }

/* ---------------------------------------------------------------- forms */
.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; }
.form-hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.form-error { font-size: .8rem; color: var(--red); margin-top: .35rem; }
.form-input, .form-select, .form-textarea {
  width: 100%; font-family: var(--sans); font-size: .92rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .7rem .85rem; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(197,146,58,.15); }
.form-textarea { min-height: 110px; resize: vertical; }
.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type="color"] { width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; padding: 2px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- tabs (segmented) */
.tabs { display: inline-flex; gap: .25rem; padding: .28rem; background: var(--bone-2); border-radius: 999px; margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab { border: none; background: transparent; font-family: var(--sans); font-weight: 600; font-size: .85rem; padding: .5rem 1rem; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tab.is-active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ---------------------------------------------------------------- drawer */
.drawer-scrim { position: fixed; inset: 0; background: rgba(26,26,24,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 92vw); background: var(--paper); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .25s cubic-bezier(.2,.7,.2,1); z-index: 61; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { font-size: 1.3rem; }
.drawer-body { padding: 1.5rem; overflow-y: auto; }
.detail-list { display: flex; flex-direction: column; }
.detail-row { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.detail-row .k { color: var(--muted); }
.detail-row .v { font-weight: 500; text-align: right; }

/* ---------------------------------------------------------------- chat / transcript */
.chat-bubble { padding: .8rem 1rem; border-radius: 14px; margin-bottom: .6rem; max-width: 80%; font-size: .92rem; }
.chat-bubble.ai { background: var(--bone-2); }
.chat-bubble.user { background: var(--ink); color: var(--on-ink); margin-left: auto; }
.transcript { display: flex; flex-direction: column; gap: .5rem; }
.call-row { display: flex; align-items: center; gap: .6rem; }
.call-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brass); }

/* ---------------------------------------------------------------- pipeline (kanban) */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.pipe-col { background: var(--bone-2); border-radius: var(--radius); padding: .85rem; min-height: 120px; }
.pipe-col > h3 { font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .75rem; display: flex; justify-content: space-between; }
.job-card { background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px; padding: .85rem; margin-bottom: .6rem; cursor: pointer; box-shadow: var(--shadow); }
.job-card:hover { border-color: var(--brass); }
.jc-title { font-weight: 600; font-size: .9rem; }
.jc-meta { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.count { background: var(--bone-2); border-radius: 999px; padding: 0 .5rem; font-size: .72rem; color: var(--muted); }

/* ---------------------------------------------------------------- misc */
.live-url { display: inline-flex; align-items: center; gap: .5rem; background: var(--bone-2); border-radius: 999px; padding: .4rem .9rem; font-size: .85rem; font-weight: 500; }
.summary-box { background: var(--bone-2); border-radius: var(--radius); padding: 1.25rem; }
.detail-list + .summary-box { margin-top: 1rem; }

/* ---------------------------------------------------------------- states */
.state-block { text-align: center; padding: 3.5rem 1.5rem; color: var(--muted); }
.state-icon { font-size: 2rem; margin-bottom: .75rem; }
.state-block h3 { font-family: var(--display); color: var(--ink); margin-bottom: .35rem; }
.state-error h3 { color: var(--red); }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--brass); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-sm { width: 15px; height: 15px; border-width: 2px; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- toast */
.toast-host { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .6rem; z-index: 80; }
.toast { background: var(--ink); color: var(--on-ink); padding: .85rem 1.15rem; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 340px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--amber); }

/* ---------------------------------------------------------------- auth pages */
.auth-page { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-hero { background: var(--ink); color: var(--on-ink); padding: clamp(2rem, 4vw, 3.5rem); display: flex; flex-direction: column; justify-content: space-between; gap: 1.75rem; position: relative; overflow: hidden; }
.auth-hero .brand, .auth-hero .logo { display: flex; align-items: center; gap: .6rem; }
.auth-hero .brand-name { color: var(--on-ink); font-family: var(--display); font-size: 1.25rem; }
.auth-hero-body { display: flex; flex-direction: column; gap: 1.5rem; flex: 1; justify-content: center; }
.auth-hero h2 { font-size: clamp(1.5rem, 2.4vw, 2.1rem); color: var(--on-ink); max-width: 18ch; }
.auth-hero .sub, .auth-hero p { color: var(--on-ink-muted); margin-top: .5rem; max-width: 36ch; }
/* testimonial: portrait tied to the quote */
.auth-testimonial { display: flex; flex-direction: column; gap: 1rem; }
.auth-portrait { width: 100%; height: clamp(180px, 26vh, 300px); object-fit: cover; object-position: 50% 22%; border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line-dark); }
.auth-quote { font-family: var(--display); font-style: italic; font-weight: 400; font-size: clamp(1.15rem, 1.7vw, 1.5rem); line-height: 1.3; color: var(--on-ink); max-width: 30ch; border: none; margin: 0; }
.auth-quote em { color: var(--brass); font-style: italic; }
.auth-attrib { display: flex; align-items: center; gap: .55rem; font-size: .85rem; color: var(--on-ink-muted); font-weight: 500; }
.auth-attrib .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); flex-shrink: 0; }
.auth-attrib b { color: var(--on-ink); font-weight: 600; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand, .auth-card .logo { display: inline-flex; align-items: center; gap: .5rem; }
.auth-card .brand-mark { background: var(--ink); color: var(--bone); }
.auth-card .brand-name { color: var(--ink); font-family: var(--display); font-size: 1.2rem; }
.auth-card h1 { font-size: 2rem; margin-bottom: .35rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 1.5rem; }
.auth-foot { text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--muted); }
.auth-foot a { color: var(--brass-deep); font-weight: 600; }
@media (max-width: 820px) { .auth-page { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------------------------------------------------------------- responsive */
.sidebar-backdrop { display: none; }
@media (max-width: 940px) {
  .sidebar { position: fixed; z-index: 70; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(26,26,24,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 65; }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
}
