:root {
  color-scheme: light;
  --bg: #a4c3da;
  --surface: #ffffff;
  --surface-2: #eef3f2;
  --ink: #1c2424;
  --muted: #5c6867;
  --line: #d8dfde;
  --header-bg: #f5d0ab;
  --nav-bg: #004f81;
  --nav-active-bg: #f5d0ab;
  --accent: #004f81;
  --accent-strong: #003a60;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #15803d;
  --info: #2563eb;
  --shadow: 0 18px 50px rgba(28, 36, 36, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.runtime-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-summary {
  display: grid;
  gap: 2px;
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.session-summary strong {
  color: var(--ink);
  font-size: 13px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field-hint {
  color: var(--muted);
  font-weight: 650;
  line-height: 1.35;
}

.field-hint.warn {
  color: var(--warn);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 10px;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 79, 129, 0.22);
  outline-offset: 1px;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.api-base-field {
  width: min(340px, 38vw);
}

.main-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
  background: var(--bg);
}

.sidebar[hidden] + .content {
  grid-column: 1 / -1;
}

.sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 72px);
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: var(--nav-bg);
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #ffffff;
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.nav-item.is-active {
  background: var(--nav-active-bg);
  color: var(--nav-bg);
}

.content {
  width: min(1680px, 100%);
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.auth-shell {
  position: fixed;
  inset: 72px 0 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: min(460px, 100%);
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.auth-panel .panel-header {
  background: var(--header-bg);
}

.view-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.view-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
}

.view-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  align-items: start;
}

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

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(420px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.workspace-main,
.workspace-side {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.workspace-side {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  padding-right: 2px;
}

.panel,
.metric-tile,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  overflow: hidden;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

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

.panel-body {
  padding: 16px;
}

.scroll-panel .panel-body {
  max-height: min(52vh, 620px);
  overflow: auto;
}

.document-inventory-panel,
.link-inventory-panel,
.archive-inventory-panel,
.user-directory-panel,
.logs-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.document-inventory-panel .panel-body,
.link-inventory-panel .panel-body,
.archive-inventory-panel .panel-body,
.user-directory-panel .panel-body,
.logs-panel .panel-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.content > .workspace-main.scroll-panel {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.file-dropzone {
  display: grid;
  gap: 8px;
  border: 1px dashed #7fa7c2;
  border-radius: 8px;
  background: #f7fbfe;
  padding: 14px;
}

.file-dropzone.is-dragover {
  border-color: var(--accent);
  background: #eef7fc;
}

.file-dropzone strong {
  color: var(--ink);
}

.file-dropzone small {
  color: var(--muted);
}

.file-dropzone input[type="file"] {
  max-width: 100%;
}

.button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 800;
}

.button {
  background: var(--accent);
  color: #ffffff;
}

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

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

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

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

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

.icon-button {
  width: 38px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

.table-controls {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.filter-dropdown {
  position: relative;
  min-width: 180px;
}

.filter-dropdown summary {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.filter-dropdown summary::-webkit-details-marker {
  display: none;
}

.filter-dropdown summary::after {
  content: "v";
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.filter-dropdown[open] summary {
  border-color: var(--accent);
}

.filter-dropdown[open] summary::after {
  content: "^";
}

.filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 6;
  display: grid;
  gap: 6px;
  min-width: 100%;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 8px;
}

.filter-option {
  display: flex;
  min-height: 30px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 750;
}

.filter-option:hover {
  background: var(--surface-2);
}

.filter-option input {
  width: 14px;
  min-height: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 12px;
  font-weight: 850;
  text-align: left;
  text-transform: uppercase;
}

.sort-header span {
  color: var(--accent);
  font-size: 10px;
}

.scroll-panel th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination-page {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
}

tr.is-selected {
  background: #e8f3fa;
}

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

.short-url-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin-top: 3px;
}

.short-url-row .mono {
  overflow-wrap: anywhere;
}

.copy-url-button {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--accent);
  padding: 0;
}

.copy-url-button::before,
.copy-url-button::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 12px;
  border: 1.7px solid currentColor;
  border-radius: 2px;
  background: #ffffff;
}

.copy-url-button::before {
  top: 7px;
  left: 9px;
}

.copy-url-button::after {
  top: 5px;
  left: 7px;
}

.copy-url-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.compact-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.public {
  background: #e8f3fa;
  color: var(--nav-bg);
}

.pill.private,
.pill.restricted {
  background: #f0f2f5;
  color: #49515a;
}

.pill.active {
  background: #e7f7ec;
  color: var(--ok);
}

.pill.disabled,
.pill.expired {
  background: #fff0ed;
  color: var(--danger);
}

.pill.warn {
  background: #fff7e8;
  color: var(--warn);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.log-metadata {
  max-width: 560px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.logs-table {
  min-width: 1080px;
}

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

.metric-tile {
  padding: 16px;
}

.metric-tile strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.metric-tile span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.notice {
  padding: 12px 14px;
  color: var(--muted);
  box-shadow: none;
}

.notice strong {
  color: var(--ink);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 750;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.qr-preview {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.qr-box {
  display: grid;
  width: 180px;
  min-height: 180px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.qr-box img {
  display: block;
  width: 100%;
  height: auto;
}

.mock-qr {
  width: 160px;
  height: 160px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--accent);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(420px, calc(100vw - 36px));
  min-height: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  padding: 0 14px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

.toast.is-visible {
  min-height: 42px;
  padding-block: 11px;
  transform: translateY(0);
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: start center;
  overflow-y: auto;
  background: rgba(28, 36, 36, 0.42);
  padding: 64px 20px;
}

.modal-panel {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-panel.wide {
  width: min(1080px, 100%);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-modal-stack {
  display: grid;
  gap: 16px;
}

@media (max-width: 1120px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .workspace-side {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 940px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .runtime-controls {
    justify-content: stretch;
  }

  .session-summary {
    text-align: left;
  }

  .api-base-field {
    width: 100%;
  }

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

  .sidebar {
    position: static;
    display: flex;
    height: auto;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    width: auto;
    min-width: max-content;
  }

  .grid.two,
  .grid.three,
  .workspace-layout,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  .view-header {
    display: block;
  }

  .runtime-controls {
    display: grid;
  }

  .detail-list div,
  .bar-row,
  .pagination-row {
    grid-template-columns: 1fr;
  }

  .pagination-row {
    display: grid;
    justify-items: start;
  }
}
