:root {
  --db-backdrop: rgba(13, 20, 30, 0.62);
  --db-panel: #ffffff;
  --db-panel-strong: #f5f7fb;
  --db-line: #d9e0ea;
  --db-text: #172033;
  --db-muted: #657186;
  --db-danger: #b42318;
}

.db-auth-pending .app-shell {
  visibility: hidden;
}

.db-login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(19, 33, 48, 0.96), rgba(20, 35, 34, 0.92)),
    #132130;
  color: #f8fafc;
}

.db-login-screen[hidden] {
  display: none;
}

.db-login-card {
  width: min(100%, 420px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  padding: 28px;
}

.db-login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.db-login-brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 8px;
}

.db-login-brand strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
}

.db-login-brand span {
  display: block;
  color: rgba(248, 250, 252, 0.78);
  font-size: 0.92rem;
  margin-top: 4px;
}

.db-login-form {
  display: grid;
  gap: 14px;
}

.db-login-form label,
.db-panel-form label {
  display: grid;
  gap: 6px;
  color: inherit;
  font-weight: 650;
}

.db-login-form input,
.db-panel-form input,
.db-panel-form select,
.db-panel-form textarea {
  min-width: 0;
  border: 1px solid var(--db-line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--db-text);
  font: inherit;
}

.db-login-form input {
  border-color: rgba(255, 255, 255, 0.3);
}

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

.db-login-forgot {
  justify-self: end;
  color: #bfdbfe;
  font-weight: 800;
  text-decoration: none;
}

.db-login-forgot:hover {
  color: #fff;
  text-decoration: underline;
}

.db-login-note {
  margin: 0 0 18px;
  color: rgba(248, 250, 252, 0.78);
  line-height: 1.5;
}

.db-auth-error {
  min-height: 20px;
  color: #fecaca;
  font-weight: 650;
}

.db-shell-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.db-user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  font-size: 0.9rem;
  white-space: nowrap;
}

.db-acting-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.db-acting-user select {
  width: min(280px, 28vw);
  min-width: 170px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.db-dialog {
  width: min(1180px, calc(100vw - 28px));
  max-height: min(86vh, 860px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--db-panel);
  color: var(--db-text);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

.db-dialog::backdrop {
  background: var(--db-backdrop);
}

.db-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: inherit;
}

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

.db-panel-head h2 {
  margin: 0;
  font-size: 1.18rem;
}

.db-panel-head p {
  margin: 4px 0 0;
  color: var(--db-muted);
}

.db-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--db-line);
  background: var(--db-panel-strong);
}

.db-tabs button {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
  color: var(--db-muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.db-tabs button.active {
  border-color: var(--db-line);
  background: #fff;
  color: var(--db-text);
}

.db-panel-body {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 22px;
}

.db-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.db-permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.db-check-card {
  position: relative;
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.db-check-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.db-check-card:has(input:checked) {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  background: var(--surface-2);
}

.db-check-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  min-width: 1px;
  height: 1px;
  min-height: 1px;
  padding: 0;
  pointer-events: none;
}

.db-check-indicator {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 12%, transparent);
}

.db-check-indicator::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(-45deg);
}

.db-check-card input[type="checkbox"]:checked + .db-check-indicator {
  border-color: var(--primary);
  background: var(--primary);
}

.db-check-card input[type="checkbox"]:checked + .db-check-indicator::after {
  border-color: #fff;
}

.db-check-card input[type="checkbox"]:focus-visible + .db-check-indicator {
  box-shadow: var(--focus-ring);
}

.db-user-pricing {
  border: 1px solid var(--db-line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.db-user-tariff,
.db-settings-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.db-admin-settings-forms {
  display: grid;
  gap: 14px;
}

.db-pricing-mode-toggle {
  min-height: 44px;
}

.db-pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.db-pricing-grid input:disabled {
  opacity: 0.72;
  background: var(--surface);
}

.db-pricing-defaults {
  font-size: 0.88rem;
}

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

.db-settings-grid .full {
  grid-column: 1 / -1;
}

.db-tariff-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 18px;
  align-items: start;
}

.db-tariff-head h2 {
  margin: 0;
}

.db-tariff-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.db-tariff-price {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.db-tariff-price span,
.db-tariff-price small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.db-tariff-price strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
  font-size: 1.6rem;
}

.db-tariff-form {
  margin-top: 16px;
}

.db-tariff-base,
.db-tariff-trial {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.db-tariff-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.db-tariff-tabs span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 750;
}

.db-tariff-addon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.db-check-card.db-tariff-addon {
  align-items: flex-start;
  min-height: 98px;
}

.db-tariff-addon strong {
  display: block;
  margin-bottom: 4px;
}

.db-tariff-addon small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.45;
}

.db-section {
  display: grid;
  gap: 12px;
}

.db-section h3 {
  margin: 0;
  font-size: 1rem;
}

.db-section p {
  margin: 0;
  color: var(--db-muted);
  line-height: 1.5;
}

.db-panel-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.db-panel-form .full {
  grid-column: 1 / -1;
}

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

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.db-table th,
.db-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--db-line);
  text-align: left;
  vertical-align: top;
}

.db-table th {
  background: var(--db-panel-strong);
  color: var(--db-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

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

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

.db-metric {
  border: 1px solid var(--db-line);
  border-radius: 8px;
  padding: 12px;
  background: var(--db-panel-strong);
  color: var(--db-text);
}

.db-metric span {
  display: block;
  color: var(--db-muted);
  font-size: 0.82rem;
}

.db-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  color: var(--db-text);
}

.db-status {
  min-height: 21px;
  color: var(--db-muted);
  font-weight: 650;
}

.db-status.bad {
  color: var(--db-danger);
}

.db-status.ok {
  color: #047857;
}

.db-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.db-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.db-billing-invoices,
.db-billing-editor {
  margin-top: 14px;
}

.db-billing-detail-head {
  justify-content: space-between;
}

.db-billing-detail-head h3 {
  margin: 0;
}

.db-billing-detail-head p {
  margin: 4px 0 0;
}

.db-billing-invoice-form {
  border: 1px solid var(--db-line);
  border-radius: 8px;
  padding: 14px;
  background: var(--db-panel-strong);
}

.db-billing-items {
  display: grid;
  gap: 10px;
}

.db-billing-item-table input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--db-line);
  border-radius: 6px;
  padding: 8px 9px;
  background: #fff;
  color: var(--db-text);
  font: inherit;
}

.db-billing-item-table th:nth-child(2),
.db-billing-item-table th:nth-child(3),
.db-billing-item-table th:nth-child(4),
.db-billing-item-table td:nth-child(2),
.db-billing-item-table td:nth-child(3),
.db-billing-item-table td:nth-child(4) {
  width: 130px;
}

.db-page-accordion-list {
  display: grid;
  gap: 12px;
}

.db-page-accordion {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.db-page-accordion > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.db-page-accordion > summary::-webkit-details-marker {
  display: none;
}

.db-page-accordion > summary::after {
  content: "⌄";
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 900;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.db-page-accordion:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.db-page-accordion > summary:hover::after {
  background: var(--surface-soft);
  color: var(--text);
}

.db-page-accordion h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.db-page-accordion p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.db-page-accordion-body {
  display: grid;
  gap: 14px;
  padding: 0 20px 20px;
}

.db-page-accordion-body > .row-actions {
  justify-content: flex-end;
}

.db-denied {
  padding: 24px;
  border: 1px solid var(--db-line);
  border-radius: 8px;
  background: var(--db-panel-strong);
  color: var(--db-muted);
}

@media (max-width: 820px) {
  .db-login-card {
    padding: 22px;
  }

  .db-grid,
  .db-grid.three,
  .db-panel-form,
  .db-settings-grid,
  .db-tariff-head,
  .db-metrics {
    grid-template-columns: 1fr;
  }

  .db-shell-actions {
    flex-wrap: wrap;
  }

  .db-user-chip {
    white-space: normal;
  }

  .db-acting-user {
    width: 100%;
    justify-content: flex-start;
  }

  .db-acting-user select {
    width: min(100%, 360px);
  }
}
