/* Skyra CRM — application UI, layered on the site design system.
   Scanned and operated rather than read, so density and state legibility
   matter more here than editorial typography. */

body.crm { background: var(--bg-soft); display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 960px) { body.crm { grid-template-columns: 250px 1fr; } }

/* ---- Sidebar --------------------------------------------------------- */
.crm-sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem;
}
@media (min-width: 960px) { .crm-sidebar { position: sticky; top: 0; height: 100vh; } }

.ws-switch { display: grid; gap: .3rem; }
.ws-switch .select { width: 100%; padding: .55rem .8rem; font-size: var(--step--1); font-weight: 650; }
.ws-hint { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }

.crm-nav { display: grid; gap: .15rem; }
.crm-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem;
  border-radius: var(--r-sm); text-decoration: none; color: var(--text-soft);
  font-weight: 600; font-size: var(--step--1);
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.crm-nav a:hover { background: var(--bg-soft); color: var(--text); }
.crm-nav a.is-active { background: var(--brand-wash); color: var(--brand-ink); }
.crm-nav .pip {
  margin-left: auto; font-style: normal; font-size: .66rem; font-weight: 800;
  background: var(--danger); color: #fff; border-radius: var(--r-full);
  min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 .35rem;
}

.crm-sidebar-foot { margin-top: auto; display: grid; gap: .75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.crm-who { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.crm-who strong { display: block; font-size: var(--step--1); }
.crm-who span span { display: block; font-size: .7rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.crm-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-400), var(--accent-500));
  color: #fff; font-weight: 800; font-size: .9rem;
}

/* ---- Main ------------------------------------------------------------ */
.crm-main { min-width: 0; }
.crm-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 3vw, 1.75rem); background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.crm-topbar h1 { font-size: var(--step-2); }
.crm-body { padding: clamp(1rem, 3vw, 1.75rem); display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
/* Grid and flex children default to min-width:auto, which lets a wide scroller
   (the pipeline board) push the whole page sideways. Opt every level out. */
.crm-body > *, .crm-card, .crm-card-body, .crm-grid > * { min-width: 0; }

.crm-banner {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .85rem clamp(1rem, 3vw, 1.75rem);
  background: var(--ink-900); color: #fff; font-size: var(--step--1);
}
.crm-banner .btn { margin-left: auto; }

/* ---- Cards, tables, pills ------------------------------------------- */
.crm-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.crm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.crm-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.15rem; border-bottom: 1px solid var(--border);
}
.crm-card-head h2 { font-size: var(--step-1); }
.crm-card-body { padding: 1.15rem; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1.1rem 1.2rem; }
.stat .label { display: flex; align-items: center; gap: .45rem; font-size: var(--step--1); color: var(--text-muted); font-weight: 650; }
.stat b { display: block; font-size: var(--step-3); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: .45rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .74rem; color: var(--text-muted); margin-top: .3rem; }

.crm-table-wrap { overflow-x: auto; }
table.crm { width: 100%; min-width: 720px; font-size: var(--step--1); }
table.crm th, table.crm td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.crm thead th { background: var(--surface-alt); font-weight: 700; white-space: nowrap; }
table.crm tbody tr:hover td { background: var(--bg-soft); }
table.crm td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.crm a { color: inherit; text-decoration: none; font-weight: 650; }
table.crm a:hover { color: var(--brand-ink); }
.muted { color: var(--text-muted); font-size: .74rem; }

.st { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: var(--r-full); font-size: .68rem; font-weight: 700; white-space: nowrap; }
.st-ok   { background: var(--accent-wash); color: var(--accent); }
.st-info { background: var(--brand-wash);  color: var(--brand-ink); }
.st-warn { background: #FFF4E0; color: #A35B00; }
.st-bad  { background: var(--danger-wash); color: var(--danger); }
[data-theme="dark"] .st-warn { background: #3A2A08; color: #FBBF24; }

/* ---- Pipeline board -------------------------------------------------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(232px, 1fr); gap: .85rem; overflow-x: auto; padding-bottom: .5rem; align-items: start; }
.board-col { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--r-lg); padding: .7rem; display: grid; gap: .6rem; align-content: start; }
.board-col > header { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; padding: 0 .2rem; }
.board-col h3 { font-size: var(--step--1); font-weight: 700; }
.board-col .col-total { font-size: .7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.deal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: .75rem .85rem; display: grid; gap: .4rem; box-shadow: var(--shadow-xs); }
.deal-card strong { font-size: var(--step--1); line-height: 1.35; }
.deal-card .val { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand-ink); }
.deal-card .meta { font-size: .7rem; color: var(--text-muted); display: flex; justify-content: space-between; gap: .5rem; }
.deal-card select { width: 100%; padding: .35rem .5rem; font-size: .7rem; border-radius: var(--r-xs); border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); }

/* ---- Timeline -------------------------------------------------------- */
.timeline { display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 30px 1fr; gap: .75rem; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-wash); color: var(--brand-ink); }
.timeline .when { font-size: .7rem; color: var(--text-muted); }
.timeline p { font-size: var(--step--1); color: var(--text-soft); margin-top: .15rem; }

/* ---- Forms in the app ------------------------------------------------ */
.crm-form { display: grid; gap: .9rem; }
.crm-form .row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .crm-form .row.two { grid-template-columns: 1fr 1fr; } .crm-form .row.three { grid-template-columns: 1fr 1fr 1fr; } }
.crm-form label { font-size: var(--step--1); font-weight: 650; display: block; margin-bottom: .3rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.toolbar .input, .toolbar .select { padding: .5rem .75rem; font-size: var(--step--1); max-width: 230px; }

.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--text-muted); }
.empty .icon { opacity: .5; }

/* ---- Auth screens ---------------------------------------------------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; background: var(--bg-soft); }
.auth-card { width: 100%; max-width: 430px; }
.cred-box {
  background: var(--bg-sunk); border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  padding: 1rem; font-family: var(--font-mono); font-size: var(--step--1); display: grid; gap: .35rem;
}
.cred-box b { font-weight: 500; color: var(--text); }
