:root {
  color-scheme: light;
  --bg: #f4f1ec;
  --ink: #1e2528;
  --muted: #697177;
  --line: #d8d2c8;
  --panel: #fffdf8;
  --panel-strong: #f8f2e6;
  --accent: #0b6f66;
  --accent-dark: #074f49;
  --accent-soft: #d8eee8;
  --orange: #d97836;
  --blue: #315c9d;
  --red: #b7473d;
  --green: #19825a;
  --shadow: 0 18px 45px rgba(44, 39, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(120deg, rgba(11, 111, 102, 0.16), transparent 42%),
    linear-gradient(300deg, rgba(217, 120, 54, 0.14), transparent 48%),
    var(--bg);
}

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.auth-brand {
  color: var(--ink);
  margin-bottom: 6px;
}

.auth-brand .brand-mark {
  background: #172327;
  color: #ffffff;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  background: #172327;
  color: #f7f4ed;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f7f4ed;
  color: #172327;
  font-weight: 900;
}

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

.brand span {
  margin-top: 2px;
  color: #bec8c8;
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d9e2e1;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #223438;
  border-color: #355057;
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  min-height: 74px;
  padding: 14px;
  border: 1px solid #355057;
  border-radius: 8px;
  background: #203236;
}

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

.sidebar-footer span {
  color: #bec8c8;
  font-size: 13px;
}

.sidebar-footer strong {
  margin-top: 8px;
  font-size: 26px;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.select-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(11, 111, 102, 0.22);
  outline-offset: 2px;
}

.toolbar select {
  width: min(260px, 58vw);
}

.icon-button,
.ghost-button,
.primary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.user-badge {
  min-height: 42px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-button {
  padding: 0 14px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.primary-button {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric {
  min-height: 132px;
  padding: 18px;
}

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

.metric span {
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin: 16px 0 6px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.metric small {
  font-size: 13px;
}

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

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

.panel-head {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.form-panel {
  align-self: start;
  display: grid;
  gap: 14px;
}

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

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

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

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

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

td {
  font-size: 14px;
}

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

.list-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.list-row + .list-row {
  margin-top: 10px;
}

.list-title {
  font-weight: 900;
}

.list-subtitle,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.url-box {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: #485056;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.mini-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.danger-button:hover:not(:disabled) {
  background: #fff1ef;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.paid,
.status.active {
  background: #def3e8;
  color: var(--green);
}

.status.pending {
  background: #fff0d6;
  color: #9a5b12;
}

.status.refund {
  background: #f8dfdc;
  color: var(--red);
}

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

.product-card {
  min-height: 210px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.product-art {
  min-height: 88px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 34px;
  font-weight: 900;
}

.product-art.crm {
  background: linear-gradient(135deg, #0b6f66, #315c9d);
}

.product-art.chatgpt {
  background: linear-gradient(135deg, #0b6f66, #222f3e);
}

.product-art.course {
  background: linear-gradient(135deg, #d97836, #8f4f89);
}

.product-art.audit {
  background: linear-gradient(135deg, #29313f, #69885a);
}

.product-meta {
  display: grid;
  gap: 6px;
}

.product-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-stats div {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-strong);
}

.product-stats span,
.product-stats strong {
  display: block;
}

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

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

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

.user-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.user-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-card .actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.partner-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
}

.ref-banner {
  margin-bottom: 16px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #e8f4f0;
}

.ref-banner.hidden {
  display: none;
}

.ref-banner span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

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

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

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

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

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

@media (max-width: 760px) {
  .app {
    display: block;
  }

  .sidebar {
    min-height: auto;
    padding: 14px;
  }

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

  .nav-item {
    text-align: center;
    padding: 0 8px;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none;
  }

  .workspace {
    padding: 18px 14px;
  }

  .topbar,
  .ref-banner,
  .panel-head,
  .list-row,
  .partner-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .ref-banner,
  .panel-head,
  .list-row {
    display: flex;
  }

  .toolbar,
  .actions {
    justify-content: flex-start;
  }

  .toolbar select {
    width: 100%;
  }

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

  .partner-card {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .partner-card .status {
    grid-column: 1 / -1;
    width: max-content;
  }

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