/* Buttons ------------------------------------------------------------- */
.btn {
  --h: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:hover {
  background: #1b2030;
  border-color: var(--line-3);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn[disabled],
.btn.is-loading {
  opacity: 0.5;
  pointer-events: none;
}
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px -8px var(--brand-glow);
}
.btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 28px -8px var(--brand-glow);
}
.btn.success {
  background: var(--ok-soft);
  border-color: rgba(61, 220, 132, 0.35);
  color: var(--ok);
}
.btn.danger {
  background: var(--bad-soft);
  border-color: rgba(240, 77, 95, 0.35);
  color: #ff8c99;
}
.btn.danger:hover {
  background: rgba(240, 77, 95, 0.22);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.btn.sm {
  --h: 30px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: var(--r-xs);
}
.btn.icon {
  width: var(--h);
  padding: 0;
}
.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}

/* Forms -------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label,
.label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.hint {
  font-size: 12.5px;
  color: var(--dim);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: rgba(8, 10, 16, 0.7);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--dim);
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--line-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  background: rgba(8, 10, 16, 0.95);
}
.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23838ba3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.select option {
  background: #12151f;
}
.input.sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13.5px;
}
.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #232839;
  border: 1px solid var(--line-2);
  transition: 0.2s var(--ease);
}
.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #8a92a8;
  transition: 0.22s var(--ease);
}
.switch input:checked + i {
  background: var(--grad);
  border-color: transparent;
}
.switch input:checked + i::after {
  transform: translateX(18px);
  background: #fff;
}
.switch input:focus-visible + i {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  color: var(--text-2);
}

/* Surfaces ------------------------------------------------------------ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(14px);
  min-width: 0;
}
.card-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 0;
}
.card-h h3 {
  font-size: 15px;
  font-weight: 600;
}
.card-h .sub {
  color: var(--muted);
  font-size: 13px;
}
.card-b {
  padding: 16px 20px 20px;
}
.card.tight .card-b {
  padding: 0;
}
.card.glow {
  position: relative;
}
.card.glow::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(255, 61, 127, 0.5), transparent 35%, transparent 65%, rgba(177, 140, 255, 0.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.grid {
  display: grid;
  gap: 18px;
}
.grid.c2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid.c3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.c4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.split {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}
@media (max-width: 1180px) {
  .grid.c4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid.split {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .grid.c2,
  .grid.c3,
  .grid.c4 {
    grid-template-columns: 1fr;
  }
}

/* Stat --------------------------------------------------------------- */
.stat {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.stat .k {
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}
.stat .k svg {
  width: 15px;
  height: 15px;
  opacity: 0.8;
}
.stat .v {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .v small {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}
.stat .d {
  font-size: 13px;
  color: var(--muted);
}
.stat .spark {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 55%;
  height: 46px;
  opacity: 0.9;
  pointer-events: none;
}

/* Badges & chips --------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.bad {
  background: var(--bad-soft);
  color: #ff8c99;
}
.badge.info {
  background: var(--info-soft);
  color: var(--info);
}
.badge.brand {
  background: var(--brand-soft);
  color: #ff7aa6;
}
.badge.violet {
  background: var(--violet-soft);
  color: var(--violet);
}
.badge.teal {
  background: var(--teal-soft);
  color: var(--teal);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6);
  animation: pulse 2s infinite;
}
.dot.warn {
  background: var(--warn);
}
.dot.bad {
  background: var(--bad);
}
@keyframes pulse {
  70% {
    box-shadow: 0 0 0 7px rgba(61, 220, 132, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 220, 132, 0);
  }
}

/* Tables ------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.t th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.t td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.t tr:last-child td {
  border-bottom: 0;
}
table.t tbody tr {
  transition: background 0.15s;
}
table.t tbody tr.click {
  cursor: pointer;
}
table.t tbody tr.click:hover {
  background: rgba(255, 255, 255, 0.035);
}
table.t td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Tabs / segmented ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(8, 10, 16, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: 0.18s;
}
.tab:hover {
  color: var(--text);
}
.tab.on {
  background: var(--bg-3);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--line-2);
}
.tab .n {
  margin-left: 6px;
  color: var(--dim);
  font-size: 12px;
}

/* Modal / drawer ------------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 4, 8, 0.66);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade 0.18s var(--ease);
}
.overlay.is-side {
  place-items: stretch end;
  padding: 0;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  animation: pop 0.26s var(--ease);
}
.modal.wide {
  width: min(880px, 100%);
}
.modal-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 0;
}
.modal-h h3 {
  font-size: 18px;
  flex: 1;
}
.modal-b {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-f {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 22px;
}
.drawer {
  width: min(720px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--panel-solid);
  border-left: 1px solid var(--line-2);
  box-shadow: var(--shadow-2);
  animation: slide 0.3s var(--ease);
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
@keyframes slide {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
}

/* Toasts --------------------------------------------------------------------------- */
#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}
.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 260px;
  max-width: 420px;
  padding: 12px 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--info);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  animation: pop 0.3s var(--ease);
  font-size: 14px;
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.bad {
  border-left-color: var(--bad);
}
.toast.warn {
  border-left-color: var(--warn);
}

/* Empty / skeleton --------------------------------------------------------------------- */
.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}
.empty svg {
  width: 38px;
  height: 38px;
  opacity: 0.45;
}
.empty b {
  color: var(--text-2);
  font-weight: 600;
}
.skel {
  border-radius: 8px;
  background: linear-gradient(90deg, #131725 25%, #1a1f30 50%, #131725 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* Misc --------------------------------------------------------------------------------- */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  flex: none;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  overflow: hidden;
}
.avatar.lg {
  width: 64px;
  height: 64px;
  font-size: 24px;
}
.avatar.sm {
  width: 26px;
  height: 26px;
  font-size: 12px;
}
.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 8px 16px;
  font-size: 14px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  min-width: 0;
  word-wrap: anywhere;
}
.bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.6s var(--ease);
}
.divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}
.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}
.notice {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--info-soft);
  font-size: 14px;
  color: var(--text-2);
}
.notice.warn {
  background: var(--warn-soft);
  border-color: rgba(245, 165, 36, 0.3);
}
.notice.bad {
  background: var(--bad-soft);
  border-color: rgba(240, 77, 95, 0.3);
}
.notice.ok {
  background: var(--ok-soft);
  border-color: rgba(61, 220, 132, 0.3);
}
.notice svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 2px;
}
.kbd {
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-2);
}
.md p + p {
  margin-top: 8px;
}
.md h1,
.md h2,
.md h3 {
  margin: 4px 0;
}

/* Layout polish ------------------------------------------------------- */
/* Cards placed directly in the view get consistent vertical rhythm. */
.view > .card + .card,
.view > .grid + .card,
.view > .card + .grid,
.view > .grid + .grid {
  margin-top: 18px;
}
.grid.stats {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
@media (max-width: 760px) {
  .grid.c4,
  .grid.stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .stat {
    padding: 14px 16px;
  }
  .stat .v {
    font-size: 24px;
  }
  .page-h h2 {
    font-size: 22px;
  }
}
@media (max-width: 380px) {
  .grid.c4,
  .grid.stats {
    grid-template-columns: 1fr;
  }
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.table tr:last-child td {
  border-bottom: 0;
}
table.table td small {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12px;
}
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.stat .k .dot {
  flex: none;
}
.field-error {
  color: var(--bad, #ff6b81);
  font-size: 12.5px;
  margin-top: 4px;
}
.input.invalid,
.select.invalid {
  border-color: var(--bad, #ff6b81);
}
.retry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}
.load-state {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.load-state .skel {
  border-radius: var(--r-md);
}
.page-h .spacer {
  flex: 1;
}
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.card-h {
  flex-wrap: wrap;
  row-gap: 10px;
}
.card-h h3 {
  white-space: nowrap;
}
.card-h .input.sm {
  max-width: 100%;
}
