/* Look "B Charcoal calm" (DECISIONS #84). The values live in css/tokens.css.
   The old variable names below stay (other css files use them) and point at the tokens until each screen is migrated.
   --purple* is retired: the names are kept only so old rules keep working, they now mean charcoal / warm grey. */
:root {
  --ink: var(--c-ink);
  --text: var(--c-text);
  --muted: var(--c-muted);
  --faint: var(--c-faint);
  --line: var(--c-line);
  --line-strong: var(--c-line-strong);
  --bg: var(--c-page);
  --white: var(--c-card);
  --dark: var(--c-btn);
  --dark-hover: var(--c-btn-hover);
  --blue-btn: var(--c-btn);
  --blue-btn-hover: var(--c-btn-hover);
  --purple: var(--c-ink);
  --purple-dark: var(--c-text);
  --purple-soft: var(--c-select);
  --purple-line: var(--c-select-line);
  --tile: var(--c-tile);
  --radius: var(--r-lg);
  --radius-sm: var(--r-md);
  --sidebar-w: 224px;
  --topbar-h: 56px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: var(--c-page);
  color: var(--c-text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }

/* Sidebar (layout; details in nav.css) */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--c-card);
  border-inline-end: 1px solid var(--c-line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: var(--fw-semibold); font-size: var(--fs-body); color: var(--c-ink); min-width: 0; text-decoration: none; }
.brand .mark { width: 28px; height: 28px; border-radius: var(--r-md); background: var(--c-btn); color: var(--c-card); display: grid; place-items: center; font-size: var(--fs-body); font-weight: var(--fw-semibold); flex-shrink: 0; }
.brand .mark.has-logo { background: none; }
.brand .mark img, .brand .mark svg { width: 100%; height: 100%; object-fit: contain; }
.brand #brandName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group { font-size: var(--fs-hint); font-weight: var(--fw-semibold); color: var(--c-faint); padding: 14px 10px 6px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--c-text); text-decoration: none; font-weight: var(--fw-medium); font-size: var(--fs-body);
}
nav a i { font-style: normal; width: 16px; text-align: center; color: var(--c-faint); }
nav a:hover { background: var(--c-tile); }
nav a.active { background: var(--c-select); color: var(--c-ink); }
nav a.active i { color: var(--c-ink); }
.user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.user b { display: block; color: var(--c-ink); font-size: var(--fs-table); font-weight: var(--fw-semibold); }
.user small { color: var(--c-faint); font-size: var(--fs-hint); }

/* Content column: top tab bar + page */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; padding: 24px 24px 40px; min-width: 0; }
/* A work / reading page (FOCUS_PAGES in app.js) is --page-focus wide at most, centred: the side room comes from the padding,
   so drawers and pop-ups the page holds are untouched. Lists, tables and boards keep the full width. */
@media (min-width: 861px) {
  main.page-focus { padding-inline: max(var(--sp-5), calc((100% - var(--page-focus)) / 2)); }
  body.md-dw-open:not(.md-dw-modal) main.page-focus { padding-inline: var(--sp-5); } /* the side log needs the room */
}
.crumbs { font-size: var(--fs-hint); font-weight: var(--fw-medium); color: var(--c-faint); margin-bottom: 8px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { margin: 0; font-size: var(--fs-title); line-height: 1.2; font-weight: var(--fw-semibold); color: var(--c-ink); letter-spacing: -0.3px; }
.muted { color: var(--c-muted); margin: 4px 0 0; font-size: var(--fs-body); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: var(--fw-medium); font-size: var(--fs-body); line-height: 1.2;
  padding: 9px 14px; border-radius: var(--r-md);
  border: var(--btn2-bw) solid var(--btn2-border); background: var(--btn2-bg); color: var(--btn2-ink); box-shadow: var(--btn2-shadow);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--btn2-hover-bg); border-color: var(--btn2-hover-border); }
.btn:active { transform: var(--btn-press); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--c-btn); border-color: var(--c-btn); color: var(--c-card); font-weight: var(--fw-semibold); box-shadow: var(--btn-shadow); }
.btn.primary:hover { background: var(--c-btn-hover); border-color: var(--c-btn-hover); }
.icon-btn { background: none; border: 0; color: var(--c-muted); cursor: pointer; font-size: var(--fs-section); padding: 4px 6px; border-radius: var(--r-sm); line-height: 1; }
.icon-btn:hover { background: var(--c-select); color: var(--c-ink); }

/* Stats (KPI cards): icon tile on the left, big number, small label */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--c-card); border: 1px solid var(--c-card-line); border-radius: var(--r-lg); padding: 16px 20px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; align-content: center;
  box-shadow: var(--card-shadow);
}
.stat::before {
  content: ""; grid-column: 1; grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: var(--r-md); background-color: var(--c-tile);
  background-repeat: no-repeat; background-position: center; background-size: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233B6FE0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v16a2 2 0 0 0 2 2h16M7 16V9M12 16V5M17 16v-4'/%3E%3C/svg%3E");
}
.stat.has-ico::before, .stat > .stat-ico { display: none; }
.stat.has-ico > .stat-ico { display: grid; }
.stat .value { grid-column: 2; grid-row: 1; font-size: var(--fs-kpi); line-height: 1.2; font-weight: var(--fw-semibold); color: var(--c-ink); }
.stat .label { grid-column: 2; grid-row: 2; color: var(--c-muted); font-size: var(--fs-hint); font-weight: 400; }
.stat .hint { grid-column: 2; grid-row: 3; font-size: var(--fs-hint); color: var(--c-faint); margin-top: 2px; }
.stat .value em { font-style: normal; font-size: var(--fs-table); color: var(--c-ink); margin-inline-start: 6px; }
.stat-ico { grid-column: 1; grid-row: 1 / span 3; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--c-tile); color: var(--c-ink); place-items: center; }
.stat-ico .ico { width: 22px; height: 22px; }
/* KPI cards: one soft tint per card in order (blue, amber, orange, green, pink), a solid icon circle, white icon */
.stat > .stat-ico { border-radius: 50%; color: var(--c-card); }
.stat > .stat-ico .ico { color: var(--c-card); }
.stat:nth-child(5n+1) { background: var(--tint-blue-soft); border-color: var(--tint-blue-line); }
.stat:nth-child(5n+2) { background: var(--tint-amber-soft); border-color: var(--tint-amber-line); }
.stat:nth-child(5n+3) { background: var(--tint-orange-soft); border-color: var(--tint-orange-line); }
.stat:nth-child(5n+4) { background: var(--tint-green-soft); border-color: var(--tint-green-line); }
.stat:nth-child(5n+5) { background: var(--tint-pink-soft); border-color: var(--tint-pink-line); }
.stat:nth-child(5n+1) > .stat-ico { background: var(--tint-blue); }
.stat:nth-child(5n+2) > .stat-ico { background: var(--tint-amber); }
.stat:nth-child(5n+3) > .stat-ico { background: var(--tint-orange); }
.stat:nth-child(5n+4) > .stat-ico { background: var(--tint-green); }
.stat:nth-child(5n+5) > .stat-ico { background: var(--tint-pink); }

/* Card + toolbar (filter card) */
.card { background: var(--c-card); border: 1px solid var(--c-card-line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--card-shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--c-line); }
/* Soft scrollbar for panels and pop-ups (Sami 2026-11-01): a thin rounded thumb, no track, darker only when you use it */
.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times { scrollbar-gutter: stable; }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar { width: 10px; height: 10px; }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-track { background: transparent; }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-thumb { background: rgba(28, 27, 37, .14); background-clip: padding-box; border: 3px solid transparent; border-radius: var(--r-pill); min-height: 40px; }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times):hover::-webkit-scrollbar-thumb { background-color: rgba(28, 27, 37, .24); }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-thumb:hover { background-color: rgba(16, 24, 40, .55); }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-thumb:active { background-color: rgba(16, 24, 40, .75); }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-button { display: none; height: 0; }
:is(.soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times)::-webkit-scrollbar-corner { background: transparent; }
/* Firefox: no thumb styling there, so the thin standard bar in the same soft grey */
@supports not selector(::-webkit-scrollbar) {
  .soft-scroll, .la-fp-body, .md-dw-body, .md-fbody, .la-dp-times { scrollbar-width: thin; scrollbar-color: rgba(28, 27, 37, .2) transparent; }
}
/* Underline look for every row of tabs (Sami 2026-11-16, DECISIONS #306, look 1 of docs/prototypes/inner-tabs/; replaces look C of #263):
   no grey tray, a thin line under the row, the picked tab = blue words + a 3px blue line under it, 40px high for the sales tablet. */
.tabs { display: flex; gap: 4px; background: none; border: 0; border-bottom: 1px solid var(--c-line); border-radius: 0; padding: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
  font: inherit; font-size: var(--fs-table); font-weight: var(--fw-medium); color: var(--c-muted);
  background: none; border: 0; border-radius: var(--r-sm) var(--r-sm) 0 0; min-height: 40px; padding: 8px 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
}
/* Hover shows it is a button (said-once #4, Sami 2026-11-14): a grey ground and ink text, never the blue line of the picked tab */
.tabs button:not(.on):hover { background: var(--c-select); color: var(--c-ink); }
.tabs button span { color: var(--c-faint); margin-inline-start: 4px; font-weight: 400; }
/* Picked = blue (Sami 2026-11-14), as an underline (#306): solid blue stays for buttons */
.tabs button.on { background: none; color: var(--c-accent-text); box-shadow: inset 0 -3px 0 var(--c-accent); font-weight: var(--fw-semibold); }
.tabs button.on span { color: var(--c-accent-text); }
/* A count above zero stands out (Sami 2026-11-17): bold and dark; 0 stays faint. Which counts turn red by urgency comes later. */
.tabs button span.tab-hot { font-weight: var(--fw-semibold); }
.tabs button:not(.on) span.tab-hot { color: var(--c-ink); }
.tabs button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tabs button.on:focus-visible { box-shadow: inset 0 -3px 0 var(--c-accent), var(--focus-ring); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select, dialog input, dialog select, dialog textarea {
  font: inherit; font-size: var(--fs-body); padding: 9px 12px; border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md); background: var(--c-card); color: var(--c-ink);
}
.filters input { width: 240px; }
input::placeholder, textarea::placeholder { color: #9b9ca3; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--c-ink); box-shadow: var(--focus-ring); }

/* Table */
.card table { width: 100%; border-collapse: collapse; }
.card { overflow-x: auto; }
th, td { padding: 14px 16px; text-align: start; white-space: nowrap; }
th { font-size: var(--fs-table); font-weight: var(--fw-semibold); color: var(--c-text); border-bottom: 1px solid var(--c-line); background: var(--c-card); }
td { border-bottom: 1px solid var(--c-line); color: var(--c-text); font-size: var(--fs-body); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--c-tile); }
.lead { display: flex; align-items: center; gap: 10px; }
.lead b { display: block; color: var(--c-ink); font-weight: var(--fw-semibold); font-size: var(--fs-body); }
.lead small { display: block; color: var(--c-faint); max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--c-select); color: var(--c-ink); display: grid; place-items: center; font-size: var(--fs-hint); font-weight: var(--fw-semibold); flex-shrink: 0; }
.channel { display: inline-flex; align-items: center; gap: 6px; font-weight: var(--fw-medium); }
.channel i { font-style: normal; font-size: 9.5px; font-weight: var(--fw-semibold); width: 22px; height: 22px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--c-select); color: var(--c-muted); border: 1px solid var(--c-line); }
.stage {
  font: inherit; font-size: var(--fs-hint); font-weight: var(--fw-medium);
  border: 1px solid transparent; border-radius: var(--r-pill); padding: 4px 10px; cursor: pointer;
}
.stage:hover { filter: brightness(.96); } /* hover (said-once #4, 2026-11-14) */
.row-actions button { background: none; border: 0; cursor: pointer; color: var(--c-faint); font: inherit; font-weight: var(--fw-medium); padding: 4px 6px; }
.row-actions button:hover { color: var(--c-ink); }
.empty { text-align: center; color: var(--c-muted); padding: 36px; margin: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--c-line); color: var(--c-muted); font-size: var(--fs-table); }

/* Stage colors (soft pills, Neravo palette) */
.s-new        { background: #f0f7fd; color: #2c5d8a; border-color: #dcebf8; }
.s-contacted  { background: #d4f1ff; color: #1f5a7a; border-color: #bfe6f8; }
.s-qualified  { background: #dafbea; color: #1f6b44; border-color: #c2f0d7; }
.s-visit      { background: #f6ecf6; color: #8a4486; border-color: #ecd6ea; }
.s-won        { background: #d1ffdb; color: #1b6a35; border-color: #b6f2c4; }
.s-lost       { background: #ffcaca; color: #9b2c2c; border-color: #f5b3b3; }

/* Old-style dialog */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(512px, 92vw); color: var(--c-text); box-shadow: 0 20px 50px rgba(20,20,28,.22); }
dialog::backdrop { background: rgba(20,20,28,.45); }
dialog form { padding: 22px 24px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
dialog h2 { margin: 0; font-size: var(--fs-title); font-weight: var(--fw-semibold); color: var(--c-ink); }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--c-ink); }
dialog label.full, .actions { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
dialog .actions .btn.primary { background: var(--c-btn); border-color: var(--c-btn); }

@media (max-width: 860px) {
  body { flex-direction: column; }
  main { padding: 16px 16px 32px; }
  h1 { font-size: var(--fs-title); }
  .filters input { width: 100%; }
  dialog form { grid-template-columns: 1fr; }
}
