/* CRM Sandbox: laid out like Agentcis (dark left menu, white top bar, light grey canvas, blue accents). */
:root {
  --navy: #1b2437;
  --navy-2: #232f47;
  --navy-text: #aab4c8;
  --blue: #1e7be0;
  --blue-dark: #1767bd;
  --blue-soft: #e8f1fc;
  --canvas: #f2f4f8;
  --card: #ffffff;
  --line: #e3e7ee;
  --ink: #26303f;
  --ink-2: #4b5567;
  --muted: #7c8697;
  --green: #1f9d55;
  --green-soft: #e3f6ea;
  --orange: #c76a00;
  --orange-soft: #fff1df;
  --red: #d33a3a;
  --red-soft: #fde8e8;
  --purple: #7b4fd6;
  --purple-soft: #f0eafc;
  --grey-soft: #eef0f4;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Roboto, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--canvas);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 500; margin: 0; }
h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* Frame */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--navy); color: var(--navy-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 22px; color: #fff; font-weight: 500; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.brand-mark.big { width: 48px; height: 48px; font-size: 18px; border-radius: 12px; }
.sidebar nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: var(--navy-text);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--navy-2); color: #fff; border-left-color: var(--blue); }
.nav-item.active svg { color: #5aa7ff; }
.sidebar-foot { margin-top: auto; padding: 16px 18px; font-size: 11.5px; line-height: 1.5; color: #6f7a90; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 5;
}
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; background: transparent; height: 36px; flex: 1; font: inherit; color: var(--ink); outline: none; }
.sandbox-pill { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--orange); background: var(--orange-soft); padding: 4px 10px; border-radius: 999px; }
.link-button { background: none; border: 0; color: var(--ink-2); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--blue); }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* Building blocks */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.crumbs { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 1px 2px rgba(20, 30, 50, .04); }
.card.flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 500; border: 1px solid transparent; cursor: pointer; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-light { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-light:hover { border-color: #c9d1de; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-grey { background: var(--grey-soft); color: var(--ink-2); }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 500; flex-shrink: 0; vertical-align: middle; }
.person { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; }
a.person:hover span { color: var(--blue); }

/* Tables and tabs */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 500; padding: 11px 14px; background: #fafbfd; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fafcff; }
.table tbody tr:last-child td { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tab { padding: 13px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--blue); text-decoration: none; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--grey-soft); color: var(--ink-2); font-size: 11.5px; text-align: center; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.pager .btn { padding: 6px 12px; margin-left: 6px; }

/* Dashboard */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; border-left: 4px solid; display: flex; flex-direction: column; color: var(--ink-2); }
.tile:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(20, 30, 50, .08); }
.tile strong { font-size: 26px; font-weight: 500; color: var(--ink); }
.tile-blue { border-left-color: var(--blue); }
.tile-orange { border-left-color: #f2994a; }
.tile-purple { border-left-color: var(--purple); }
.tile-grey { border-left-color: #a6afbd; }
.stage-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.stage-bars li { display: grid; grid-template-columns: 170px 1fr 28px; align-items: center; gap: 10px; }
.bar { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.plain-list { list-style: none; margin: 0 0 10px; padding: 0; }
.plain-list li { padding: 9px 0; border-bottom: 1px solid var(--line); line-height: 1.45; }
.plain-list li:last-child { border-bottom: 0; }
.stage-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stage-chip { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--ink-2); font-size: 13px; }
.stage-chip b { background: var(--grey-soft); border-radius: 999px; padding: 0 7px; font-weight: 500; font-size: 12px; }
.stage-chip.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.stage-chip:hover { text-decoration: none; border-color: var(--blue); }

/* Client profile */
.profile { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.profile-top { text-align: center; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.profile-top h1 { margin-top: 10px; }
.profile-top p { margin: 4px 0 8px; }
.details { display: grid; grid-template-columns: 1fr; margin: 0; }
.details dt { color: var(--muted); font-size: 12px; margin-top: 10px; }
.details dd { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; word-break: break-word; }
.panel { padding: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 0 0 18px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #a6afbd; margin-top: 4px; position: relative; z-index: 1; }
.dot-green { background: var(--green); }
.dot-blue { background: var(--blue); }
.timeline-head { margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note-body { background: #fafbfd; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; line-height: 1.5; color: var(--ink-2); }
.note-body p { margin: 0 0 6px; }
.note-body p:last-child { margin-bottom: 0; }
.note-form { display: grid; gap: 8px; margin-bottom: 18px; }
.note-form input, .note-form textarea, .form input, .form select {
  font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 9px 11px; background: #fff; color: var(--ink); width: 100%;
}
.note-form button { justify-self: end; }

/* Forms and login */
.form { max-width: 820px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form label, .login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, #2c3c5e 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 32px; width: min(380px, calc(100vw - 32px)); display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login-card input { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.login-card p { margin: 0; }
.error { color: var(--red); }

@media (max-width: 1000px) {
  .profile, .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .table { display: block; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}
