:root {
  color-scheme: dark;
  --bg: #101316;
  --surface: #171c20;
  --surface-2: #20262b;
  --line: #2c343b;
  --text: #eef3f0;
  --muted: #98a5a1;
  --green: #31d07c;
  --teal: #39c6c0;
  --amber: #e4b64b;
  --red: #ff6868;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #e8efeb;
  --line: #cfdad5;
  --text: #101816;
  --muted: #5f6f69;
  --green: #13995c;
  --teal: #168f8a;
  --amber: #ad7d14;
  --red: #c93f3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

:root[data-theme="light"] .sidebar,
:root[data-theme="light"] .user-sidebar {
  background: #eef4f1;
}

:root[data-theme="light"] .brand-logo {
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.04));
}

:root[data-theme="light"] .chat,
:root[data-theme="light"] .offer,
:root[data-theme="light"] .finance-row,
:root[data-theme="light"] .kyc-list div,
:root[data-theme="light"] .order-strip div,
:root[data-theme="light"] .catalog-card,
:root[data-theme="light"] .table-row,
:root[data-theme="light"] .sale-card,
:root[data-theme="light"] .mini-item,
:root[data-theme="light"] .check-list div {
  background: #f8fbf9;
}

:root[data-theme="light"] .message.system {
  background: #e6efec;
}

:root[data-theme="light"] .message.seller {
  background: #ddf2e9;
  color: #0b4c33;
}

:root[data-theme="light"] .message.buyer {
  background: #edf0f3;
}

button,
input {
  font: inherit;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #121619;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 54px;
}

.brand-logo {
  width: 188px;
  height: 48px;
  display: block;
}

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

.nav a {
  color: #dce5e2;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 7px;
  font-size: 14px;
}

.nav a.active,
.nav a:hover {
  background: var(--surface-2);
  color: var(--green);
}

.sidebar-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  background: var(--amber);
  border-radius: 50%;
  margin-right: 8px;
}

.workspace {
  padding: 24px;
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

p {
  color: var(--muted);
  margin-top: 5px;
  font-size: 14px;
}

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

.control-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  min-height: 38px;
}

.control-group button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 10px;
}

.control-group button + button {
  border-left: 1px solid var(--line);
}

.seg-control.active {
  background: var(--green);
  color: #06110d;
  font-weight: 800;
}

.icon-control {
  width: 38px;
  font-size: 17px;
}

.search {
  width: min(360px, 40vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 0 12px;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

button,
.primary {
  min-height: 38px;
  border: 1px solid #3a4844;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

.primary {
  background: var(--green);
  color: #07110d;
  border-color: var(--green);
  font-weight: 700;
}

.primary-link {
  background: var(--green);
  color: #07110d;
  border-color: var(--green);
  font-weight: 800;
}

.danger {
  border-color: #5f3437;
  color: #ffb3b3;
}

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

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

.metric {
  padding: 16px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 30px;
  margin: 8px 0 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 14px;
}

.dashboard-grid.lower {
  align-items: start;
}

.panel {
  padding: 16px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #24333a;
  color: #c7f3ed;
  font-size: 12px;
  white-space: nowrap;
}

.pill.success {
  background: #153c2b;
  color: #a8ffd2;
}

.pill.muted {
  background: #252b30;
  color: var(--muted);
}

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

.order-strip div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #12171a;
}

.order-strip span,
.order-strip strong {
  display: block;
}

.order-strip span {
  color: var(--muted);
  font-size: 12px;
}

.order-strip strong {
  margin-top: 4px;
  font-size: 14px;
}

.chat {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #111518;
  border-radius: 8px;
  min-height: 220px;
}

.message {
  width: fit-content;
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.4;
  font-size: 14px;
}

.message.system {
  background: #202a30;
  color: #d9e4e0;
  justify-self: center;
}

.message.seller {
  background: #1c3432;
  color: #cffff9;
  justify-self: end;
}

.message.buyer {
  background: #2c2f35;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

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

.offer,
.finance-row,
.kyc-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12171a;
}

.offer span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.catalog-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #12171a;
}

.catalog-card img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 6px;
  background: #0d1113;
}

.catalog-card strong,
.catalog-card span {
  display: block;
}

.catalog-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.catalog-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.stat-tags {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stat-tags em {
  font-style: normal;
  font-size: 11px;
  color: #c8d7d3;
  background: #20292e;
  border-radius: 999px;
  padding: 4px 7px;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.finance-row + .finance-row,
.kyc-list div + div {
  margin-top: 8px;
}

.invoice-box {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid #3f3b2a;
  color: #ffe0a3;
  background: #2b2617;
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
}

.invoice-action {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.invoice-action strong,
.invoice-action span {
  display: block;
}

.invoice-action span {
  color: #d6bc7f;
  margin-top: 2px;
}

.invoice-action a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #e4b64b;
  color: #160f04;
  text-decoration: none;
  font-weight: 800;
  padding: 0 11px;
  white-space: nowrap;
}

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

  .sidebar {
    position: static;
  }

  .dashboard-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }

  .dashboard-grid,
  .metric-grid,
  .order-strip {
    grid-template-columns: 1fr;
  }
}
