:root {
  --pink: #e5007e;
  --blue: #005bbb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe3ee;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --success: #0b7a36;
  --danger: #c81e1e;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(229, 0, 126, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(0, 91, 187, 0.10), transparent 30%),
    var(--bg);
}

.layout {
  width: min(1280px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 0.38fr) minmax(360px, 1fr);
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.brand h1,
.cabinet h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1.04;
  letter-spacing: 0;
}

.brand p,
.cabinet header p,
.notice p,
.release p {
  color: var(--muted);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--pink);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.auth-card,
.cabinet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  padding: 24px;
}

.auth-card {
  width: min(640px, 100%);
  justify-self: end;
}

.tabs,
.cabinet-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

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

.cabinet-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.tab,
.section-tab,
.ghost,
.primary,
.danger {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
}

.tab.active,
.section-tab.active,
.primary {
  border-color: var(--pink);
  background: var(--pink);
  color: #fff;
}

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

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

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

input,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font: inherit;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 104px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: #fff1f7;
  color: var(--pink);
  font-weight: 800;
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--pink);
  color: #fff;
}

textarea {
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(229, 0, 126, 0.18);
  border-color: var(--pink);
}

.message {
  display: none;
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff1f7;
  color: #9d174d;
  font-weight: 700;
}

.message.visible {
  display: block;
}

.cabinet {
  display: none;
}

body[data-view="cabinet"] .auth-card,
body[data-view="cabinet"] .brand {
  display: none;
}

body[data-view="cabinet"] .layout {
  display: block;
  align-items: start;
}

body[data-view="cabinet"] .cabinet {
  display: block;
  position: relative;
  padding-top: 28px;
}

body[data-view="cabinet"][data-active-section="overview"] .cabinet {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

body[data-view="cabinet"][data-active-section="overview"] .cabinet-header,
body[data-view="cabinet"][data-active-section="overview"] > .layout > .cabinet > .cabinet-tabs {
  display: none;
}

.cabinet-logout {
  display: flex;
  width: max-content;
  min-width: 86px;
  margin: 0 0 12px auto;
}

.cabinet-header,
.section-head,
.release {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.cabinet-header {
  margin-bottom: 22px;
}

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

.cabinet h2 {
  font-size: 30px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section h3,
.section h4 {
  margin: 0 0 14px;
}

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

.cards.compact {
  margin-bottom: 24px;
}

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

.card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.card strong {
  font-size: 22px;
}

.client-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.46fr) minmax(560px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.workspace-card,
.workspace-web-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.workspace-card {
  padding: 30px 18px 16px;
}

.workspace-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

.workspace-brand img {
  width: 150px;
  height: auto;
}

.workspace-card h3 {
  max-width: 360px;
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.12;
}

.workspace-lead {
  max-width: 390px;
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.workspace-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.workspace-tabs .section-tab {
  min-height: 38px;
}

.workspace-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.workspace-metrics.is-loading {
  display: none;
}

.workspace-metric {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.metric-link {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.metric-link:hover,
.metric-link:focus {
  border-color: rgba(229, 0, 126, 0.36);
  box-shadow: 0 0 0 3px rgba(229, 0, 126, 0.08);
  outline: none;
}

.workspace-metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.workspace-metric strong {
  display: block;
  max-width: 100%;
  font-size: 20px;
  line-height: 1.18;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compact-empty {
  padding: 12px;
}

.workspace-web-preview {
  display: grid;
  grid-template-columns: 236px minmax(420px, 1fr);
  min-height: 640px;
  background: #eef0f4;
}

.preview-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f5f6f9;
  padding: 24px 18px 0;
}

.preview-sidebar img {
  width: 154px;
  height: auto;
  margin-bottom: 18px;
}

.preview-sidebar p {
  margin: 0 0 18px;
  color: #526174;
  line-height: 1.48;
}

.preview-mode {
  border-left: 3px solid var(--pink);
  padding-left: 12px;
  margin-bottom: 20px;
}

.preview-mode span,
.preview-book-side span {
  color: var(--muted);
  font-size: 13px;
}

.preview-mode strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.preview-book,
.preview-link {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.preview-book.active,
.preview-link.active {
  border-left: 3px solid var(--pink);
  background: #fff;
  color: var(--pink);
}

.preview-download {
  margin: 20px -18px 0;
  padding: 24px 18px 48px;
  background: linear-gradient(145deg, var(--pink), #f25a91);
  color: #fff;
}

.preview-download p {
  color: #fff;
  font-weight: 700;
}

.download-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
}

.preview-download a {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  margin-top: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.preview-main {
  display: grid;
  grid-template-rows: 32px auto auto 1fr;
  min-width: 0;
}

.preview-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.preview-connect {
  width: min(500px, calc(100% - 52px));
  justify-self: center;
  align-self: start;
  margin: 18px 0 14px;
  border: 1px solid #e2e7ef;
  border-radius: 8px;
  background: #fff;
  padding: 24px 22px 22px;
}

.preview-connect h4 {
  margin: 0 0 12px;
  font-size: 24px;
}

.preview-input-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 128px;
  gap: 10px;
}

.preview-input-row input {
  min-height: 48px;
  font-size: 22px;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.preview-tabs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 26px;
}

.preview-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  font: inherit;
  cursor: pointer;
}

.preview-tabs button.active {
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  padding: 0 14px;
  box-shadow: 0 3px 0 var(--ink);
}

.preview-tabs .icon-only {
  min-width: 34px;
  padding: 0;
}

.preview-tabs .icon-only.active {
  box-shadow: none;
}

.preview-book-area {
  display: block;
  min-width: 0;
  padding: 12px 26px 24px;
}

.preview-search {
  margin-bottom: 12px;
}

.preview-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  font: inherit;
}

.preview-inline-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.preview-add-contact-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(100%, 420px);
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  overflow: hidden;
}

.preview-inline-actions[hidden],
.preview-add-contact-form[hidden] {
  display: none;
}

.preview-add-contact-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-add-contact-form input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
}

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

.preview-peer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.preview-peer-grid.sessions {
  grid-template-columns: 1fr;
  gap: 10px;
}

.preview-peer-grid.list {
  grid-template-columns: 1fr;
  gap: 10px;
}

.preview-peer-card {
  overflow: hidden;
  min-height: 142px;
  border: 0;
  border-radius: 8px;
  background: #eef1f5;
  text-align: left;
  cursor: pointer;
}

.preview-peer-grid.list .preview-peer-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  min-height: 74px;
}

.preview-peer-card:hover,
.preview-peer-card:focus {
  outline: 2px solid rgba(229, 0, 126, 0.28);
}

.preview-peer-art {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 92px;
  padding: 12px;
  color: #fff;
  background: #c781d7;
}

.preview-peer-grid.list .preview-peer-art {
  min-height: 74px;
}

.preview-peer-art span {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.preview-peer-art.tone-2 { background: #d080aa; }
.preview-peer-art.tone-3 { background: #9699d3; }
.preview-peer-art.tone-4 { background: #8eb889; }
.preview-peer-art.tone-5 { background: #d49a84; }

.preview-peer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 12px;
}

.preview-peer-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-peer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.favorite-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8a94a6;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.favorite-toggle:hover,
.favorite-toggle:focus {
  border-color: rgba(229, 0, 126, 0.28);
  color: var(--pink);
}

.favorite-toggle.active {
  border-color: rgba(229, 0, 126, 0.22);
  background: #fff1f7;
  color: var(--pink);
}

.preview-delete-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #a33d49;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.preview-delete-toggle:hover,
.preview-delete-toggle:focus {
  border-color: rgba(220, 38, 38, 0.22);
  background: #fff1f2;
  color: #dc2626;
}

.preview-session-row {
  display: grid;
  grid-template-columns: minmax(112px, 1.25fr) minmax(108px, 1.15fr) minmax(92px, 1fr) minmax(86px, .9fr) minmax(64px, .7fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

.preview-session-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.preview-session-row span {
  color: var(--muted);
  font-size: 12px;
}

.preview-session-row strong {
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.preview-session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.preview-icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.preview-icon-action svg {
  width: 22px;
  height: 22px;
}

.preview-icon-action:hover,
.preview-icon-action:focus {
  border-color: rgba(7, 20, 43, 0.35);
}

.preview-icon-action.add {
  border-color: rgba(229, 0, 126, 0.35);
  background: #fff1f7;
  color: var(--pink);
}

.preview-icon-action.add:hover,
.preview-icon-action.add:focus {
  border-color: var(--pink);
}

.notice {
  margin-top: 16px;
  border-left: 4px solid var(--blue);
  background: #eef6ff;
  border-radius: 8px;
  padding: 16px;
}

.notice strong {
  color: var(--blue);
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-note {
  margin: -6px 0 14px;
  max-width: 760px;
}

.web-client-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
  margin-bottom: 18px;
}

.web-client-hero strong {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
}

.web-client-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.web-contact-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 16px;
}

.web-contact-preview h4 {
  margin: 0 0 4px;
}

.web-contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.web-contact-card strong {
  display: block;
  margin-bottom: 8px;
}

.web-contact-card span {
  color: var(--muted);
  font-weight: 800;
}

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

.client-entry-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 16px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr);
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.inline-message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-message.good {
  color: var(--success);
}

.inline-message.error {
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #f1f5f9;
  font-size: 12px;
  text-transform: uppercase;
}

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

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.editing-row td {
  background: #fff7fb;
}

.table-input {
  width: 100%;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.table-input:focus {
  outline: 2px solid rgba(229, 0, 126, 0.16);
  border-color: var(--pink);
}

.id-input {
  min-width: 130px;
}

.note-input {
  resize: vertical;
  min-height: 40px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.pill.good {
  background: #eaf7f2;
  color: var(--success);
}

.release-list {
  display: grid;
  gap: 12px;
}

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

.release p {
  margin: 6px 0;
}

code {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    align-items: start;
    padding-top: 28px;
  }

  .brand h1 {
    font-size: 36px;
  }

  .auth-card {
    width: 100%;
    justify-self: stretch;
  }

  .cards,
  .tabs,
  .cabinet-tabs {
    grid-template-columns: 1fr;
  }

  .cabinet-header,
  .section-head,
  .release,
  .form-actions,
  .web-client-hero {
    display: grid;
  }

  .section-actions {
    justify-content: stretch;
  }

  .web-client-actions {
    justify-content: stretch;
  }

  .section-actions > *,
  .web-client-actions > * {
    width: 100%;
  }

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

  .client-workspace,
  .workspace-web-preview,
  .preview-input-row {
    grid-template-columns: 1fr;
  }

  .workspace-web-preview {
    min-height: auto;
  }

  .preview-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-download {
    padding-bottom: 24px;
  }

  .preview-tabs {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .preview-add-contact-form,
  .preview-session-row {
    grid-template-columns: 1fr;
  }

  .preview-add-actions {
    justify-content: flex-start;
  }

}
