:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #f9fafb;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #22604a;
  --primary-strong: #174434;
  --accent: #1d5d9f;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 18px 45px rgba(24, 33, 47, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1,
.topbar h1 {
  margin: 0;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #0f1722;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  display: block;
  border-radius: 8px;
  background: #f8fafc;
  object-fit: contain;
  padding: 4px;
}

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

.brand span {
  color: #b7c1d0;
  font-size: 0.86rem;
}

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

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d7dde8;
  text-align: left;
}

.nav-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0 7px;
  border-radius: 999px;
  background: #344054;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

.nav-badge.alert {
  background: #d92d20;
}

.nav button.active,
.nav button:hover {
  background: #1d2938;
  border-color: #344054;
  color: #ffffff;
}

.sidebar-alert {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #475467;
  border-radius: 8px;
  background: #182230;
  color: #f8fafc;
  text-align: left;
}

.order-sidebar-alert.new {
  border-color: #f79009;
  background: #2a1b08;
}

.handoff-sidebar-alert.new {
  border-color: #f04438;
  background: #2b1718;
}

.sidebar-alert strong,
.sidebar-alert span {
  display: block;
}

.sidebar-alert strong {
  font-size: 0.88rem;
  line-height: 1.25;
}

.sidebar-alert span {
  color: #d0d5dd;
  font-size: 0.78rem;
  line-height: 1.35;
}

.content {
  min-width: 0;
  padding: 24px;
  overflow-x: hidden;
}

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

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions,
.row-actions,
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.dashboard-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.dashboard-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.dashboard-footer a,
.legal-back {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.dashboard-footer a:hover,
.legal-back:hover {
  text-decoration: underline;
}

.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.secondary:hover,
.button.subtle:hover {
  border-color: #b8c2d2;
  background: var(--surface-strong);
}

.button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.button.warning {
  border-color: var(--warning);
  color: var(--warning);
}

.button.subtle {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.88rem;
}

.button.subtle-danger {
  background: #fff7f6;
}

.button.full {
  width: 100%;
}

.panel,
.metric,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  min-width: 0;
  padding: 18px;
  box-shadow: var(--shadow);
}

.legal-page {
  min-height: 100vh;
  padding: 32px 20px 48px;
}

.legal-document {
  width: min(860px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.legal-document header {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.legal-document h1 {
  margin: 12px 0 10px;
  line-height: 1.05;
}

.legal-document h2 {
  margin: 24px 0 10px;
  font-size: 1.05rem;
}

.legal-document p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.65;
}

.legal-document a {
  color: var(--primary);
  font-weight: 800;
}

.legal-updated {
  color: var(--muted);
  font-size: 0.88rem;
}

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

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

.metric span,
.metric small,
.muted {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 2rem;
}

.split,
.catalog-grid,
.credit-grid,
.notifications-grid,
.handoff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  margin-top: 16px;
}

.catalog-grid {
  align-items: start;
}

.credit-grid {
  align-items: start;
}

.handoff-grid {
  grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.25fr);
  align-items: start;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-width: 0;
}

.section-title h2 {
  margin: 0;
  font-size: 1.05rem;
}

.form {
  display: grid;
  gap: 12px;
}

.field,
.field span {
  display: grid;
  gap: 6px;
}

.field span,
.checkline span {
  color: #344054;
  font-size: 0.84rem;
  font-weight: 800;
}

.sidebar .field span {
  color: #d7dde8;
}

.field.compact {
  margin-bottom: 8px;
}

input,
select,
textarea {
  max-width: 100%;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
}

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

.field-row,
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.filters {
  grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(120px, 1fr)) auto;
  align-items: end;
}

.compact-filters {
  width: min(720px, 100%);
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.5fr) auto;
  margin: 0;
}

.field-check {
  align-content: end;
  min-height: 68px;
}

.credit-customer-list {
  margin-top: 14px;
}

.status,
.loading,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-strong);
}

.status {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  position: sticky;
  top: 12px;
  z-index: 20;
}

.status-close {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 28px;
  font: inherit;
  font-size: 20px;
  height: 28px;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.status.success {
  border-color: #a6d8be;
  background: #effaf4;
  color: #14532d;
}

.status.error {
  border-color: #f3b2ac;
  background: #fff1f0;
  color: var(--danger);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.product-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.product-card img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  background: #e7ebf1;
}

.product-head,
.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.product-head strong {
  min-width: 0;
}

.product-meta {
  margin: 10px 0;
  color: #344054;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef4ff;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.ok {
  background: #ecfdf3;
  color: #027a48;
}

.badge.muted-badge {
  background: #eef0f4;
  color: #526071;
}

.badge.danger-badge {
  background: #fff1f0;
  color: var(--danger);
}

.compact-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-list article {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.compact-list strong,
.compact-list span,
.compact-list small {
  display: block;
}

.compact-list span,
.compact-list small {
  margin-top: 4px;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  color: #344054;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td strong,
td span {
  display: block;
}

.inline-select {
  min-width: 140px;
}

.inline-filter {
  min-width: 150px;
  margin: 0;
}

.quote-opportunity-list {
  display: grid;
  gap: 16px;
}

.quote-opportunity-card {
  display: grid;
  gap: 16px;
  border-left: 5px solid var(--line);
}

.quote-opportunity-card.needs-assistance {
  border-left-color: var(--danger);
  box-shadow: 0 18px 45px rgba(180, 35, 24, 0.1);
}

.quote-opportunity-card.resolved {
  border-left-color: #039855;
}

.quote-opportunity-card.completed {
  border-left-color: #98a2b3;
}

.quote-opportunity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.quote-opportunity-head h2,
.quote-opportunity-head p,
.quote-customer-message p {
  margin: 0;
}

.quote-opportunity-head .muted {
  margin-top: 5px;
}

.quote-opportunity-details {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 1fr);
  gap: 18px;
}

.quote-item-list {
  display: grid;
  gap: 7px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.quote-item-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
}

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

.quote-facts div {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quote-facts dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.quote-facts dd {
  margin: 4px 0 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.quote-customer-message {
  padding: 11px 12px;
  border-left: 3px solid var(--accent);
  background: #f4f8fc;
}

.quote-customer-message p {
  margin-top: 5px;
  white-space: pre-wrap;
}

.quote-follow-up-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(210px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.quote-opportunity-actions {
  padding-top: 2px;
}

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

.handoff-item {
  position: relative;
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}

.handoff-item:hover,
.handoff-item.active {
  border-color: var(--primary);
  background: #f3faf7;
}

.handoff-item span,
.handoff-item small {
  display: block;
}

.handoff-item > span:not(.handoff-item-head),
.handoff-item small {
  color: var(--muted);
}

.handoff-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.handoff-item em {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #fff1f0;
  color: var(--danger);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
}

.handoff-conversation {
  display: grid;
  gap: 14px;
}

.handoff-conversation .section-title p {
  margin: 6px 0 0;
}

.handoff-reason {
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #f4f8fc;
  color: #344054;
  font-weight: 700;
}

.conversation-log {
  min-height: 340px;
  max-height: 58vh;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.message {
  display: flex;
}

.message.agent {
  justify-content: flex-end;
}

.message > div {
  width: min(78%, 680px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.message.agent > div {
  border-color: #a6d8be;
  background: #effaf4;
}

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

.message p {
  margin: 6px 0;
  white-space: pre-wrap;
}

.message small {
  color: var(--muted);
}

.handoff-reply-form {
  padding-top: 2px;
}

.pagination {
  justify-content: flex-end;
  margin-top: 14px;
}

.checkline,
.user-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.checkline input,
.user-option input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.user-picker {
  max-height: 360px;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-option {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.user-option strong,
.user-option small {
  display: block;
}

.user-option small {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .metric-grid,
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .catalog-grid,
  .credit-grid,
  .notifications-grid,
  .handoff-grid,
  .quote-opportunity-details,
  .quote-follow-up-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .content {
    padding: 16px;
  }

  .brand {
    align-items: flex-start;
  }

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

  .nav button {
    min-height: 44px;
  }

  .topbar,
  .compact-list article,
  .section-title,
  .quote-opportunity-head,
  .dashboard-footer {
    flex-direction: column;
  }

  .topbar-actions,
  .row-actions {
    width: 100%;
  }

  .topbar-actions .button,
  .row-actions .button {
    flex: 1 1 140px;
  }

  .metric-grid,
  .field-row,
  .filters,
  .compact-filters {
    grid-template-columns: 1fr;
  }

  .message > div {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .login-screen,
  .content,
  .legal-page {
    padding: 12px;
  }

  .sidebar {
    padding: 12px;
    gap: 14px;
  }

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

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

  .panel,
  .metric,
  .login-panel,
  .legal-document {
    padding: 14px;
  }

  .metric strong {
    font-size: 1.45rem;
    overflow-wrap: anywhere;
  }

  .button {
    width: 100%;
  }

  .product-card {
    grid-template-columns: 1fr;
  }

  .product-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1.6;
  }

  table {
    min-width: 760px;
  }
}
