@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
/* MyShopMetrics distributor portal shell — palette + primitives + chrome.
   Loaded by every /d/* page. Page-specific layout still lives inline. */

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a121d;
  --panel: #1a2433;
  --panel-2: #1f2a37;
  --panel-3: #243246;
  --line: #2c3d56;
  --line-2: #3a4d6a;

  --fg: #f1f5f9;
  --fg-2: #cbd5e1;
  --fg-3: #94a3b8;
  --fg-4: #64748b;

  --accent: #06b6d4;
  --accent-2: #0891b2;
  --accent-soft: rgba(6, 182, 212, 0.16);

  --brass: #C97B17;
  --brass-2: #d88420;
  --brass-soft: rgba(201, 123, 23, 0.18);

  --good: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;

  --radius: 10px;
  --radius-lg: 14px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter Tight', 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
button { font-family: inherit; cursor: pointer; }

/* ---------- Top app nav ---------- */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 18, 29, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.app-nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
}
.app-brand-mark {
  width: 26px; height: 26px; background: #fff; color: #0a121d;
  border-radius: 5px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; position: relative; overflow: hidden; flex-shrink: 0;
  margin-right: 9px;
}
.app-brand-mark::after {
  content: ""; position: absolute; right: 0; top: 0; width: 0; height: 0;
  border-top: 7px solid #C97B17; border-left: 7px solid transparent;
}
.app-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-brand .lite { color: var(--accent); }
.app-brand small {
  color: var(--fg-3);
  font-weight: 500;
  font-size: 12px;
  margin-left: 6px;
}
.app-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-nav-links::-webkit-scrollbar { display: none; }
.app-nav-links a {
  color: var(--fg-3);
  font-weight: 500;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 7px;
  white-space: nowrap;
}
.app-nav-links a:hover { color: var(--fg); background: var(--panel-2); }
.app-nav-links a.active {
  color: var(--fg);
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 7px 7px 0 0;
}
.app-brand-link { text-decoration: none; }
.app-brand-link:hover .app-brand { color: var(--fg); }
.app-nav-user {
  display: flex;
  align-items: center;
  position: relative;
  white-space: nowrap;
  gap: 2px;
}
.app-tool-link {
  color: var(--fg-3);
  font-weight: 500;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
  white-space: nowrap;
}
.app-tool-link:hover { color: var(--fg); background: var(--panel-2); }
.app-tool-sep {
  width: 1px;
  height: 18px;
  background: var(--line-2);
  margin: 0 6px;
  display: inline-block;
}
.app-settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-3);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.app-settings-btn:hover { background: var(--panel-2); color: var(--fg); border-color: var(--line-2); }
.app-settings-btn[aria-expanded="true"] { background: var(--panel-2); color: var(--fg); border-color: var(--accent); }
.app-settings-btn .me { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.app-settings-btn .chev { font-size: 9px; opacity: 0.7; }

.app-settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 60;
  animation: settingsIn 0.12s ease-out;
}
@keyframes settingsIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.app-settings-menu .settings-header {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--fg);
  word-break: break-all;
}
.app-settings-menu .settings-header > div { font-weight: 500; margin-top: 2px; }
.app-settings-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--fg-2);
  font-size: 13.5px;
  font-weight: 500;
}
.app-settings-menu a:hover { background: var(--panel-2); color: var(--fg); }
.app-settings-menu a.muted-link { color: var(--fg-3); }
.app-settings-menu .settings-sep { height: 1px; background: var(--line); margin: 6px 0; }

@media (max-width: 720px) {
  .app-nav-inner { gap: 10px; padding: 9px 12px; }
  .app-brand { font-size: 14px; }
  .app-brand small { display: none; }
  .app-settings-btn .me { max-width: 110px; }
  /* Tool links hide on narrow screens — they're still reachable from the dropdown. */
  .app-tool-link, .app-tool-sep { display: none; }
}

/* Tier-2 sub-nav (CRM section) */
.app-subnav {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.app-subnav-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-subnav-inner::-webkit-scrollbar { display: none; }
.app-subnav-inner a {
  color: var(--fg-3);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.app-subnav-inner a:hover { color: var(--fg); }
.app-subnav-inner a.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
@media (max-width: 720px) {
  .app-subnav-inner { padding: 0 12px; }
  .app-subnav-inner a { padding: 9px 11px; font-size: 13px; }
}

/* Hub-tile cards (used on /d/crm/) */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 720px) { .hub-grid { grid-template-columns: 1fr; } }
.hub-tile {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  transition: border-color 0.12s, transform 0.05s;
  color: var(--fg);
}
.hub-tile:hover { border-color: var(--accent); color: var(--fg); }
.hub-tile:active { transform: scale(0.997); }
.hub-tile .h-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.hub-tile .h-icon {
  width: 36px;
  height: 36px;
  background: var(--panel-2);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.hub-tile .h-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.hub-tile .h-count { color: var(--fg-3); font-size: 13px; font-weight: 600; }
.hub-tile .h-desc { color: var(--fg-2); font-size: 13.5px; line-height: 1.55; margin-top: 6px; }
.hub-tile .h-foot { color: var(--fg-3); font-size: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; gap: 14px; flex-wrap: wrap; }
.hub-tile .h-foot .num { color: var(--fg); font-weight: 600; }

/* ---------- App container ---------- */
.app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 18px 80px;
}
.app-container.narrow { max-width: 920px; }

/* ---------- Section header ---------- */
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.section-head h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  min-width: 160px;
}
.section-head .sub {
  color: var(--fg-3);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  min-height: 38px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--fg-2);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--panel-2); color: var(--fg); border-color: var(--accent); }
.btn-brass {
  background: var(--brass);
  border-color: var(--brass);
}
.btn-brass:hover { background: var(--brass-2); border-color: var(--brass-2); }
.btn-bad {
  background: transparent;
  color: var(--bad);
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-bad:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--bad); color: var(--bad); }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-lg { padding: 20px; border-radius: var(--radius-lg); }
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head h2 {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.panel-head h2.lg {
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--fg);
  font-size: 15px;
}

/* ---------- Inputs ---------- */
.input, textarea.input, select.input {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.12s;
}
.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { min-height: 88px; resize: vertical; line-height: 1.5; }
.input-label {
  display: block;
  color: var(--fg-3);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}
.input-label:first-child { margin-top: 0; }
.input-label .req { color: var(--bad); margin-left: 3px; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .input-row { grid-template-columns: 1fr; } }
.input-help { color: var(--fg-3); font-size: 12px; margin-top: 4px; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.muted { color: var(--fg-3); }

/* ---------- Tabs (pill-style, scrollable on mobile) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: transparent;
  color: var(--fg-3);
  border: 0;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--fg); }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .badge {
  display: inline-block;
  background: var(--panel-2);
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 6px;
}
.tabs button.active .badge { background: var(--accent-soft); color: var(--accent); }

/* ---------- Chips / pills / tags ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--fg-2);
  border: 1px solid var(--line-2);
  white-space: nowrap;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(6, 182, 212, 0.3); }
.chip-brass { background: var(--brass-soft); color: var(--brass-2); border-color: rgba(201, 123, 23, 0.3); }
.chip-good { background: rgba(16, 185, 129, 0.15); color: var(--good); border-color: rgba(16, 185, 129, 0.3); }
.chip-warn { background: rgba(245, 158, 11, 0.15); color: var(--warn); border-color: rgba(245, 158, 11, 0.3); }
.chip-bad { background: rgba(239, 68, 68, 0.15); color: var(--bad); border-color: rgba(239, 68, 68, 0.3); }

/* Severity helper for flags / priority */
.sev-low { color: var(--fg-3); }
.sev-normal { color: var(--accent); }
.sev-high { color: var(--brass-2); }
.sev-urgent { color: var(--bad); font-weight: 700; }

/* ---------- Activity timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}
.timeline-item {
  position: relative;
  padding: 4px 0 18px 0;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--line-2);
}
.timeline-item.note::before { border-color: var(--accent); }
.timeline-item.recap::before { border-color: var(--good); background: var(--good); }
.timeline-item.brief::before { border-color: var(--brass); background: var(--brass); }
.timeline-item.task::before { border-color: var(--warn); }
.timeline-when {
  color: var(--fg-3);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.timeline-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
}
.timeline-card .head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.timeline-card .head strong { font-size: 13.5px; color: var(--fg); }
.timeline-card .body { color: var(--fg-2); font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.timeline-card .meta { color: var(--fg-3); font-size: 11.5px; margin-top: 6px; }

/* ---------- List items ---------- */
.list { list-style: none; }
.list-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item:first-child { padding-top: 0; }
.list-item .title { font-size: 13.5px; color: var(--fg); font-weight: 500; }
.list-item .meta { color: var(--fg-3); font-size: 11.5px; margin-top: 2px; }
.list-empty {
  color: var(--fg-3);
  font-size: 13px;
  font-style: italic;
  padding: 18px 0;
  text-align: center;
}

/* ---------- Status path stepper (for visit briefs) ---------- */
.path {
  display: flex;
  gap: 0;
  margin: 8px 0 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line-2);
}
.path-step {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  background: var(--panel-2);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: relative;
}
.path-step.done { background: var(--accent); color: #fff; }
.path-step.active { background: var(--brass); color: #fff; }
.path-step + .path-step { border-left: 1px solid var(--line); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 200;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.modal .sub { color: var(--fg-3); font-size: 13px; margin-bottom: 14px; }
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--fg);
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  border-left: 3px solid var(--accent);
  max-width: 360px;
  animation: toastIn 0.2s ease-out;
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Loading spinner ---------- */
.loading {
  color: var(--fg-3);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Utilities ---------- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 18px; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 14px; }
.mb-lg { margin-bottom: 22px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-fg-2 { color: var(--fg-2); }
.text-fg-3 { color: var(--fg-3); }
.text-fg-4 { color: var(--fg-4); }
.text-bad { color: var(--bad); }
.text-good { color: var(--good); }
.text-warn { color: var(--warn); }
.text-accent { color: var(--accent); }
.no-wrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
hr.div { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* Quick-action button row that scrolls on mobile */
.quick-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 14px 0;
  padding-bottom: 4px;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-actions .btn { flex-shrink: 0; }

/* Two-column app layouts (account.html, chat.html) */
.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}
.app-grid > .main { min-width: 0; }
.app-grid > .rail { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 980px) {
  .app-grid { grid-template-columns: 1fr; }
}

/* Sticky header for account.html */
.sticky-head {
  position: sticky;
  top: 56px;
  z-index: 30;
  background: var(--bg);
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
@media (max-width: 720px) {
  .sticky-head { position: static; }
}

/* Inline edit pencil */
.editable {
  cursor: text;
  border: 1px dashed transparent;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  display: inline-block;
  min-width: 24px;
}
.editable:hover { border-color: var(--line-2); background: var(--panel); }
.editable.editing { background: var(--bg); border: 1px solid var(--accent); padding: 5px 7px; }
.editable.placeholder { color: var(--fg-4); font-style: italic; }
