/* ============================================================
   Perccent Call Center Dashboard
   Design system: Coinbase-design-analysis (alpha)
   Fonts: Inter (CoinbaseDisplay/Sans substitute),
          JetBrains Mono (CoinbaseMono substitute)
   ============================================================ */

:root {
  /* colors */
  --primary: #0052ff;
  --primary-active: #003ecc;
  --primary-disabled: #a8b8cc;
  --ink: #0a0b0d;
  --body: #5b616e;
  --body-strong: #0a0b0d;
  --muted: #7c828a;
  --muted-soft: #a8acb3;
  --hairline: #dee1e6;
  --hairline-soft: #eef0f3;
  --canvas: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-card: #ffffff;
  --surface-strong: #eef0f3;
  --surface-dark: #0a0b0d;
  --surface-dark-elevated: #16181c;
  --on-primary: #ffffff;
  --on-dark: #ffffff;
  --on-dark-soft: #a8acb3;
  --up: #05b169;
  --down: #cf202f;
  --yellow: #f4b000;

  /* radius */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 100px;
  --r-full: 9999px;

  /* spacing */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-base: 16px;
  --s-md: 20px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;
  --s-section: 96px;

  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.04);
  --font-display: "Inter", -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans: "Inter", -apple-system, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* General guideline: restrict selection / copy across the app */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
/* Inputs/textarea remain usable for typing */
input,
textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
}

/* ---------- Typography helpers ---------- */
.display-xl {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -1.6px;
}
.display-sm {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.11;
  letter-spacing: -0.5px;
}
.title-lg {
  font-size: 32px;
  font-weight: 400;
  line-height: 1.13;
  letter-spacing: -0.4px;
}
.title-md {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.33;
}
.title-sm {
  font-size: 16px;
  font-weight: 600;
}
.body-sm {
  font-size: 14px;
}
.caption {
  font-size: 13px;
  color: var(--muted);
}
.mono {
  font-family: var(--font-mono);
  font-weight: 500;
}
.up {
  color: var(--up);
}
.down {
  color: var(--down);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--r-pill);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
  padding: 12px 20px;
  height: 44px;
  white-space: nowrap;
  transition: background 0.12s ease, opacity 0.12s ease;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover {
  background: var(--primary-active);
}
.btn-primary:disabled {
  background: var(--primary-disabled);
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface-strong);
  color: var(--ink);
}
.btn-secondary:hover {
  background: var(--hairline);
}
.btn-cta {
  height: 56px;
  padding: 16px 32px;
}
.btn-text {
  background: transparent;
  color: var(--primary);
  border: none;
  height: auto;
  padding: 0;
  font-weight: 600;
}
.btn-text:hover {
  text-decoration: underline;
}
.btn-danger {
  background: var(--down);
  color: #fff;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  height: 36px;
  padding: 8px 16px;
  font-size: 14px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: var(--surface-dark);
}
.login-hero {
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: var(--s-section);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-lg);
}
.login-hero .wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 600;
}
.login-hero h1 {
  margin: 0;
}
.login-hero p {
  color: var(--on-dark-soft);
  max-width: 460px;
  font-size: 18px;
}
.login-mock {
  margin-top: var(--s-md);
  background: var(--surface-dark-elevated);
  border-radius: var(--r-xl);
  padding: var(--s-xl);
  max-width: 460px;
}
.login-mock .mrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #23262b;
  color: var(--on-dark-soft);
  font-size: 14px;
}
.login-mock .mrow:last-child {
  border-bottom: none;
}
.login-panel {
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--s-section) var(--s-xxl);
}
.login-card {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}
.login-card h2 {
  margin: 0 0 4px;
}
.login-sub {
  color: var(--body);
  margin: 0 0 var(--s-lg);
}
.role-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-xs);
  background: var(--surface-strong);
  border-radius: var(--r-pill);
  padding: 4px;
  margin-bottom: var(--s-md);
}
.role-toggle button {
  border: none;
  background: transparent;
  border-radius: var(--r-pill);
  height: 40px;
  font-weight: 600;
  color: var(--body);
}
.role-toggle button.active {
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: var(--s-base);
}
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.input,
.textarea,
.select {
  width: 100%;
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font-sans);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border: 2px solid var(--primary);
  padding: 13px 15px;
}
.textarea {
  min-height: 96px;
  resize: vertical;
}
.search-pill {
  background: var(--surface-strong);
  border: none;
  border-radius: var(--r-pill);
  padding: 12px 20px;
  height: 44px;
  width: 100%;
  max-width: 360px;
  font-size: 16px;
  font-family: var(--font-sans);
}
.search-pill:focus {
  outline: 2px solid var(--primary);
}

/* ---------- App shell / nav ---------- */
.shell {
  min-height: 100vh;
  background: var(--canvas);
}
.topnav {
  height: 64px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: var(--s-lg);
  padding: 0 var(--s-xl);
  position: sticky;
  top: 0;
  z-index: 50;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}
.brand-dot {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--primary);
  display: inline-block;
}
.navlinks {
  display: flex;
  gap: 4px;
  margin-left: var(--s-base);
}
.navlinks a {
  font-size: 14px;
  font-weight: 500;
  color: var(--body);
  padding: 8px 14px;
  border-radius: var(--r-pill);
}
.navlinks a:hover {
  background: var(--surface-strong);
  text-decoration: none;
}
.navlinks a.active {
  color: var(--ink);
  background: var(--surface-strong);
}
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-base);
}
.who {
  text-align: right;
  line-height: 1.2;
}
.who .name {
  font-weight: 600;
  font-size: 14px;
}
.who .role {
  font-size: 12px;
  color: var(--muted);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--surface-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Page container ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--s-xl);
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-base);
  margin-bottom: var(--s-lg);
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
}
.page-head .sub {
  color: var(--body);
  margin: 4px 0 0;
}
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: var(--s-sm);
}
.breadcrumb a {
  color: var(--muted);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--s-xs);
  flex-wrap: wrap;
  margin-bottom: var(--s-lg);
}
.tab {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--body);
  border-radius: var(--r-pill);
  padding: 10px 20px;
  height: 44px;
  font-weight: 600;
  font-size: 14px;
}
.tab:hover {
  background: var(--surface-soft);
}
.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.tab .count {
  margin-left: 6px;
  font-family: var(--font-mono);
  opacity: 0.7;
}

/* subtabs (orders) */
.subtabs {
  display: flex;
  gap: var(--s-xs);
  flex-wrap: wrap;
  margin-bottom: var(--s-base);
}
.subtab {
  border: none;
  background: var(--surface-strong);
  color: var(--body);
  border-radius: var(--r-pill);
  padding: 6px 16px;
  height: 36px;
  font-weight: 600;
  font-size: 13px;
}
.subtab.active {
  background: var(--primary);
  color: #fff;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--s-xl);
  margin-bottom: var(--s-lg);
}
.card-soft {
  background: var(--surface-soft);
  border: none;
}
.card h2,
.card h3 {
  margin-top: 0;
}
.section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--s-base);
}

/* ---------- Tables ---------- */
.table-wrap {
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 16px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--hairline);
}
tbody td {
  padding: 16px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr.clickable {
  cursor: pointer;
}
tbody tr.clickable:hover {
  background: var(--surface-soft);
}
.cell-strong {
  font-weight: 600;
  color: var(--ink);
}
.expand-row td {
  background: var(--surface-soft);
  padding: 0;
}
.expand-inner {
  padding: 16px;
  display: flex;
  gap: var(--s-xl);
  flex-wrap: wrap;
  color: var(--body);
  font-size: 13px;
}

/* ---------- Badges / tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-strong);
  color: var(--ink);
  white-space: nowrap;
}
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  display: inline-block;
}
.badge-grey {
  background: var(--surface-strong);
  color: var(--muted);
}
.badge-yellow {
  background: rgba(244, 176, 0, 0.14);
  color: #9a6f00;
}
.badge-green {
  background: rgba(5, 177, 105, 0.12);
  color: var(--up);
}
.badge-blue {
  background: rgba(0, 82, 255, 0.1);
  color: var(--primary);
}
.badge-red {
  background: rgba(207, 32, 47, 0.1);
  color: var(--down);
}

/* ---------- Journey status bar ---------- */
.journey {
  display: flex;
  gap: var(--s-sm);
  flex-wrap: wrap;
}
.stage {
  flex: 1 1 180px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  text-align: left;
  background: var(--canvas);
  position: relative;
  transition: border 0.12s ease, transform 0.08s ease;
}
.stage:hover {
  transform: translateY(-1px);
}
.stage.sel {
  border: 2px solid var(--primary);
}
.stage .stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.stage .stage-idx {
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.stage .stage-name {
  font-weight: 600;
  font-size: 15px;
}
.stage .stage-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.stage-grey .stage-idx {
  background: var(--surface-strong);
  color: var(--muted);
}
.stage-yellow .stage-idx {
  background: rgba(244, 176, 0, 0.16);
  color: #9a6f00;
}
.stage-green .stage-idx {
  background: rgba(5, 177, 105, 0.14);
  color: var(--up);
}
.stage .pill-state {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stage-grey .pill-state {
  color: var(--muted);
}
.stage-yellow .pill-state {
  color: #9a6f00;
}
.stage-green .pill-state {
  color: var(--up);
}
.connector {
  align-self: center;
  color: var(--hairline);
  font-size: 18px;
}

/* sub-status list */
.substatus {
  margin-top: var(--s-base);
}
.substatus li {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.substatus ul {
  margin: 0;
  padding: 0;
}
.substatus .s-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.tick {
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.tick-done {
  background: var(--up);
  color: #fff;
}
.tick-progress {
  background: rgba(244, 176, 0, 0.16);
  color: #9a6f00;
}
.tick-todo {
  background: var(--surface-strong);
  color: var(--muted-soft);
}

/* ---------- detail grid ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-base) var(--s-xl);
}
.detail-item .dk {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.detail-item .dv {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- CRM ---------- */
.crm-entry {
  border-left: 2px solid var(--hairline);
  padding: 4px 0 16px 16px;
  position: relative;
}
.crm-entry::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--primary);
}
.crm-entry .crm-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.crm-entry .crm-text {
  font-size: 14px;
  color: var(--ink);
}
.crm-entry .crm-agent {
  font-weight: 600;
  color: var(--ink);
}

/* ---------- two-col layout ---------- */
.cols-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--s-lg);
  align-items: start;
}

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--s-base);
}
.modal {
  background: var(--canvas);
  border-radius: var(--r-xl);
  padding: var(--s-xl);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-soft);
}
.modal h3 {
  margin-top: 0;
}
.modal .modal-actions {
  display: flex;
  gap: var(--s-xs);
  justify-content: flex-end;
  margin-top: var(--s-base);
}

/* ---------- toast ---------- */
#toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  max-width: 360px;
  box-shadow: var(--shadow-soft);
  animation: toastin 0.18s ease;
}
.toast.warn {
  border-left: 3px solid var(--yellow);
}
.toast.ok {
  border-left: 3px solid var(--up);
}
.toast .toast-sub {
  color: var(--on-dark-soft);
  font-size: 12px;
  margin-top: 2px;
}
@keyframes toastin {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- misc ---------- */
.row-actions {
  display: flex;
  gap: var(--s-xs);
  align-items: center;
}
.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-base);
  flex-wrap: wrap;
}
.muted {
  color: var(--muted);
}
.empty {
  padding: var(--s-xxl);
  text-align: center;
  color: var(--muted);
}
.hint {
  background: var(--surface-soft);
  border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--body);
  margin-bottom: var(--s-base);
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-base);
  margin-bottom: var(--s-lg);
}
.stat {
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.stat .k {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat .v {
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.5px;
  margin-top: 4px;
}
.legend-table td {
  font-size: 13px;
}
.photo-up {
  width: 72px;
  height: 72px;
  border-radius: var(--r-full);
  background: var(--surface-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .cols-2 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .login-wrap {
    grid-template-columns: 1fr;
  }
  .login-hero {
    display: none;
  }
  .login-panel {
    padding: var(--s-xl);
  }
  .navlinks {
    display: none;
  }
  .page {
    padding: var(--s-base);
  }
  .topnav {
    padding: 0 var(--s-base);
  }
  .who .name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  table {
    font-size: 13px;
  }
  thead th,
  tbody td {
    padding: 12px 10px;
  }
}
