:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #edf2ef;
  --border: #d5ddd9;
  --border-strong: #aab9b3;
  --text: #18211e;
  --muted: #65736e;
  --accent: #0b6b57;
  --accent-hover: #075544;
  --accent-soft: #dff2eb;
  --info: #246b9b;
  --info-soft: #e4f1f8;
  --warning: #9a6100;
  --warning-soft: #fff1cc;
  --danger: #b42318;
  --danger-soft: #fee9e7;
  --success: #16734d;
  --success-soft: #e1f4e9;
  --shadow: 0 12px 36px rgba(24, 33, 30, 0.14);
  --sidebar-width: 224px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf2ef;
}

.login-panel {
  width: min(400px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--border);
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-heading {
  margin: 24px 0 18px;
}

.login-heading p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.login-heading h1 {
  margin: 0;
  font-size: 24px;
}

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

.login-form input {
  min-height: 44px;
}

.login-submit {
  min-height: 44px;
  margin-top: 4px;
  justify-content: center;
}

.form-error {
  margin: 0;
  padding: 9px 10px;
  color: #752018;
  background: var(--danger-soft);
  border: 1px solid #efb5af;
  border-radius: 5px;
  font-size: 12px;
}

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

button,
a,
input,
select,
textarea,
summary {
  outline-offset: 2px;
}

:focus-visible {
  outline: 3px solid var(--accent);
}

a {
  color: var(--accent);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.clipboard-fallback {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  font-size: 19px;
  font-weight: 750;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #43504c;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.nav-list a:hover {
  color: var(--text);
  background: var(--surface-alt);
}

.nav-list a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-count {
  min-width: 22px;
  margin-left: auto;
  padding: 2px 6px;
  color: #fff;
  background: var(--danger);
  border-radius: 10px;
  text-align: center;
  font-size: 11px;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px 32px;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding: 12px 2px;
  border-top: 1px solid var(--border);
}

.sidebar-user + .sidebar-status {
  margin-top: 0;
}

.user-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}

.user-avatar svg {
  width: 16px;
  height: 16px;
}

.sidebar-user-text {
  min-width: 0;
}

.sidebar-user-text strong,
.sidebar-user-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text strong {
  font-size: 12px;
}

.sidebar-user-text small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.sidebar-user .icon-button {
  width: 32px;
  height: 32px;
}

.sidebar-status small,
.sidebar-status strong {
  display: block;
}

.sidebar-status small {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-status strong {
  margin-top: 2px;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.status-dot.is-danger {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.status-dot.is-muted {
  background: #84908c;
  box-shadow: 0 0 0 3px #e8ecea;
}

.main-column {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 72px;
  gap: 14px;
  padding: 10px 28px;
  background: rgba(244, 246, 245, 0.96);
  border-bottom: 1px solid var(--border);
}

.page-heading {
  min-width: 0;
}

.page-heading p,
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.page-heading h1,
.dialog-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.refresh-time {
  color: var(--muted);
  font-size: 12px;
}

#workspace {
  width: min(1480px, 100%);
  min-height: calc(100vh - 72px);
  padding: 24px 28px 48px;
  margin: 0 auto;
}

.icon-button.menu-button {
  display: none;
}

.button,
.icon-button {
  border: 1px solid transparent;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  gap: 7px;
  padding: 8px 13px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

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

.button.secondary:hover {
  background: var(--surface-alt);
}

.button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button.warning {
  color: #fff;
  background: var(--warning);
  border-color: var(--warning);
}

.button.compact {
  min-height: 34px;
  padding: 6px 10px;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: transparent;
  border-radius: 5px;
}

.icon-button:hover {
  background: var(--surface-alt);
}

.page-tools,
.section-header,
.actions,
.filter-bar,
.detail-actions,
.tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.page-tools {
  justify-content: space-between;
  margin-bottom: 18px;
}

.spacer {
  height: 14px;
}

.panel-filter {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-body {
  padding: 16px;
}

.compact-filter,
.compact-heading {
  margin-bottom: 8px;
}

.page-filter {
  margin-bottom: 16px;
}

.page-tools h2,
.section-header h2,
.section-header h3 {
  margin: 0;
  font-size: 17px;
}

.page-tools p,
.section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.metric-card.is-warning {
  border-left: 4px solid var(--warning);
}

.metric-card.is-danger {
  border-left: 4px solid var(--danger);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.panel > .section-header {
  min-height: 58px;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

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

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

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8faf9;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f8faf9;
}

.clickable-row {
  cursor: pointer;
}

.primary-cell {
  color: var(--text);
  font-weight: 700;
}

.secondary-text,
.mono-secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.mono,
.mono-secondary,
pre,
code {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.mono {
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #43504c;
  background: #e8ecea;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: #b9dfc8;
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #ead18d;
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f3b8b2;
}

.badge.info {
  color: var(--info);
  background: var(--info-soft);
  border-color: #b6d8ea;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.empty-state,
.error-state,
.loading-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 40px 20px;
  text-align: center;
}

.empty-state strong,
.error-state strong {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
}

.empty-state p,
.error-state p {
  max-width: 520px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.is-spinning {
  animation: spin 0.75s linear infinite;
}

.search-field {
  position: relative;
  min-width: min(300px, 100%);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  padding-left: 34px;
}

input,
select,
textarea {
  min-height: 38px;
  max-width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

label {
  color: #394641;
  font-size: 13px;
  font-weight: 650;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field small {
  color: var(--muted);
  font-size: 11px;
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.check-field {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
}

.check-field input {
  min-height: 0;
}

.ota-group {
  margin: 16px 0;
}

.ota-group + .ota-group {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.debug-command-params {
  min-height: 180px;
  font-family: var(--mono);
  line-height: 1.5;
  resize: vertical;
}

.debug-command-result {
  margin-top: 16px;
}

.live-refresh {
  padding: 0 4px;
  white-space: nowrap;
}

.batch-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.batch-toolbar .secondary-text {
  margin: 0;
  white-space: nowrap;
}

.compact-check {
  min-height: 32px;
  white-space: nowrap;
}

.alert-select,
.batch-toolbar input[type="checkbox"],
.live-refresh input[type="checkbox"] {
  min-height: 0;
}

.retention-settings {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.retention-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.2fr) minmax(190px, 1fr) minmax(190px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

.retention-row:last-child {
  border-bottom: 0;
}

.capture-policy-row {
  grid-template-columns: repeat(3, minmax(170px, 1fr));
}

.capture-policy-row .retention-heading {
  grid-column: 1 / -1;
}

.retention-heading strong,
.retention-heading small {
  display: block;
}

.retention-heading small,
.retention-status {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.retention-limit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.8fr);
  align-items: center;
  gap: 8px;
}

.retention-limit > span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.retention-limit input[type="checkbox"] {
  min-height: 0;
}

.number-with-unit {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.number-with-unit input {
  width: 100%;
}

.retention-status {
  grid-column: 2 / -1;
  margin-top: -6px;
}

.retention-status.is-warning {
  color: var(--warning);
  font-weight: 700;
}

.retention-database,
.preview-result,
.cleanup-result-section {
  margin-top: 18px;
}

.retention-database h3,
.preview-result h3,
.cleanup-result-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.database-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 10px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.database-metrics > div {
  min-width: 0;
  padding: 11px 12px;
  background: var(--surface);
}

.database-metrics span,
.database-metrics strong {
  display: block;
}

.database-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.database-metrics strong {
  margin-top: 4px;
  font-size: 15px;
}

.cleanup-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin: 0;
}

.cleanup-counts > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: var(--surface-alt);
  border-radius: 5px;
}

.cleanup-counts dt {
  color: var(--muted);
  font-size: 11px;
}

.cleanup-counts dd {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
}

.retention-empty {
  margin: 0;
}

.conflict-list {
  margin: 14px 0 0;
  padding-left: 22px;
  color: var(--text);
  font-size: 13px;
}

.user-actions {
  flex-wrap: nowrap;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-header > div:nth-child(2) {
  min-width: 0;
}

.detail-header h2 {
  margin: 0;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.detail-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.detail-actions {
  justify-content: flex-end;
  margin-left: auto;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.summary-strip > div {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface);
}

.summary-strip span,
.definition-grid dt {
  color: var(--muted);
  font-size: 11px;
}

.summary-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 7px;
  padding: 16px;
}

.slot-tile {
  position: relative;
  min-height: 68px;
  padding: 9px;
  color: var(--text);
  background: #f8faf9;
  border: 1px solid var(--border);
  border-left: 4px solid #99a5a0;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
}

.slot-tile:hover {
  border-color: var(--accent);
}

.slot-tile.ready {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.slot-tile.failed {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.slot-tile.bound {
  box-shadow: inset 0 0 0 1px var(--info);
}

.slot-tile.active::after {
  content: "当前";
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 1px 4px;
  color: #fff;
  background: var(--accent);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

.slot-tile strong,
.slot-tile small {
  display: block;
}

.slot-tile strong {
  font-size: 13px;
}

.slot-tile small {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

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

.definition-grid div {
  min-width: 0;
}

.definition-grid dt {
  margin: 0 0 4px;
}

.definition-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  color: #31554a;
  background: var(--accent-soft);
  border: 1px solid #b7ddcf;
  border-radius: 5px;
  font-size: 12px;
}

.callout.warning {
  color: #664300;
  background: var(--warning-soft);
  border-color: #e6ca7a;
}

.callout.danger {
  color: #752018;
  background: var(--danger-soft);
  border-color: #efb5af;
}

.tabs {
  gap: 2px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  min-height: 38px;
  padding: 8px 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-weight: 650;
}

.tab-button.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.alert-row.is-acknowledged {
  opacity: 0.62;
}

.context-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.context-chip {
  max-width: 240px;
  padding: 3px 6px;
  color: #4b5853;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
}

.json-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.json-details summary {
  padding: 9px 11px;
  cursor: pointer;
  color: #3f4c47;
  font-size: 12px;
  font-weight: 700;
}

.json-details pre,
.log-output {
  max-height: 420px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: #24302c;
  background: #f3f6f4;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.55;
}

.details-actions {
  display: flex;
  justify-content: flex-end;
  padding: 9px 11px;
  border-top: 1px solid var(--border);
}

.selection-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.65fr);
  gap: 16px;
}

.selection-list,
.selected-list {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.selection-item,
.selected-item {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 9px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.selection-item:last-child,
.selected-item:last-child {
  border-bottom: 0;
}

.selection-item input {
  min-height: 0;
}

.selected-item > span {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.order-actions {
  display: flex;
  gap: 3px;
}

.order-actions button {
  width: 28px;
  height: 28px;
}

dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(86vh, 900px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

dialog.wide {
  width: min(980px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(24, 33, 30, 0.48);
}

.dialog-shell {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.dialog-header > div {
  min-width: 0;
  flex: 1;
}

.dialog-body {
  padding: 18px;
  overflow: auto;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

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

.toast {
  padding: 11px 13px;
  color: #fff;
  background: #24302c;
  border-radius: 5px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.error {
  background: #8e2017;
}

.sidebar-backdrop {
  position: fixed;
  z-index: 25;
  inset: 0;
  background: rgba(24, 33, 30, 0.45);
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 880px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  .selection-layout {
    grid-template-columns: 1fr;
  }

  .retention-row {
    grid-template-columns: 1fr 1fr;
  }

  .retention-heading,
  .retention-status {
    grid-column: 1 / -1;
  }

  .retention-status {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .login-view {
    padding: 14px;
  }

  .login-panel {
    padding: 24px 20px;
  }
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(280px, 86vw);
    transition: transform 160ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .icon-button.menu-button {
    display: inline-grid;
  }

  .button,
  .button.compact,
  .icon-button,
  .nav-list a {
    min-height: 44px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .topbar {
    position: sticky;
    padding: 9px 14px;
  }

  .topbar-actions {
    position: absolute;
    right: 14px;
  }

  .page-heading {
    padding-right: 44px;
  }

  .page-heading h1 {
    font-size: 17px;
  }

  .page-heading p,
  .refresh-time {
    display: none;
  }

  #workspace {
    padding: 18px 14px 40px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .detail-header {
    flex-wrap: wrap;
  }

  .detail-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

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

  .form-grid,
  .definition-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .retention-row,
  .database-metrics,
  .cleanup-counts {
    grid-template-columns: 1fr;
  }

  .retention-heading,
  .retention-status {
    grid-column: auto;
  }

  .retention-limit {
    grid-template-columns: minmax(0, 1fr) minmax(125px, 0.8fr);
  }

  .filter-bar > *,
  .search-field {
    width: 100%;
  }

  .filter-bar select,
  .filter-bar input {
    width: 100%;
  }

  dialog {
    width: 100vw;
    max-width: none;
    max-height: 94vh;
    margin: auto 0 0;
    border-radius: 7px 7px 0 0;
  }
}

@media (max-width: 420px) {
  .topbar-actions .button span {
    display: none;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

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

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

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