:root {
  --bg: #ffffff;
  --surface: #f7f9fa;
  --surface-strong: #eef7f6;
  --text: #172026;
  --muted: #65717c;
  --border: #dbe2e7;
  --accent: #0f8f87;
  --accent-dark: #08716b;
  --green: #16794c;
  --amber: #b7791f;
  --red: #c2413d;
  --shadow: 0 12px 36px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

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

.sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 17px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: white;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 11px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
}

.nav-item.active {
  background: var(--surface-strong);
  color: var(--accent-dark);
}

.nav-item span {
  float: right;
  min-width: 22px;
  text-align: center;
  background: #f6d58d;
  color: #6b4700;
  border-radius: 99px;
  padding: 1px 6px;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.sidebar-footer strong {
  color: var(--text);
}

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-wrap input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 14px 0 38px;
  outline: none;
}

.search-wrap input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 135, 0.12);
}

.status-strip {
  display: flex;
  gap: 22px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 14px;
}

.status-strip strong,
#syncStatus,
#clientCount {
  color: var(--text);
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  background: #37b26c;
  border-radius: 50%;
  margin-right: 7px;
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  min-height: calc(100vh - 72px);
}

.main-panel {
  min-width: 0;
  border-right: 1px solid var(--border);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.1;
}

h2 {
  font-size: 17px;
}

.toolbar p,
.api-docs p,
.review-strip span {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

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

select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  outline: none;
}

.button {
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 13px;
  font-weight: 700;
  cursor: pointer;
  background: white;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

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

.button.ghost:hover,
.link-button:hover,
.icon-button:hover {
  background: var(--surface);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.table-shell {
  overflow: auto;
  border-top: 1px solid var(--border);
}

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

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

th {
  color: #4d5a66;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfd;
}

tr {
  cursor: pointer;
}

tr.selected,
tbody tr:hover {
  background: var(--surface-strong);
}

.chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.chip {
  border-radius: 99px;
  padding: 2px 8px;
  background: var(--surface);
  color: #40505b;
  font-size: 12px;
  white-space: nowrap;
}

.status {
  font-weight: 750;
  color: var(--green);
}

.status.inactive {
  color: var(--muted);
}

.details-panel {
  padding: 20px;
  background: #fcfdfd;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
}

.icon-button,
.link-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 22px;
}

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

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d7eeee;
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 20px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #4d5a66;
}

label input,
label select,
label textarea {
  width: 100%;
  color: var(--text);
  font-weight: 500;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: #4d5a66;
  font-weight: 700;
  font-size: 13px;
}

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

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.checkbox-grid input {
  min-height: auto;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.review-strip {
  display: grid;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

.review-strip-header,
.review-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.review-preview {
  display: grid;
  gap: 6px;
}

.review-preview-row {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
}

.review-preview-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.mini-actions .button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.split-list,
.api-docs,
.review-list,
.clients-header {
  padding: 0 24px 24px;
}

.clients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
}

.clients-header p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1.2fr 2fr 52px auto;
  gap: 10px;
  align-items: end;
  padding: 16px 0;
}

.inline-form h2 {
  grid-column: 1 / -1;
}

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

.list-card,
.review-card {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  background: white;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.group-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.group-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.token-row code {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 6px 8px;
  color: #2e3a43;
  font-size: 12px;
}

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

.list-card p,
.review-card p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.review-actions {
  display: flex;
  gap: 8px;
}

.danger {
  color: var(--red);
  border-color: rgba(194, 65, 61, 0.3);
}

.approve {
  color: var(--green);
  border-color: rgba(22, 121, 76, 0.3);
}

.api-docs {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

pre {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #111827;
  color: #e5e7eb;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 7px;
  background: #172026;
  color: white;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 160ms ease;
  box-shadow: var(--shadow);
}

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

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

  .brand span:last-child,
  .nav-item,
  .sidebar-footer {
    font-size: 0;
  }

  .nav-item::first-letter {
    font-size: 14px;
  }

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

  .details-panel {
    border-top: 1px solid var(--border);
  }
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 12px;
  }

  .brand span:last-child,
  .sidebar-footer {
    display: none;
  }

  .nav {
    display: flex;
  }

  .nav-item {
    white-space: nowrap;
    font-size: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
    height: auto;
  }

  .status-strip,
  .toolbar-actions,
  .review-strip-header,
  .review-preview-row,
  .clients-header,
  .list-card,
  .review-card {
    flex-direction: column;
    align-items: stretch;
  }

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