:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #e7eef7;
  background: #0b161d;
  --panel: #12222e;
  --border: #2d405d;
  --muted: #9fb0c3;
  --gold: #c5a45d;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; border: 1px solid #48617d; border-radius: 7px; }
button, .button { cursor: pointer; background: transparent; padding: 5px 13px; font-weight: 500; white-space: nowrap; min-height: 32px; }
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: 1px solid #48617d; border-radius: 7px; }
button:hover, .button:hover { background: #203547; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--gold); color: #15212b; border-color: #d8bd7d; font-weight: 650; }
.primary:hover { background: #d8b975; }
.danger { color: #ffb4b4; background: #45232c; border-color: #79414b; }
.danger:hover { background: #61303b; }
input, select { background: #0b1720; min-height: 32px; padding: 5px 11px; min-width: 0; max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: #ffb4b4; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 25px; line-height: 1.2; font-weight: 550; margin: 5px 0 0; letter-spacing: -.5px; }
h2 { font-size: 19px; font-weight: 550; margin: 0; }
small { font-size: 12px; line-height: 1.5; color: var(--muted); }
.muted { color: var(--muted); }
.shell { max-width: 1280px; margin: 0 auto; padding: 27px 28px 32px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.brand { font-size: 11px; color: var(--muted); letter-spacing: .7px; }
.user-actions { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.user-actions form { margin: 0; }
.toolbar { display: flex; margin-bottom: 14px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #101f2c; color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
thead th:first-child { border-top-left-radius: 10px; }
thead th:last-child { border-top-right-radius: 10px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1a2c3c; }
td { overflow-wrap: anywhere; }
.domain-id { font-weight: 550; }
.cell-secondary { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; font-weight: 400; }
.row-action { width: 1%; text-align: right; }
.badge { display: inline-block; font-size: 11px; border: 1px solid var(--border); border-radius: 5px; padding: 3px 7px; color: var(--muted); white-space: nowrap; }
.badge.visible { color: #74e0d0; border-color: #315653; background: #153436; }
.empty { text-align: center; height: 140px; color: var(--muted); }
.message { border: 1px solid var(--border); background: #1a2c3c; border-radius: 7px; padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere; }
.error { color: #ffb4b4; background: #45232c; border-color: #79414b; }
.error-text { color: #ffb4b4; }
.success { color: #bce8dc; background: #153436; border-color: #315653; }
label { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 12px; font-weight: 500; }
label input, label select { width: 100%; color: #e7eef7; font-size: 14px; font-weight: 400; }
.login-shell { max-width: 520px; padding-top: 70px; }
.login { padding: 24px; }
.login h2 { margin-bottom: 18px; }
.login button { margin-top: 8px; }
dialog { color: inherit; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(740px, calc(100% - 32px)); max-height: calc(100dvh - 48px); box-shadow: 0 16px 60px #0007; }
dialog::backdrop { background: #030b12bc; }
dialog[open]:not(:modal) { position: relative; margin: 24px auto; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 10px 24px 18px; }
.dialog-body > p:first-child { margin-top: 10px; }
fieldset { padding: 0; border: 0; margin: 18px 0 0; min-width: 0; }
legend { padding: 0 0 6px; color: #e7eef7; font-size: 13px; font-weight: 550; border-bottom: 1px solid var(--border); width: 100%; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
.field-grid label { margin: 10px 0 2px; }
.help { font-size: 12px; margin: 18px 0 0; }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; border-top: 1px solid var(--border); }
.save-actions { display: flex; gap: 8px; margin-left: auto; }
#delete-confirmation { width: min(480px, calc(100% - 32px)); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 600px) {
  .shell { padding: 20px 14px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .user-actions { width: 100%; justify-content: space-between; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .dialog-heading, .dialog-body, .dialog-actions { padding-left: 16px; padding-right: 16px; }
  th, td { padding: 12px 10px; }
  h1 { font-size: 23px; }
  dialog { max-height: calc(100dvh - 24px); }
}
/* Keep primary actions visible while the metadata fields scroll. */
dialog { overflow: hidden; }
dialog > form { display: flex; flex-direction: column; max-height: calc(100dvh - 50px); }
.dialog-heading, .dialog-actions { flex: none; }
.dialog-body { overflow-y: auto; min-height: 0; }
@media (max-width: 600px) { dialog > form { max-height: calc(100dvh - 26px); } }

.owner-image-upload { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 18px; margin-top: 14px; }
.owner-image-upload > label { flex: 1; min-width: 0; }
.owner-image-preview { width: 200px; height: 200px; flex: none; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #0b161d; }
.owner-image-preview > img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.owner-image-preview [data-owner-placeholder] { padding: 14px; color: var(--muted); font-size: 12px; text-align: center; }
.owner-image-preview [hidden] { display: none; }
@media (max-width: 600px) { .owner-image-upload { flex-direction: column; } }

.owner-image-upload { flex-wrap: wrap; }
.owner-image-preview.is-cropping { width: min(100%, 320px); height: 320px; display: block; border-radius: 0; }
.owner-image-preview.is-cropping > img { max-width: 100%; object-fit: contain; }
.owner-crop-controls { flex-basis: 100%; }
.owner-crop-controls[hidden] { display: none; }
.owner-crop-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.owner-image-preview .cropper-bg { background-image: conic-gradient(#26333d 25%, #18232b 0 50%, #26333d 0 75%, #18232b 0); background-size: 16px 16px; }


.owner-image-upload[data-owner-drop] { border: 1px dashed var(--border); border-radius: 8px; padding: 12px; }
.owner-drop-hint { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 12px; }
.owner-image-upload.is-dragover { border-color: var(--gold); background: #203547; }
