:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #687580;
  --line: #d8dee4;
  --surface: #ffffff;
  --soft: #f4f7f8;
  --nav: #0f171b;
  --nav-2: #172228;
  --green: #18a058;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #c2413a;
  --cyan: #0e7490;
  --shadow: 0 18px 50px rgba(15, 23, 27, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(15, 23, 27, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 23, 27, 0.035) 1px, transparent 1px),
    var(--soft);
  background-size: 44px 44px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #eef5f6;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #e7f9ef;
  color: #0b5f39;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.side-panel small,
.side-panel span {
  color: #9fb1b7;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #c9d5d8;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: #e8f3f4;
  font-size: 12px;
  font-weight: 800;
}

.side-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 8px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.topbar-actions,
.inline-form,
.segmented {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

textarea {
  resize: vertical;
}

.topbar select {
  min-width: 220px;
}

.primary-button,
.ghost-button,
.segmented button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 750;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.ghost-button,
.segmented button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.segmented {
  padding: 3px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 34px;
  border: 0;
  background: transparent;
}

.segmented button.active {
  background: #fff;
  box-shadow: 0 1px 6px rgba(23, 32, 38, 0.09);
}

.token-panel,
.panel,
.metric-card {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.token-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
  min-height: 126px;
  display: grid;
  align-content: space-between;
}

.metric-card small {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
}

.metric-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 850;
}

.metric-card span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.metric-accent {
  height: 4px;
  width: 58px;
  border-radius: 999px;
  background: var(--green);
}

.metric-card:nth-child(2) .metric-accent {
  background: var(--blue);
}

.metric-card:nth-child(3) .metric-accent {
  background: var(--amber);
}

.metric-card:nth-child(4) .metric-accent {
  background: var(--red);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
}

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

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf4ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.ACTIVE,
.status.ready,
.status.delivered,
.status.approved {
  background: #e9f8ef;
  color: #0b7a42;
}

.status.processing,
.status.pending {
  background: #fff7e6;
  color: #9a5d00;
}

.status.rejected,
.status.archived,
.status.SUSPENDED {
  background: #fff0ef;
  color: #a1302a;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.lead-list,
.lead-board,
.compact-list,
.usage-panel {
  display: grid;
  gap: 12px;
}

.lead-list {
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.lead-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.lead-card-header,
.lead-card-footer,
.contact-row,
.usage-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.lead-card strong {
  display: block;
}

.lead-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.lead-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lead-board .lead-card {
  min-height: 230px;
}

.draft-box,
.data-box {
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  color: #2d3a42;
  white-space: pre-wrap;
  line-height: 1.45;
}

.contact-row,
.usage-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e6eaed;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--green), var(--blue));
}

dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

dialog::backdrop {
  background: rgba(15, 23, 27, 0.45);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

#dialogBody {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-panel {
    display: none;
  }

  .metric-grid,
  .two-column,
  .lead-board {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .panel-heading,
  .lead-card-header,
  .lead-card-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .inline-form,
  .segmented,
  .nav {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .topbar select {
    min-width: 0;
  }

  .metric-grid,
  .two-column,
  .lead-board,
  .form-grid,
  .dialog-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}
