:root {
  --nb-bg: #ffffff;
  --nb-surface: #f7f8fa;
  --nb-surface-strong: #eef1f4;
  --nb-border: #dfe3e8;
  --nb-text: #18212b;
  --nb-muted: #697586;
  --nb-primary: #0f766e;
  --nb-primary-hover: #115e59;
  --nb-warning: #b45309;
  --nb-danger: #b42318;
  --nb-success: #067647;
  --nb-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
}

.dark,
[data-theme='dark'] {
  --nb-bg: #14181f;
  --nb-surface: #1b212a;
  --nb-surface-strong: #252d38;
  --nb-border: #343e4b;
  --nb-text: #edf1f5;
  --nb-muted: #9aa6b5;
  --nb-primary: #2dd4bf;
  --nb-primary-hover: #5eead4;
  --nb-warning: #fbbf24;
  --nb-danger: #fb7185;
  --nb-success: #34d399;
  --nb-shadow: 0 20px 54px rgba(0, 0, 0, 0.42);
}

#nb-budget-launcher {
  position: fixed;
  right: 22px;
  bottom: 76px;
  z-index: 2147482000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--nb-primary) 42%, var(--nb-border));
  border-radius: 8px;
  background: var(--nb-bg);
  color: var(--nb-text);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  font: 600 14px/1 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0;
  cursor: pointer;
}

#nb-budget-launcher:hover {
  border-color: var(--nb-primary);
  color: var(--nb-primary);
}

#nb-budget-launcher:focus-visible,
.nb-button:focus-visible,
.nb-input:focus-visible,
.nb-icon-button:focus-visible {
  outline: 2px solid var(--nb-primary);
  outline-offset: 2px;
}

.nb-launcher-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--nb-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.nb-modal-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--nb-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0;
}

.nb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.nb-dialog {
  position: relative;
  display: flex;
  width: min(1120px, 100%);
  max-height: min(86vh, 900px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--nb-border);
  border-radius: 8px;
  background: var(--nb-bg);
  box-shadow: var(--nb-shadow);
}

.nb-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--nb-border);
}

.nb-title {
  margin: 0;
  color: var(--nb-text);
  font-size: 19px;
  font-weight: 650;
  line-height: 1.35;
}

.nb-subtitle {
  margin: 5px 0 0;
  color: var(--nb-muted);
  font-size: 13px;
  line-height: 1.5;
}

.nb-icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--nb-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.nb-icon-button:hover {
  border-color: var(--nb-border);
  background: var(--nb-surface);
  color: var(--nb-text);
}

.nb-dialog-body {
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 20px;
}

.nb-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 11px 12px;
  border: 1px solid var(--nb-border);
  border-left-width: 3px;
  border-radius: 6px;
  background: var(--nb-surface);
  font-size: 13px;
  line-height: 1.55;
}

.nb-alert-warning {
  border-left-color: var(--nb-warning);
}

.nb-alert-danger {
  border-left-color: var(--nb-danger);
}

.nb-alert-success {
  border-left-color: var(--nb-success);
}

.nb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.nb-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nb-search {
  width: min(360px, 100%);
}

.nb-channel-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--nb-border);
  border-radius: 6px;
  background: var(--nb-surface);
}

.nb-channel-picker-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.nb-channel-picker-title {
  color: var(--nb-text);
  font-size: 13px;
  line-height: 1.4;
}

.nb-channel-picker-copy .nb-subtitle {
  margin: 0;
}

.nb-channel-picker-controls {
  display: flex;
  width: min(460px, 100%);
  align-items: center;
  gap: 8px;
}

.nb-channel-select {
  flex: 1 1 auto;
  min-width: 0;
}

.nb-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--nb-border);
  border-radius: 6px;
  background: var(--nb-bg);
  color: var(--nb-text);
  font: 400 13px/1 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0;
}

.nb-input::placeholder {
  color: var(--nb-muted);
}

.nb-input:hover,
.nb-input:focus {
  border-color: color-mix(in srgb, var(--nb-primary) 62%, var(--nb-border));
}

.nb-input-small {
  width: 92px;
}

.nb-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--nb-border);
  border-radius: 6px;
  background: var(--nb-bg);
  color: var(--nb-text);
  font: 600 13px/1 system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

.nb-button:hover {
  border-color: var(--nb-primary);
  color: var(--nb-primary);
}

.nb-button-primary {
  border-color: var(--nb-primary);
  background: var(--nb-primary);
  color: #ffffff;
}

.nb-button-primary:hover {
  background: var(--nb-primary-hover);
  color: #ffffff;
}

.nb-button-danger:hover {
  border-color: var(--nb-danger);
  color: var(--nb-danger);
}

.nb-button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.nb-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--nb-border);
  border-radius: 6px;
  background: var(--nb-surface);
}

.nb-summary-item {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--nb-border);
}

.nb-summary-item:last-child {
  border-right: 0;
}

.nb-summary-label {
  display: block;
  margin-bottom: 3px;
  color: var(--nb-muted);
  font-size: 11px;
}

.nb-summary-value {
  display: block;
  overflow: hidden;
  color: var(--nb-text);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.nb-table {
  width: 100%;
  min-width: 990px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

.nb-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--nb-surface-strong);
  color: var(--nb-muted);
  font-size: 11px;
  font-weight: 650;
}

.nb-table td {
  background: var(--nb-bg);
  font-size: 12px;
}

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

.nb-channel-name {
  display: block;
  overflow: hidden;
  color: var(--nb-text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-channel-meta {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--nb-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--nb-muted);
  font-size: 12px;
  white-space: nowrap;
}

.nb-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nb-muted);
  content: '';
}

.nb-status-enabled::before {
  background: var(--nb-success);
}

.nb-status-disabled::before {
  background: var(--nb-danger);
}

.nb-money {
  font-variant-numeric: tabular-nums;
  font-weight: 620;
  white-space: nowrap;
}

.nb-progress {
  display: grid;
  gap: 5px;
}

.nb-progress-track {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--nb-surface-strong);
}

.nb-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: var(--nb-primary);
}

.nb-level-warning .nb-progress-bar {
  background: var(--nb-warning);
}

.nb-level-critical .nb-progress-bar,
.nb-level-exceeded .nb-progress-bar {
  background: var(--nb-danger);
}

.nb-progress-label {
  color: var(--nb-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.nb-inline-fields {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nb-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--nb-muted);
  font-size: 11px;
  white-space: nowrap;
}

.nb-toggle-label input {
  width: 15px;
  height: 15px;
  accent-color: var(--nb-primary);
}

.nb-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.nb-empty,
.nb-loading {
  padding: 42px 16px;
  color: var(--nb-muted);
  text-align: center;
  font-size: 13px;
}

.nb-toast-region {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483600;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  gap: 8px;
}

.nb-toast {
  padding: 11px 13px;
  border: 1px solid var(--nb-border);
  border-left: 3px solid var(--nb-primary);
  border-radius: 6px;
  background: var(--nb-bg);
  color: var(--nb-text);
  box-shadow: var(--nb-shadow);
  font-size: 13px;
  line-height: 1.45;
}

.nb-toast-error {
  border-left-color: var(--nb-danger);
}

.nb-standalone {
  min-height: 100vh;
  margin: 0;
  background: var(--nb-surface);
}

.nb-standalone .nb-modal-root {
  position: static;
  min-height: 100vh;
}

.nb-standalone .nb-backdrop {
  display: none;
}

.nb-standalone .nb-dialog {
  max-height: calc(100vh - 40px);
}

@media (max-width: 840px) {
  #nb-budget-launcher {
    right: 14px;
    bottom: 68px;
  }

  .nb-modal-root {
    padding: 0;
  }

  .nb-dialog {
    width: 100%;
    max-height: 100vh;
    border-width: 0;
    border-radius: 0;
  }

  .nb-dialog-header,
  .nb-dialog-body {
    padding-right: 14px;
    padding-left: 14px;
  }

  .nb-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .nb-search {
    width: 100%;
  }

  .nb-toolbar-actions {
    justify-content: flex-end;
    overflow-x: auto;
  }

  .nb-channel-picker {
    align-items: stretch;
    flex-direction: column;
  }

  .nb-channel-picker-controls {
    width: 100%;
  }

  .nb-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nb-summary-item:nth-child(2) {
    border-right: 0;
  }

  .nb-summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--nb-border);
  }

  .nb-table-wrap {
    border: 0;
    overflow: visible;
  }

  .nb-table,
  .nb-table tbody,
  .nb-table tr,
  .nb-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .nb-table thead {
    display: none;
  }

  .nb-table tr {
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid var(--nb-border);
    border-radius: 6px;
    background: var(--nb-bg);
  }

  .nb-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 11px;
  }

  .nb-table td::before {
    color: var(--nb-muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
  }

  .nb-row-actions {
    justify-content: flex-start;
  }

  .nb-input-small {
    width: 100%;
  }
}

@media (max-width: 520px) {
  #nb-budget-launcher .nb-launcher-text {
    display: none;
  }

  #nb-budget-launcher {
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .nb-channel-picker-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .nb-channel-picker-controls .nb-button {
    width: 100%;
  }

  .nb-summary-strip {
    grid-template-columns: 1fr;
  }

  .nb-summary-item,
  .nb-summary-item:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--nb-border);
  }

  .nb-summary-item:last-child {
    border-bottom: 0;
  }

  .nb-alert {
    align-items: stretch;
    flex-direction: column;
  }
}
