:root {
  --bg: #eef3f5;
  --rail: #fbfcfc;
  --panel: #ffffff;
  --panel-soft: #f5f8f8;
  --ink: #101518;
  --ink-soft: #263236;
  --muted: #66757b;
  --line: #dbe5e7;
  --line-strong: #b9c8cc;
  --red: #df3f37;
  --red-dark: #b9322b;
  --red-soft: #fff0ee;
  --green: #177447;
  --green-soft: #e1f3ea;
  --amber: #8b6415;
  --amber-soft: #fff1cc;
  --blue: #1f6e96;
  --blue-soft: #e1f1f7;
  --shadow: 0 18px 45px rgba(16, 21, 24, .10);
  --shadow-soft: 0 8px 24px rgba(16, 21, 24, .07);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 850;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease, box-shadow .16s ease;
}

button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 6px 16px rgba(16, 21, 24, .07);
}

button:active { transform: translateY(1px); }

button.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 12px 24px rgba(223, 63, 55, .22);
}

button.primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

button.ghost { background: transparent; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.boot, .locked {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

.boot > div, .locked > div {
  width: min(720px, 100%);
}

.boot h1, .locked h1 {
  margin: 14px 0 6px;
  font-size: clamp(36px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: 0;
}

.boot p, .locked p {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 950;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
}

.app-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  background: var(--rail);
  border-right: 1px solid var(--line);
  color: var(--ink);
}

.rail-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand-title {
  font-weight: 950;
  font-size: 21px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 7px;
  align-content: start;
  overflow: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav button {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  min-height: 42px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
}

.nav button:hover {
  background: #eef3f5;
  border-color: #eef3f5;
  color: var(--ink);
  box-shadow: none;
}

.nav button.active {
  padding-left: 20px;
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.nav button.active::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red);
  transform: translateY(-50%);
}

.rail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 6px 18px rgba(16, 21, 24, .05);
}

.rail-card b {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.rail-card span, .rail-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.rail-label {
  margin-bottom: 6px;
  color: var(--red-dark);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
}

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px 28px 12px;
}

.workspace-top h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.02;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#screen {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 10px 28px 34px;
}

.today-board {
  display: grid;
  gap: 16px;
}

.today-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  align-items: center;
  gap: 22px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 24px;
  box-shadow: var(--shadow);
}

.today-hero .eyebrow {
  color: #ffb4ad;
}

.today-hero h2 {
  margin: 0 0 8px;
  color: #fff;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1.02;
}

.today-hero p {
  max-width: 720px;
  margin: 0;
  color: #c6d0d2;
  font-size: 16px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.today-hero .metric {
  background: #fff;
  border-color: transparent;
  color: var(--ink);
  box-shadow: none;
}

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.page {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.side, .main-panel, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.side {
  overflow: hidden;
  align-self: start;
}

.side-head {
  padding: 15px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.side-head h3 { margin-bottom: 4px; }

.side-list {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.main-panel {
  min-width: 0;
  padding: 16px;
}

.panel { padding: 16px; }

.panel + .panel,
.section + .section { margin-top: 16px; }

.section { padding-top: 2px; }

.panel-head, .record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.crm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

h2, h3, p { margin-top: 0; }

h2 {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 8px 8px 0;
  background: var(--blue);
}

.metric b {
  display: block;
  min-width: 0;
  font-size: 22px;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric.green {
  background: var(--green-soft);
  border-color: #b7d9c4;
}

.metric.green::before { background: var(--green); }

.metric.amber {
  background: var(--amber-soft);
  border-color: #dfc982;
}

.metric.amber::before { background: var(--amber); }

.metric.red {
  background: var(--red-soft);
  border-color: #f0b5af;
}

.metric.red::before { background: var(--red); }

.lead-alert {
  border: 1px solid #f0b5af;
  border-left: 6px solid var(--red);
  border-radius: 8px;
  background: var(--red-soft);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 18px 38px rgba(223, 63, 55, .13);
}

.lead-alert h2 {
  margin-bottom: 4px;
  font-size: clamp(26px, 3vw, 36px);
}

.lead-alert .record {
  background: #fffaf8;
  border-color: #f0c3bd;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .12s ease;
}

.record:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgba(16, 21, 24, .06);
}

button.record {
  display: block;
  width: 100%;
  text-align: left;
  min-height: auto;
  box-shadow: none;
}

.record.selected {
  border-color: #99c3a9;
  background: #f5fff8;
}

.record-title {
  color: var(--ink);
  font-weight: 920;
  font-size: 16px;
  line-height: 1.24;
}

.record-main { min-width: 0; }

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.pill.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.red {
  background: var(--red-soft);
  color: var(--red-dark);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-field.wide { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  display: none;
  max-width: min(520px, calc(100vw - 28px));
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 10px 13px;
  box-shadow: var(--shadow);
}

.toast.show { display: block; }

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 244px minmax(0, 1fr);
  }

  .today-hero {
    grid-template-columns: 1fr;
  }

  .today-grid, .page {
    grid-template-columns: 1fr;
  }

  .side-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body { font-size: 14px; }

  .app-shell {
    display: block;
  }

  .app-rail {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    display: block;
    padding: 10px 12px;
    box-shadow: 0 8px 22px rgba(16, 21, 24, .08);
  }

  .rail-brand {
    padding-bottom: 10px;
  }

  .rail-card { display: none; }

  .nav {
    display: flex;
    gap: 7px;
    margin-top: 10px;
    overflow-x: auto;
  }

  .nav button {
    width: auto;
    min-height: 34px;
    white-space: nowrap;
    padding: 6px 10px;
  }

  .nav button.active {
    padding-left: 18px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-title { font-size: 18px; }
  .brand-sub { display: none; }

  .workspace-top {
    display: grid;
    padding: 16px 12px 8px;
  }

  .workspace-top h1 {
    font-size: 34px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
  }

  .top-actions button {
    min-height: 34px;
    padding: 6px 8px;
  }

  #screen {
    padding: 8px 10px 20px;
  }

  .today-board {
    gap: 10px;
  }

  .today-hero {
    padding: 16px;
  }

  .today-hero h2 {
    font-size: 30px;
  }

  .today-hero p {
    font-size: 14px;
  }

  .hero-metrics, .metrics {
    grid-template-columns: 1fr;
  }

  .main-panel, .panel {
    padding: 12px;
  }

  .side-head {
    padding: 12px;
  }

  .side-list {
    padding: 10px;
    grid-template-columns: 1fr 1fr;
  }

  .metric {
    padding: 10px;
  }

  .metric b { font-size: 18px; }
  h2 { font-size: 22px; }
  .lead-alert h2 { font-size: 25px; }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .panel-head, .record-head {
    display: grid;
  }

  .record-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .record-actions button { width: 100%; }
}

@media (max-width: 460px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .side-list {
    grid-template-columns: 1fr;
  }

  .record-actions {
    grid-template-columns: 1fr;
  }
}
