/* CRM Global SM · design tokens and primitives extracted from the Claude Design prototype.
   Screens compose these classes; layout-specific grids may stay inline in the Blade view. */

:root {
  --bg: #f6f4f2;
  --surface: #fff;
  --surface-2: #faf8f6;
  --surface-3: #f2eee9;
  --ink: #1d1a18;
  --ink-2: #57504a;
  --muted: #8a827b;
  --muted-2: #a39b94;
  --line: #e6e1dc;
  --line-2: #e2dcd5;
  --line-3: #eee9e4;
  --accent: #cf1e2e;
  --accent-dark: #b3161f;
  --accent-soft: #fdecec;
  --sidebar: #1c1917;
  --sidebar-hover: #2a2523;
  --sidebar-active: #33302d;
  --sidebar-ink: #cfc7c0;
  --sidebar-muted: #877f78;
  --sidebar-label: #6d655f;

  --blue: #1d5fa8;   --blue-bg: #e8f0fa;
  --purple: #6b3fa0; --purple-bg: #f0eafa;
  --green: #1d7a4d;  --green-bg: #e6f4ec;
  --amber: #c98a12;  --amber-bg: #faf1e0;
  --brown: #9a6412;  --brown-bg: #faf1e0;
  --gray: #57504a;   --gray-bg: #f2eee9;
  --red: #b81c26;    --red-bg: #fdecec;

  --font-body: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: Archivo, var(--font-body);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 13.5px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
input, button, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: #d8d2cb; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
[x-cloak] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.sidebar-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 0 7px; flex: none; }
.sidebar-logo i { display: block; height: 3px; border-radius: 2px; background: #fff; }
.sidebar-logo i:nth-child(2) { width: 68%; opacity: .78; }
.sidebar-logo i:nth-child(3) { width: 40%; opacity: .5; }
.sidebar-section { display: flex; flex-direction: column; gap: 3px; }
.sidebar-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-label); padding: 4px 8px 6px; }
.nav-item { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 11px; padding: 9px; border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--sidebar-ink); text-decoration: none; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 700; }
.nav-item .icon { font-size: 14px; opacity: .9; text-align: center; }
.nav-item .badge-n { font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: #7d756e; }
.nav-item.active .badge-n { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid #332e2b; padding-top: 14px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -.01em; margin: 0; }
.topbar .sub { font-size: 12.5px; color: var(--muted); }
.page { padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 16px; }
.search-fake { display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2); min-width: 260px; color: var(--muted-2); font-size: 13px; }

/* ---------- primitives */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 16px 18px; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 9px; }
.kpi .label, .label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font-family: var(--font-display); font-size: 22px; font-weight: 600; white-space: nowrap; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bar { height: 6px; border-radius: 4px; background: var(--line-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 5px; color: var(--gray); background: var(--gray-bg); white-space: nowrap; }
.badge.blue { color: var(--blue); background: var(--blue-bg); }
.badge.purple { color: var(--purple); background: var(--purple-bg); }
.badge.green { color: var(--green); background: var(--green-bg); }
.badge.amber { color: var(--amber); background: var(--amber-bg); }
.badge.brown { color: var(--brown); background: var(--brown-bg); }
.badge.red { color: var(--red); background: var(--red-bg); }
.badge.accent { color: var(--accent-dark); background: var(--accent-soft); }
.badge.muted { color: var(--muted); background: var(--surface-3); }

.chip { padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { text-decoration: none; color: var(--ink); border-color: var(--ink); }
.chip.active { border-color: var(--sidebar); background: var(--sidebar); color: #fff; }
.chip .count { font-size: 11px; opacity: .7; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg a, .seg button { padding: 7px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: transparent; border: none; cursor: pointer; text-decoration: none; }
.seg .active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 15px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { text-decoration: none; color: var(--ink); border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.dark { background: var(--sidebar); border-color: var(--sidebar); color: #fff; }
.btn.dark:hover { background: var(--sidebar-active); color: #fff; }
.btn.sm { padding: 7px 11px; font-size: 12px; }
.btn.link { border: none; background: transparent; color: var(--blue); padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: var(--ink-2); flex: none; }
.avatar.lg { width: 38px; height: 38px; font-size: 13px; }
.avatar.dark { background: #3d3634; color: #e8e1da; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.input, .select, .textarea { padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 13px; outline: none; background: var(--surface); width: 100%; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.textarea { resize: vertical; min-height: 72px; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a827b'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--muted); }
.error { font-size: 12px; color: var(--red); }

/* grid tables (as in the prototype) */
.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl.scroll { overflow-x: auto; }
.tbl-head, .tbl-row { display: grid; gap: 12px; padding: 12px 16px; align-items: center; }
.tbl-head { background: var(--surface-2); border-bottom: 1px solid var(--line-3); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 16px; }
.tbl-row { border-bottom: 1px solid var(--surface-3); font-size: 12.5px; }
.tbl-row:last-child { border-bottom: none; }
.tbl-row.click { cursor: pointer; }
.tbl-row.click:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.title-sm { font-size: 12.5px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.divider { border-top: 1px solid var(--line-3); }
.empty { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { color: var(--ink); text-decoration: none; }

.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 14px 1fr; gap: 10px; }
.timeline-item .dot { margin-top: 5px; }

.alert { padding: 12px 14px; border-radius: 9px; font-size: 13px; }
.alert.success { background: var(--green-bg); color: var(--green); }
.alert.danger { background: var(--red-bg); color: var(--red); }
.alert.warn { background: var(--amber-bg); color: var(--brown); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,17,16,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; }
.modal.wide { max-width: 760px; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line-3); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0; }
.modal-body { display: flex; flex-direction: column; gap: 16px; padding: 20px 24px; }
.modal-foot { display: flex; gap: 10px; padding: 16px 24px 22px; border-top: 1px solid var(--line-3); }
.close-x { font-size: 18px; color: var(--muted-2); cursor: pointer; line-height: 1; background: none; border: none; }

/* kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 262px; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.board-col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.board-col.over { outline: 2px dashed var(--accent); }
.board-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; display: flex; flex-direction: column; gap: 7px; cursor: grab; }
.board-card:active { cursor: grabbing; }
.board-card.dragging { opacity: .5; }

/* auth */
.auth { display: grid; grid-template-columns: .9fr 1.1fr; min-height: 100vh; }
.auth-art { position: relative; background: #1c1917; color: #f4efe9; overflow: hidden; }
.auth-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; }
.auth-art .veil { position: absolute; inset: 0; background: linear-gradient(175deg, rgba(18,16,15,.86) 0%, rgba(18,16,15,.42) 46%, rgba(18,16,15,.9) 100%); }
.auth-art .inner { position: relative; padding: 48px 52px; min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; }
.auth-form { background: #fff; padding: 44px 64px 56px; display: flex; flex-direction: column; gap: 26px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* a timeline entry reached by its anchor (e.g. the visit MIA just registered) */
.timeline-item:target { background: var(--accent-soft); border-radius: 8px; margin: 0 -8px; padding: 6px 8px; scroll-margin-top: 90px; }
