:root {
  --ink: #17212b;
  --muted: #5b6673;
  --line: #d8dee6;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --accent: #176f73;
  --accent-2: #ad5d1e;
  --danger: #b42318;
  --warn: #96670f;
  --ok: #137333;
  --focus: #8cc7ca;
  --shadow: 0 14px 40px rgba(23, 33, 43, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f5;
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #18232e;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  padding: 0 4px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: linear-gradient(135deg, #f0b35b, #58adb2);
  color: #18232e;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  color: #b8c5d2;
  font-size: 12px;
  margin-top: 3px;
}

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

.nav button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 9px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  color: #dce5ee;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: #263645;
}

.nav .ico {
  width: 28px;
  text-align: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #b8c5d2;
  font-size: 12px;
  line-height: 1.45;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.page-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafb;
  color: #344150;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.content {
  padding: 24px 26px 32px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric {
  min-height: 116px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.04);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
}

.metric-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.section {
  margin-top: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.04);
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  min-width: min(360px, 100%);
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  white-space: nowrap;
}

.btn:hover {
  border-color: #aeb8c4;
  background: #f8fafb;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: #125f62;
}

.btn.warn {
  background: #fff8e8;
  border-color: #e4c77c;
  color: #65450b;
}

.btn.danger {
  color: var(--danger);
}

.mini-btn {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  display: inline-grid;
  place-items: center;
  position: relative;
}

.icon-btn:hover {
  background: #f8fafb;
}

.danger-icon {
  color: var(--danger);
}

.danger-icon:hover {
  border-color: #e2aaa4;
  background: #fff5f4;
}

.chat-icon,
.notification-btn {
  font-size: 16px;
}

.icon-btn.disabled,
.icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 0 5px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8fafb;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.pending {
  background: #fff3d8;
  color: var(--warn);
}

.status.pending_ap {
  background: #edf0ff;
  color: #354a9f;
}

.status.verified {
  background: #ddf3e2;
  color: var(--ok);
}

.status.issue {
  background: #fde4e1;
  color: var(--danger);
}

.status.draft {
  background: #e8eef4;
  color: #435160;
}

.status.cancelled {
  background: #f0e5e2;
  color: #7a2e22;
}

.status.credit_hold {
  background: #fff0c2;
  color: #8a4f00;
}

.status.kickback_pending {
  background: #f2e7ff;
  color: #5b2c83;
}

.status.partial_ship {
  background: #eaf5ff;
  color: #0b5f8f;
}

.status.sent_to_shipping {
  background: #e7e2fb;
  color: #4d3192;
}

.status.order_shipped {
  background: #dff3ff;
  color: #086788;
}

.status.completed {
  background: #d9f7ec;
  color: #086b4b;
}

.status-cell {
  display: grid;
  gap: 5px;
  align-items: start;
}

.status-control {
  max-width: 132px;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 12px;
}

.status-filter {
  min-width: 150px;
  max-width: 190px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #344150;
  font-size: 13px;
  font-weight: 700;
}

.check-field input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.check-field.full {
  grid-column: 1 / -1;
}

.check-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

label {
  color: #344150;
  font-size: 13px;
  font-weight: 700;
}

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

input:disabled,
select:disabled,
textarea:disabled {
  background: #eef2f5;
  color: var(--muted);
  cursor: not-allowed;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.line-items {
  display: grid;
  gap: 10px;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 92px 110px 42px;
  gap: 10px;
  align-items: end;
}

.totals {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.grand {
  color: var(--ink);
  font-weight: 800;
  font-size: 20px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.callout {
  border-left: 4px solid var(--accent-2);
  background: #fff8ef;
  padding: 12px;
  color: #4e3420;
  border-radius: 0 6px 6px 0;
  line-height: 1.45;
}

.verify-kickback {
  margin-bottom: 14px;
}

.verification-log {
  display: grid;
  gap: 10px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.log-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
}

.log-title {
  font-weight: 800;
}

.log-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed #c4ccd5;
  border-radius: 8px;
  background: #fbfcfd;
}

.chat-context {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.chat-context span {
  color: var(--muted);
  font-size: 13px;
}

.chat-thread {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding: 4px;
}

.chat-message {
  display: grid;
  gap: 5px;
  justify-items: start;
}

.chat-message.own {
  justify-items: end;
}

.chat-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.chat-meta span {
  color: var(--muted);
}

.chat-bubble {
  max-width: min(560px, 86%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.45;
}

.chat-message.own .chat-bubble {
  background: #eaf6f6;
  border-color: #b9dddd;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 14px;
}

.chat-compose textarea {
  min-height: 72px;
}

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

.notification-item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.notification-item:hover {
  border-color: var(--accent);
  background: #f8fcfc;
}

.notification-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f5;
  font-weight: 800;
}

.notification-item span:last-child {
  display: grid;
  gap: 4px;
}

.notification-item em,
.notification-item small {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.notification-item small {
  font-size: 12px;
}

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

.verify-card {
  min-height: 124px;
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 14px;
  text-align: left;
}

.verify-card:hover {
  border-color: var(--accent);
  background: #f8fcfc;
}

.verify-card.disabled-card {
  cursor: not-allowed;
  opacity: 0.58;
}

.verify-card.disabled-card:hover {
  border-color: var(--line);
  background: #fff;
}

.verify-card.cancel-card:hover {
  border-color: var(--danger);
  background: #fff5f4;
}

.verify-card strong {
  font-size: 15px;
}

.verify-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 22, 31, 0.48);
  z-index: 10;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 860px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.mobile-menu {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(238, 242, 245, 0.92), rgba(238, 242, 245, 0.92)),
    linear-gradient(135deg, #176f73, #ad5d1e);
}

.login-panel {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-brand {
  color: var(--ink);
  padding: 0 0 18px;
}

.login-brand .brand-sub {
  color: var(--muted);
}

.login-brand .brand-logo {
  border-color: var(--line);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-help {
  display: grid;
  gap: 5px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.link-button {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 700;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
  }

  .brand,
  .sidebar-foot {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(68px, 1fr));
    overflow-x: auto;
  }

  .nav button {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 3px;
    font-size: 12px;
  }

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

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

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .content {
    padding: 16px;
  }

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

  .line-item {
    grid-template-columns: 1fr 84px 98px 38px;
  }

  .chat-compose {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    max-width: 100%;
  }

  .verify-options {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
  }
}
