:root {
  color-scheme: light;
  --blue: #1677ff;
  --blue-soft: #e8f2ff;
  --orange: #ff7a00;
  --red: #ff4d4f;
  --green: #00aa33;
  --bg: #f4f5f7;
  --card: #fff;
  --text: #222;
  --muted: #8a96a3;
  --line: #e5e8ef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sidebar-app {
  width: min(100%, 390px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}

.top-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 41px;
  border-bottom: 1px solid #d9dee7;
  background: #fff;
}

.tab {
  position: relative;
  background: #fff;
  color: #555;
  font-size: 14px;
}

.tab.active {
  color: #006dff;
  font-weight: 600;
}

.tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--blue);
  content: "";
}

.dev-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 5px 12px;
  border-bottom: 1px solid #ffe1ad;
  background: #fff8e8;
  color: #9a6500;
  font-size: 12px;
}

.dev-toolbar button {
  min-height: 24px;
  border: 1px solid #e2a431;
  border-radius: 4px;
  background: #fff;
  color: #8b5b00;
  padding: 2px 10px;
}

.group-chat-notice {
  border-bottom: 1px solid #ffd591;
  background: #fff7e6;
  color: #ad6800;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.status-view,
.unbound-view,
.sales-bind-view {
  padding: 54px 32px 0;
  text-align: center;
}

.status-view p,
.unbound-view p,
.sales-bind-view p {
  margin: 8px 0 20px;
  color: #7b8794;
  line-height: 1.5;
}

.unbound-view h1,
.sales-bind-view h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}

.sales-id-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 8px;
  margin: 18px 0 12px;
  padding: 12px;
  border: 1px solid #d8dce5;
  border-radius: 6px;
  background: #fff;
  text-align: left;
}

.sales-id-card span {
  color: #7e8a96;
}

.sales-id-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.sales-id-card button {
  height: 30px;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.sales-id-card button:disabled {
  background: #c8d0db;
}

.sales-bind-tip {
  font-size: 12px;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 12px;
  border: 3px solid #d8e8ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.search-box {
  display: grid;
  gap: 10px;
}

.search-box .auth-only {
  margin-top: 6px;
}

.search-box input,
.dialog-card input,
.dialog-card select,
.dialog-card textarea {
  width: 100%;
  border: 1px solid #d8dce5;
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.search-box input {
  height: 41px;
  padding: 0 12px;
}

.search-box button,
.btn {
  height: 37px;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.customer-view {
  padding: 14px 12px 18px;
}

.account-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.chip {
  flex: 0 0 auto;
  min-width: 58px;
  height: 26px;
  padding: 0 12px;
  border-radius: 13px;
  background: #eef0f4;
  color: #333;
  font-size: 12px;
}

.chip.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.card {
  margin-bottom: 10px;
  padding: 13px 12px;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 1px 5px rgba(20, 30, 50, 0.06);
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
}

.card-title.border {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #dfe3ea;
}

.card-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.title-with-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.title-with-badge h2 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cert-badge {
  flex: 0 0 auto;
  border-radius: 4px;
  background: #eef6ff;
  color: var(--blue);
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 600;
}

.cert-warning,
.cert-pending {
  background: #fff4df;
  color: #f56a00;
}

.cert-danger,
.cert-rejected {
  background: #ffeded;
  color: var(--red);
}

.field-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
}

.field-list div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: start;
}

.field-list .multiline-field {
  align-items: start;
}

dt {
  color: #7e8a96;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

dd span {
  display: block;
  line-height: 1.55;
}

.style-warning {
  display: inline-block;
  width: max-content;
  padding: 1px 5px;
  border-radius: 4px;
  background: #fff4df;
  color: #f56a00;
  font-weight: 600;
}

.style-primary {
  color: #ff7a00;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.card-actions .btn {
  width: 96px;
  min-width: 96px;
}

.btn {
  min-width: 72px;
  padding: 0 14px;
}

.btn.light {
  background: #f1f3f6;
  color: #333;
  font-weight: 400;
}

.btn.orange {
  background: var(--orange);
}

.contacts-list {
  display: grid;
  gap: 8px;
}

.contact-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid #ecedf1;
  border-radius: 5px;
  background: #fff;
}

.contact-item.selected {
  border-color: var(--blue);
  background: #eaf4ff;
}

.contact-item strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 500;
}

.contact-item p {
  margin: 0;
  color: #5f6b77;
  font-size: 12px;
}

.contact-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.mini-btn {
  height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  background: #f1f2f4;
  color: #111;
  font-size: 12px;
}

.mini-btn.danger {
  background: #ffeded;
  color: var(--red);
}

.add-btn {
  width: 100%;
  height: 28px;
  margin-top: 12px;
  border-radius: 4px;
  background: #f0f1f3;
  color: #111;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-left: 78px;
}

.tag {
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 2px 6px;
  font-size: 12px;
}

.line-list {
  display: grid;
  gap: 0;
}

.line-list p {
  margin: 0;
  padding: 7px 0;
  border-bottom: 1px solid #eef0f3;
  color: #384250;
  font-size: 12px;
  line-height: 1.35;
}

.line-list p:last-child {
  border-bottom: 0;
}

.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 10px;
}

.bottom-actions .btn {
  width: 100%;
  height: 36px;
}

.search-results {
  margin-top: 42px;
  text-align: left;
}

.search-results h2 {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
}

.bind-desc {
  text-align: center;
  color: #8b96a5;
}

.bind-card {
  position: relative;
  display: grid;
  width: 100%;
  gap: 5px;
  min-height: 60px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #d8dce5;
  border-radius: 5px;
  background: #fff;
  text-align: left;
}

.account-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 8px;
  min-width: 0;
}

.account-result-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.bind-card strong {
  font-size: 15px;
  font-weight: 500;
}

.bind-card span {
  color: #5d6976;
  font-size: 12px;
}

.bind-card:disabled {
  opacity: 0.65;
}

.bind-card.loading {
  place-items: center;
  text-align: center;
  opacity: 1;
}

.inline-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #d8e8ff;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-line,
.loading-line {
  padding: 12px 0;
  color: #8a96a3;
  text-align: center;
}

.dialog {
  width: min(342px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
}

.dialog-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.dialog-card h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.dialog-card label {
  display: grid;
  gap: 5px;
  color: #5f6b77;
  font-size: 12px;
}

.dialog-card input,
.dialog-card select,
.dialog-card textarea {
  padding: 8px 10px;
  color: #111;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  left: 24px;
  z-index: 30;
  width: min(320px, calc(100vw - 48px));
  margin: 0 auto;
  border-radius: 7px;
  background: rgba(18, 24, 33, 0.88);
  color: #fff;
  padding: 10px 12px;
  text-align: center;
}
