*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", SegoeUI, system-ui, -apple-system, BlinkMacSystemFont,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--bc-text);
  background: var(--bc-page);
  -webkit-font-smoothing: antialiased;
  accent-color: var(--bc-accent);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--bc-text);
}

p {
  margin: 0;
}

a {
  color: var(--bc-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

img {
  max-width: 100%;
  display: block;
}

.bc-muted {
  color: var(--bc-muted);
}

.bc-tabular {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.bc-field__hint {
  font-size: 12px;
  color: var(--bc-muted);
}

.bc-field__error {
  font-size: 12px;
  color: var(--bc-danger);
  margin-top: 8px;
}

.bc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.bc-field--narrow {
  max-width: 360px;
}

.bc-field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--bc-text);
}

.bc-input,
.bc-textarea {
  width: 100%;
  border: 1px solid var(--bc-border-strong);
  border-radius: var(--bc-radius-control);
  background: var(--bc-bg);
  color: var(--bc-text);
  transition: border-color 80ms ease, box-shadow 80ms ease, background-color 80ms ease;
}

.bc-input {
  height: var(--bc-control-height);
  padding: 0 12px;
  caret-color: var(--bc-accent);
}

.bc-input--otp {
  max-width: 180px;
  text-align: center;
  letter-spacing: 0.35em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bc-textarea {
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

.bc-input::placeholder,
.bc-textarea::placeholder {
  color: var(--bc-muted-2);
}

.bc-input:hover:not(:disabled):not(:focus):not(.bc-input--readonly),
.bc-textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--bc-muted);
}

.bc-input:focus,
.bc-textarea:focus {
  outline: none;
  border-color: var(--bc-accent);
  box-shadow: var(--bc-focus-ring);
}

.bc-input--readonly,
.bc-input:disabled {
  background: var(--bc-disabled-bg);
  color: var(--bc-text-secondary);
  cursor: default;
}

.bc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--bc-control-height);
  padding: 0 12px;
  border-radius: var(--bc-radius-control);
  border: 1px solid transparent;
  background: var(--bc-surface);
  color: var(--bc-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 80ms ease, border-color 80ms ease, color 80ms ease;
}

.bc-button:focus-visible {
  outline: none;
  border-color: var(--bc-accent);
  box-shadow: var(--bc-focus-ring);
}

.bc-button--compact {
  height: var(--bc-control-height-compact);
  padding: 0 10px;
  font-size: 12px;
}

.bc-button--icon {
  width: var(--bc-control-height-compact);
  padding: 0;
}

.bc-button--secondary {
  background: var(--bc-surface);
  border-color: var(--bc-border-strong);
  color: var(--bc-text);
}

.bc-button--secondary:hover:not(:disabled) {
  background: var(--bc-accent-bg);
  border-color: var(--bc-accent);
}

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

.bc-button--primary:hover:not(:disabled) {
  background: var(--bc-hover);
  border-color: var(--bc-hover);
}

.bc-button--primary:active:not(:disabled) {
  background: var(--bc-active);
  border-color: var(--bc-active);
}

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

.bc-card {
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-card);
  padding: 12px 14px;
  box-shadow: var(--bc-shadow);
}

.bc-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.bc-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--bc-text);
  margin: 0;
}

.bc-card__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bc-card__desc {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--bc-text-secondary);
}

.bc-alert {
  padding: 12px 14px;
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-card);
  font-size: 13px;
  margin-bottom: 16px;
}

.bc-alert--danger {
  background: var(--bc-danger-bg);
  border-color: var(--bc-danger-border);
  color: var(--bc-danger);
}

.bc-alert--success {
  background: var(--bc-success-bg);
  border-color: var(--bc-success-border);
  color: var(--bc-success);
}

.bc-alert--warning {
  background: var(--bc-warning-bg);
  border-color: var(--bc-warning-border);
  color: var(--bc-text);
}

.bc-alert--action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.bc-alert__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--bc-warning);
}

.bc-alert__message {
  margin: 0;
}

.bc-alert__hint {
  margin: 0;
  font-size: 12px;
  color: var(--bc-muted-2);
}

.bc-alert__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--bc-badge-bg);
  color: var(--bc-badge-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.bc-badge--success {
  background: var(--bc-success-bg);
  color: var(--bc-success);
}

.bc-badge--danger {
  background: var(--bc-danger-bg);
  color: var(--bc-danger);
}

.bc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bc-overlay);
}

.bc-modal-overlay[hidden] {
  display: none !important;
}

.bc-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--bc-surface);
  border: 1px solid var(--bc-border);
  border-radius: var(--bc-radius-card);
  box-shadow: var(--bc-modal-shadow);
  overflow: hidden;
}

.bc-modal__header,
.bc-modal__footer {
  padding: 12px 14px;
}

.bc-modal__header {
  border-bottom: 1px solid var(--bc-border);
}

.bc-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--bc-border);
}

.bc-modal__body {
  padding: 12px 14px;
}

.bc-modal__title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

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

.bc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bc-table th,
.bc-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--bc-border);
}

.bc-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--bc-muted);
}

.bc-table tbody tr:hover {
  background: var(--bc-accent-bg);
}

.bc-table tbody tr.bc-row--success {
  box-shadow: inset 3px 0 0 var(--bc-success);
}

.bc-table tbody tr.bc-row--danger {
  box-shadow: inset 3px 0 0 var(--bc-danger);
}

.bc-table__empty {
  padding: 12px;
  color: var(--bc-muted);
  font-size: 12px;
}

.bc-table__actions {
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 959px) {
  html,
  body {
    overflow-x: hidden;
  }
}

@media (max-width: 719px) {
  .bc-table-wrap:has(.bc-table--stack) {
    overflow: visible;
    margin-inline: 0;
  }

  .bc-table--stack thead {
    display: none;
  }

  .bc-table--stack,
  .bc-table--stack tbody {
    display: block;
    width: 100%;
  }

  .bc-table--stack tbody tr {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 8px;
    padding: 12px;
    border: 1px solid var(--bc-border);
    border-radius: var(--bc-radius-card);
    background: var(--bc-bg);
    max-width: 100%;
    box-shadow: none;
  }

  .bc-table--stack tbody tr:last-child {
    margin-bottom: 0;
  }

  .bc-table--stack tbody tr:hover {
    background: var(--bc-bg);
  }

  .bc-table--stack tbody tr.bc-row--success,
  .bc-table--stack tbody tr.bc-row--danger {
    box-shadow: inset 3px 0 0 var(--bc-success);
  }

  .bc-table--stack tbody tr.bc-row--danger {
    box-shadow: inset 3px 0 0 var(--bc-danger);
  }

  .bc-table--stack td {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    grid-template-areas: "label value";
    gap: 8px;
    align-items: start;
    width: 100%;
    max-width: 100%;
    padding: 0;
    border-bottom: none;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .bc-table--stack td::before {
    content: attr(data-label);
    grid-area: label;
    font-size: 12px;
    font-weight: 600;
    color: var(--bc-muted);
    line-height: 1.35;
    padding-top: 2px;
  }

  .bc-table--stack td > * {
    grid-area: value;
    min-width: 0;
    justify-self: start;
  }

  .bc-table--stack td.bc-table__stack-primary {
    display: block;
    padding-bottom: 8px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--bc-border);
    font-weight: 600;
  }

  .bc-table--stack td.bc-table__stack-primary::before {
    display: none;
  }

  .bc-table--stack td.bc-table__actions {
    display: block;
    padding-top: 4px;
  }

  .bc-table--stack td.bc-table__actions::before {
    display: none;
  }

  .bc-table--stack .bc-table__actions .bc-button,
  .bc-table--stack td.bc-table__actions .bc-button {
    width: 100%;
    justify-content: center;
  }

  .bc-table--stack .bc-table__empty,
  .bc-table--stack td.bc-table__empty {
    display: block;
    grid-template-columns: none;
    text-align: center;
    color: var(--bc-muted);
  }

  .bc-table--stack td.bc-table__empty::before {
    display: none;
  }

  .bc-badge {
    white-space: normal;
    max-width: 100%;
  }
}
