:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #6b7785;
  --line: #dfe5eb;
  --brand: #1d4ed8;
  --brand-strong: #1e40af;
  --brand-soft: #e8f1ff;
  --brand-line: #d7e5ff;
  --brand-ring: #bfd7ff;
  --accent: #2f8f6b;
  --danger: #b42318;
  --warning: #b65b00;
  --radius: 6px;
  --topbar-height: 58px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-body {
  display: flex;
  min-height: 0;
  height: calc(100vh - var(--topbar-height));
}

.topbar {
  flex: 0 0 var(--topbar-height);
  height: var(--topbar-height);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.sidebar {
  flex: 0 0 248px;
  width: 248px;
  min-height: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 12px 14px;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-name {
  font-weight: 700;
  line-height: 18px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  margin-top: 0;
}

.nav {
  display: grid;
  gap: 14px;
  margin-top: 2px;
}

.nav-section {
  display: grid;
  gap: 3px;
}

.nav-section-label {
  padding: 0 10px 3px;
  color: #8a96a3;
  font-size: 12px;
  line-height: 17px;
}

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  height: 36px;
  color: #334155;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 14px;
  border: 1px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: #f6f9fb;
  color: #1f2f3f;
}

.nav-item.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: var(--brand-line);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon {
  position: relative;
  width: 18px;
  height: 18px;
  color: currentColor;
  opacity: 0.82;
}

.nav-icon::before,
.nav-icon::after {
  position: absolute;
  content: "";
  box-sizing: border-box;
}

.nav-icon-dashboard::before {
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.nav-icon-dashboard::after {
  left: 5px;
  right: 5px;
  bottom: 5px;
  height: 5px;
  border-top: 2px solid currentColor;
}

.nav-icon-partitions::before {
  inset: 3px 2px;
  border: 2px solid currentColor;
  border-radius: 999px / 45%;
}

.nav-icon-partitions::after {
  left: 3px;
  right: 3px;
  top: 7px;
  height: 5px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.nav-icon-migrations::before {
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-icon-migrations::after {
  width: 7px;
  height: 7px;
  right: 2px;
  top: 2px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.nav-icon-audit::before {
  inset: 2px 4px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.nav-icon-audit::after {
  left: 7px;
  top: 6px;
  width: 6px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.nav-icon-account::before {
  left: 6px;
  top: 3px;
  width: 6px;
  height: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.nav-icon-account::after {
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 7px;
  border: 2px solid currentColor;
  border-radius: 8px 8px 3px 3px;
}

.nav-icon-operations::before {
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.nav-icon-operations::after {
  left: 5px;
  top: 8px;
  width: 8px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -4px 0 currentColor, 0 4px 0 currentColor;
}

.nav-icon-storage::before {
  left: 3px;
  right: 3px;
  top: 2px;
  height: 5px;
  border: 2px solid currentColor;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
}

.nav-icon-storage::after {
  left: 2px;
  right: 2px;
  top: 7px;
  bottom: 2px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.ui-tabs,
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ui-tab,
.subnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: #526170;
  text-decoration: none;
  font-size: 14px;
  line-height: 20px;
}

.ui-tab:hover,
.subnav a:hover {
  color: #17212b;
  background: #f4f7fa;
}

.ui-tab.active,
.subnav a.active {
  color: #fff;
  background: var(--brand);
  font-weight: 600;
}

.ui-tabs-card {
  position: relative;
  gap: 0;
  align-items: flex-end;
  width: 100%;
  margin-bottom: 0;
  padding: 0 0 0 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.ui-tabs-card .ui-tab {
  position: relative;
  min-height: 38px;
  margin: 0 3px -1px 0;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line);
  border-radius: 8px 8px 0 0;
  background: #f8fafc;
  color: #526170;
}

.ui-tabs-card .ui-tab:hover {
  background: #fff;
  color: #17212b;
}

.ui-tabs-card .ui-tab.active {
  z-index: 2;
  border-bottom-color: var(--panel);
  background: var(--panel);
  color: var(--brand);
  box-shadow: inset 0 2px 0 var(--brand);
}

.ui-tabs-card .ui-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--panel);
}

.ui-tabs-card + .panel,
.ui-tabs-card ~ .panel:first-of-type,
.ui-tabs-card + div > .panel:first-of-type {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.page-content {
  padding: 18px 24px 28px;
}

.panel-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.account {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.account::after {
  position: absolute;
  top: 100%;
  right: 0;
  width: 180px;
  height: 10px;
  content: "";
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  visibility: hidden;
  transition:
    opacity 130ms ease,
    transform 130ms ease,
    visibility 130ms ease;
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  max-width: 220px;
  padding: 0 8px 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
}

.account-trigger:hover,
.account-trigger:focus-visible,
.account:focus-within .account-trigger {
  background: transparent;
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.account-name {
  max-width: 180px;
  overflow: hidden;
  font-size: 14px;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-caret {
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.68;
  transform: translateY(-1px) rotate(45deg);
}

.account:hover .account-caret,
.account:focus-within .account-caret {
  transform: translateY(1px) rotate(225deg);
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: 164px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(15, 35, 52, 0.16);
}

.account-menu::before {
  position: absolute;
  top: -5px;
  right: 18px;
  width: 8px;
  height: 8px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

.account-menu form {
  margin: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: #f1f5f9;
  color: #17212b;
  outline: none;
}

.account-menu .dropdown-item:hover,
.account-menu .dropdown-item:focus-visible {
  background: #f1f5f9;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 5px;
  min-height: 32px;
  padding: 0 10px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.btn:hover,
button:hover {
  background: #f6f9fb;
  border-color: #cfd8e3;
}

.btn:focus-visible,
button:focus-visible {
  outline: 2px solid var(--brand-ring);
  outline-offset: 1px;
}

.btn-primary,
button.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn-primary:hover,
button.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.btn-secondary {
  background: #fff;
}

.btn-disabled {
  color: #a3adb8;
  background: #f6f8fa;
  cursor: not-allowed;
}

.btn-disabled:hover {
  border-color: var(--line);
  background: #f6f8fa;
}

.btn-with-spinner {
  gap: 0;
}

.btn-spinner {
  box-sizing: border-box;
  flex: 0 0 0;
  width: 0;
  height: 14px;
  margin-right: 0;
  border: 0 solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  overflow: hidden;
  transform: rotate(0deg);
  transition:
    border-width 120ms ease,
    flex-basis 120ms ease,
    margin-right 120ms ease,
    opacity 120ms ease,
    width 120ms ease;
}

.btn-loading .btn-spinner {
  flex-basis: 14px;
  width: 14px;
  margin-right: 8px;
  border-width: 2px;
  opacity: 1;
  animation: btn-spinner-rotate 720ms linear infinite;
}

.btn-loading,
.btn-loading:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  cursor: progress;
}

.btn-loading:disabled {
  opacity: 1;
}

.btn-sm {
  min-height: 28px;
  padding: 0 8px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.task-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.task-card {
  min-width: 0;
  padding: 16px;
}

.task-card-head,
.task-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.task-card p {
  min-height: 42px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 21px;
}

.task-card-foot span {
  min-width: 0;
  overflow: hidden;
  color: #526170;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.form-panel {
  max-width: 560px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.storage-summary-grid,
.storage-info-grid,
.storage-cors-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.storage-summary-grid {
  margin-bottom: 18px;
}

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

.storage-form-grid .wide-field {
  grid-column: span 2;
}

.storage-cors-editor {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.storage-cors-sidebar {
  display: grid;
  gap: 12px;
  align-content: start;
}

.storage-cors-field {
  min-width: 0;
}

.storage-cors-field textarea {
  height: 100%;
  min-height: 148px;
}

.storage-cors-actions {
  margin-top: 0;
}

.storage-cors-actions .btn {
  width: 100%;
}

.storage-state-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.muted-inline {
  color: var(--muted);
  font-size: 13px;
}

.profile-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.profile-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.profile-item strong {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 24px;
  font-size: 14px;
  font-weight: 600;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
  background: #fff;
}

.compact-table table {
  min-width: 980px;
}

.runtime-log-table table {
  min-width: 1280px;
}

.runtime-log-message {
  max-width: 360px;
  white-space: normal;
  word-break: break-word;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f8fafb;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.selected-row td {
  background: #f2f8fb;
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

.status.ok {
  background: #e8f5ef;
  color: var(--accent);
}

.status.missing {
  background: #fff1e7;
  color: var(--warning);
}

.status.default {
  background: #eef2f6;
  color: #596675;
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 28px;
  gap: 10px;
  align-items: start;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 35, 52, 0.14);
  pointer-events: auto;
  animation: toast-in 180ms ease-out;
}

.toast-success {
  border-left-color: var(--accent);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-info {
  border-left-color: var(--brand);
}

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.toast-success .toast-icon {
  background: var(--accent);
}

.toast-success .toast-icon::before {
  content: "✓";
}

.toast-error .toast-icon {
  background: var(--danger);
}

.toast-error .toast-icon::before {
  content: "!";
}

.toast-warning .toast-icon {
  background: var(--warning);
}

.toast-warning .toast-icon::before {
  content: "!";
}

.toast-info .toast-icon {
  background: var(--brand);
}

.toast-info .toast-icon::before {
  content: "i";
}

.modal-lock {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  opacity: 0;
  transition: opacity 180ms ease;
}

.modal-panel {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 35, 52, 0.22);
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.modal-panel-wide {
  width: min(940px, calc(100vw - 32px));
}

.modal-open .modal-backdrop {
  opacity: 1;
}

.modal-open .modal-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.modal-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  background: #f1f5f7;
}

.modal-form {
  padding: 18px;
  margin: 0;
}

.modal-actions {
  justify-content: flex-end;
}

.toast-content {
  min-width: 0;
}

.toast-title {
  display: block;
  font-size: 14px;
  line-height: 20px;
}

.toast-message {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
  word-break: break-word;
}

.toast-close {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.toast-close:hover {
  background: #f1f5f7;
}

.toast-leaving {
  animation: toast-out 180ms ease-in forwards;
}

.alert {
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.alert.error {
  background: #fff0f0;
  color: var(--danger);
  border: 1px solid #f1b8b8;
}

.alert.success {
  background: #ecf8f2;
  color: #16623f;
  border: 1px solid #bbe3cf;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.created-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
}

.created-list span {
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  border-radius: 999px;
  color: var(--brand-strong);
  padding: 4px 8px;
  font-size: 12px;
}

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.actions-cell form {
  margin: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.migration-group + .migration-group {
  margin-top: 20px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background: #eef3f6;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-form label,
.stacked-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.login-form input,
.stacked-form input,
.stacked-form textarea,
.inline-form input,
.inline-form textarea,
.modal-field-grid input,
.modal-field-grid textarea,
.toolbar-form select,
.select-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background-color: #fff;
}

.login-form input,
.stacked-form input,
.inline-form input,
.modal-field-grid input,
.select-control {
  height: 40px;
  padding: 0 10px;
}

.select-control {
  min-width: 0;
  padding-right: 34px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7785' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.select-control:hover {
  border-color: #c5d0dc;
  background-color: #fbfdff;
}

.select-control:disabled {
  color: #96a1ad;
  cursor: not-allowed;
  background-color: #f5f7f9;
}

.select-control-sm {
  height: 32px;
  min-width: 116px;
  width: auto;
  border-radius: 5px;
  padding-left: 9px;
  padding-right: 32px;
  background-position: right 8px center;
  font-size: 13px;
  line-height: 20px;
}

.custom-select {
  display: block;
  position: relative;
  width: 100%;
  min-width: 0;
}

.custom-select-sm {
  display: inline-block;
  width: auto;
  min-width: 116px;
}

.custom-select-native {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
}

.custom-select-trigger:hover {
  border-color: #c5d0dc;
  background: #fbfdff;
}

.custom-select-trigger:focus-visible,
.custom-select-open .custom-select-trigger {
  border-color: var(--brand);
  outline: 2px solid var(--brand-ring);
  outline-offset: 0;
}

.custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-caret {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 2px;
  border-right: 1.5px solid #6b7785;
  border-bottom: 1.5px solid #6b7785;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 120ms ease;
}

.custom-select-open .custom-select-caret {
  transform: translateY(2px) rotate(225deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 70;
  box-sizing: border-box;
  min-width: 100%;
  width: max-content;
  max-height: 260px;
  max-width: var(--custom-select-max-menu-width, min(200%, calc(100vw - 32px)));
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 35, 52, 0.16);
  animation: custom-select-in 120ms ease-out;
}

.custom-select-drop-up .custom-select-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-option {
  display: flex;
  width: 100%;
  min-height: 32px;
  justify-content: flex-start;
  padding: 6px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.custom-select-option:hover,
.custom-select-option.active {
  background: #f1f5f9;
  color: #17212b;
}

.custom-select-option.selected {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.custom-select-option.selected:hover,
.custom-select-option.selected.active {
  background: #dceaff;
  color: var(--brand-strong);
}

.custom-select-option[aria-disabled="true"] {
  color: #a3adb8;
  cursor: not-allowed;
}

.custom-select-disabled .custom-select-trigger,
.custom-select-disabled .custom-select-trigger:hover {
  color: #96a1ad;
  cursor: not-allowed;
  background: #f5f7f9;
  border-color: var(--line);
}

.custom-select-sm .custom-select-trigger {
  min-height: 32px;
  border-radius: 5px;
  padding: 0 9px;
  font-size: 13px;
}

.custom-select-sm .custom-select-option {
  min-height: 30px;
  font-size: 13px;
}

.stacked-form textarea,
.modal-field-grid textarea {
  min-height: 96px;
  padding: 10px;
  resize: vertical;
}

.login-form input:focus,
.stacked-form input:focus,
.stacked-form textarea:focus,
.inline-form input:focus,
.inline-form textarea:focus,
.modal-field-grid input:focus,
.modal-field-grid textarea:focus,
.toolbar-form select:focus,
.select-control:focus {
  border-color: var(--brand);
  outline: 2px solid var(--brand-ring);
}

.login-form button {
  height: 40px;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.inline-form,
.modal-field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.runtime-log-filter {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.runtime-log-filter-panel {
  border: 0;
}

.inline-form label,
.modal-field-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.inline-form .wide-field,
.modal-field-grid .wide-field {
  grid-column: span 2;
}

.checkbox-field {
  align-content: end;
  grid-template-columns: 18px 1fr;
  display: grid !important;
  align-items: center;
  color: var(--text) !important;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.inline-actions {
  align-self: end;
  margin: 0;
}

.checkbox-field.light {
  align-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  color: var(--text) !important;
  font-size: 14px;
}

.checkbox-field.light input {
  width: 16px;
  height: 16px;
}

.field-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.toolbar-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar-form select {
  height: 32px;
  width: 220px;
  border-radius: 5px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-actions,
.pagination-size {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-size {
  margin: 0;
}

.page-size-field {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.page-size-select-control {
  background-color: #fbfcfd;
  color: #334155;
  font-weight: 500;
}

.page-size-select-control:hover,
.page-size-select-control:focus {
  background-color: #fff;
}

.custom-select-page-size .custom-select-trigger {
  background: #fbfcfd;
  color: #334155;
  font-weight: 500;
}

.custom-select-page-size .custom-select-trigger:hover,
.custom-select-page-size.custom-select-open .custom-select-trigger {
  background: #fff;
}

.discover-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.discover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fbfcfd;
}

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

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

.kv-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fbfcfd;
}

.kv-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.kv-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 20px;
}

.runtime-log-filter-form {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.runtime-log-detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.runtime-log-detail-message {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfd;
}

.runtime-log-detail-message span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.runtime-log-detail-message p {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 22px;
}

.json-block {
  max-height: 520px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #0f172a;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.rbac-workbench {
  display: grid;
  grid-template-columns: minmax(420px, 43%) minmax(0, 1fr);
  gap: 16px;
  min-height: 560px;
}

.rbac-role-pane,
.rbac-permission-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.rbac-role-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rbac-role-filter {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.rbac-role-filter label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.rbac-role-filter input,
.rbac-permission-toolbar input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.rbac-role-filter .select-control {
  height: 36px;
}

.rbac-role-filter input:focus,
.rbac-permission-toolbar input:focus {
  border-color: var(--brand);
  outline: 2px solid var(--brand-ring);
}

.rbac-role-table {
  min-height: 0;
  max-height: 560px;
  overflow: auto;
  border: 0;
  border-radius: 0;
}

.rbac-role-table table {
  min-width: 0;
  table-layout: fixed;
}

.rbac-role-table th,
.rbac-role-table td {
  padding: 10px 12px;
}

.rbac-role-table tbody tr[data-row-href] {
  cursor: pointer;
}

.rbac-role-table th:nth-child(3),
.rbac-role-table td:nth-child(3) {
  width: 74px;
}

.rbac-role-select-col,
.rbac-role-select-cell {
  width: 42px;
  padding-right: 4px !important;
  text-align: center;
}

.rbac-role-table tbody tr:hover td {
  background: #f7fafc;
}

.rbac-role-table .selected-row td {
  background: var(--brand-soft);
}

.rbac-role-selector {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  vertical-align: middle;
}

.rbac-role-selector:hover,
.rbac-role-selector:focus-visible {
  background: #eef2f6;
  outline: none;
}

.rbac-role-radio {
  display: block;
  width: 14px;
  height: 14px;
  border: 1px solid #b7c2cd;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 3px #fff;
}

.rbac-role-selector[aria-current="true"] .rbac-role-radio {
  border-color: var(--brand);
  background: var(--brand);
}

.rbac-role-link {
  display: inline-flex;
  max-width: 220px;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.rbac-role-link:hover,
.rbac-role-link[aria-current="true"] {
  color: var(--brand);
}

.rbac-role-link:focus-visible {
  outline: 2px solid var(--brand-ring);
  outline-offset: 2px;
}

.rbac-role-actions-col {
  width: 166px;
}

.rbac-role-actions-cell {
  gap: 6px;
  overflow: visible;
}

.rbac-role-pane .pagination {
  flex-wrap: wrap;
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.rbac-permission-pane {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.rbac-permission-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.rbac-permission-head h3 {
  margin: 0;
  font-size: 17px;
}

.rbac-permission-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 20px;
}

.rbac-permission-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.rbac-permission-form {
  min-height: 0;
  margin: 0;
  overflow: auto;
}

.permission-tree {
  display: grid;
  gap: 3px;
  padding: 12px 16px 16px;
}

.permission-tree-readonly {
  padding: 0;
}

.permission-tree-node {
  min-width: 0;
}

.permission-tree-node.hidden-by-search {
  display: none;
}

.permission-tree-node.no-search-match > .permission-tree-row {
  display: none;
}

.permission-tree-row {
  display: grid;
  grid-template-columns: 18px auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 6px;
  border-radius: 4px;
  background: transparent;
}

.permission-tree-row:hover {
  background: #f7fafc;
}

.permission-tree-readonly .permission-tree-row {
  grid-template-columns: 18px minmax(0, 1fr);
}

.level-0 > .permission-tree-row {
  color: #1f2f3f;
  font-weight: 600;
}

.permission-tree-check {
  display: grid;
  min-height: 20px;
  place-items: center;
}

.permission-tree-toggle,
.permission-tree-toggle-spacer {
  width: 18px;
  height: 18px;
}

.permission-tree-toggle {
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #6b7785;
}

.permission-tree-toggle:hover,
.permission-tree-toggle:focus-visible {
  background: #eef2f6;
  color: var(--text);
}

.permission-tree-toggle::before {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  content: "";
  transform: rotate(90deg);
  transition: transform 120ms ease;
}

.permission-tree-node.collapsed > .permission-tree-row .permission-tree-toggle::before {
  transform: rotate(0deg);
}

.permission-tree-node.collapsed > .permission-tree-children {
  display: none;
}

.permission-tree-check input {
  width: 16px;
  height: 16px;
}

.permission-tree-content {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.permission-tree-title {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.permission-tree-title strong {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.permission-tree-children {
  display: grid;
  gap: 3px;
  margin: 2px 0 2px 24px;
  padding-left: 12px;
  border-left: 1px solid #e4eaf0;
}

.permission-type {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

.permission-type-group {
  background: var(--brand-soft);
  color: var(--brand);
}

.permission-type-page {
  background: #eef2f6;
  color: #526170;
}

.permission-type-action {
  background: #e8f5ef;
  color: var(--accent);
}

.rbac-empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.rbac-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.ops-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  border-top: 0;
  padding-top: 0;
}

.ops-form-grid .wide-field {
  grid-column: 1 / -1;
}

@keyframes btn-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes custom-select-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    height: auto;
    min-height: var(--topbar-height);
    padding: 8px 12px;
  }

  .app-body {
    display: block;
    height: auto;
    min-height: 0;
  }

  .sidebar {
    width: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }

  .main {
    height: auto;
    overflow: visible;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
  }

  .nav-section {
    gap: 4px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .storage-summary-grid,
  .storage-info-grid,
  .storage-cors-summary,
  .storage-form-grid {
    grid-template-columns: 1fr;
  }

  .storage-form-grid .wide-field {
    grid-column: span 1;
  }

  .storage-cors-editor {
    grid-template-columns: 1fr;
  }

  .storage-cors-field textarea {
    min-height: 132px;
  }

  .panel-title {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .page-content {
    padding: 16px;
  }

  .inline-form,
  .modal-field-grid {
    grid-template-columns: 1fr;
  }

  .inline-form .wide-field,
  .modal-field-grid .wide-field {
    grid-column: span 1;
  }

  .toolbar-form {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-form select {
    width: 100%;
  }

  .pagination,
  .pagination-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
