@import url("https://fonts.googleapis.com/css2?family=PT+Sans:wght@400;700&display=swap");

:root {
  --blue-900: #1f2f77;
  --blue-800: #2b3e8f;
  --blue-600: #3b53b6;
  --blue-100: #e7ecfb;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1b1f2a;
  --muted: #6c7587;
  --border: #e1e6f0;
  --desktop-page-gutter: 24px;
  --desktop-shell-max: 1480px;
  --admin-shell-max: 1280px;
  --desktop-card-padding-y: 18px;
  --desktop-card-padding-x: 20px;
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.native-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  font-family: "PT Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: scroll;
}

.app {
  min-height: 100vh;
  width: 100%;
}

.app.single .topbar {
  display: none;
}

.single-content {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: 100%;
  padding: 32px var(--desktop-page-gutter);
}

.login-card,
.admin-card {
  width: min(var(--desktop-shell-max), 100%);
  border-radius: 18px;
  padding: 28px 32px;
}

.admin-card {
  width: min(var(--admin-shell-max), 100%);
  max-width: var(--admin-shell-max);
  margin-inline: auto;
  justify-self: center;
}

.login-card {
  max-width: 420px;
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.login-bar {
  background: linear-gradient(90deg, var(--blue-900), var(--blue-800));
  color: #fff;
  width: min(100%, 300px);
  justify-self: center;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  text-align: center;
}

.login-card select,
.login-card button {
  width: min(100%, 260px);
  justify-self: center;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

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

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

.auth-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.auth-note-secondary {
  font-size: 11px;
  line-height: 1.45;
  max-width: 320px;
  justify-self: center;
}

.legal-note {
  margin: 0;
  font-size: 11px;
  color: #9aa3b2;
  text-align: center;
}
.card {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: var(--desktop-card-padding-y) var(--desktop-card-padding-x);
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.05);
}

.card.login-card {
  width: min(100%, 420px);
  max-width: 420px;
  margin-inline: auto;
  justify-self: center;
}

.card.admin-card {
  width: min(var(--admin-shell-max), 100%);
  max-width: var(--admin-shell-max);
  margin-inline: auto;
  justify-self: center;
}

.card.hero {
  background: linear-gradient(90deg, var(--blue-800), #3c54b8);
  color: #fff;
}

.card h1,
.card h2 {
  margin: 0 0 6px;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.card.hero p {
  color: rgba(255, 255, 255, 0.8);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.admin-wide-card {
  grid-column: 1 / -1;
}

.admin-card h1 {
  font-size: 22px;
}

.admin-card h2 {
  font-size: 18px;
}

.admin-card .form-grid input,
.admin-card .form-grid select {
  padding: 12px 14px;
  font-size: 15px;
}

.admin-card .btn {
  padding: 12px 18px;
}

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

.form-grid > * {
  min-width: 0;
}

.form-grid hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.chapter-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f9fbff;
}

.chapter-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.chapter-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.form-message {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.role-help {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.role-help strong {
  color: var(--text);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
}

.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn.primary {
  background: var(--blue-900);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--blue-900);
}

.btn.danger {
  background: #b42318;
  color: #fff;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.export-status {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 0 2px;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.admin-job-progress,
.generated-mail-block {
  grid-column: 1 / -1;
}

.admin-job-progress {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(231, 236, 251, 0.55), rgba(255, 255, 255, 0.98));
}

.admin-job-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(31, 47, 119, 0.12);
  overflow: hidden;
  border: 1px solid rgba(59, 83, 182, 0.14);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-600));
  transition: width 0.2s ease;
}

.progress-fill.danger {
  background: linear-gradient(90deg, #8b2a34, #d45b66);
}

.admin-job-progress-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.generated-mail-block {
  display: grid;
  gap: 8px;
}

.generated-mail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.generated-mail-actions .btn {
  flex: 1 1 180px;
}

.generated-mail-block textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: "PT Sans", "Segoe UI", sans-serif;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.tenant-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(31, 47, 119, 0.08);
  color: var(--blue-900);
}

.tenant-status-badge.soft-deleted {
  background: rgba(196, 78, 89, 0.12);
  color: #8b2a34;
}

.tenant-hard-delete-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tenant-hard-delete-note {
  font-size: 11px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .generated-mail-actions .btn {
    width: 100%;
  }
}

.user-shell {
  width: min(var(--desktop-shell-max), calc(100vw - (var(--desktop-page-gutter) * 2)));
  max-width: var(--desktop-shell-max);
  min-width: 0;
  margin: 0 auto;
  align-self: start;
}

.user-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--blue-900);
  color: #fff;
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 55, 0.12);
  margin-bottom: 20px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.user-topbar .brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  min-width: 0;
}

.version-text {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.tenant-pill {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  max-width: 100%;
}

.user-topbar .brand:focus-visible,
.tenant-pill:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 3px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}

.user-display-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
}

.user-email {
  font-size: 14px;
  opacity: 0.9;
  text-align: right;
}

.user-role {
  font-size: 13px;
  opacity: 0.85;
  text-align: right;
}

.user-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.user-layout.tenant-picker-mode {
  grid-template-columns: minmax(0, 1fr);
}

.user-main {
  align-self: start;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.user-layout.tenant-picker-mode .user-main {
  display: flex;
  justify-content: center;
}

.sidebar {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.04);
  height: fit-content;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.nav-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.nav-item {
  display: flex;
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 8px;
  text-decoration: none;
}

.nav-item.active {
  background: var(--blue-100);
  color: var(--blue-900);
}

.section-hidden {
  display: none;
}

.tenant-picker-card {
  width: min(760px, 100%);
  max-width: 760px;
  margin: 0 auto;
}

.tenant-picker-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.tenant-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbff;
}

.tenant-picker-copy {
  min-width: 0;
}

.tenant-picker-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-900);
}

.tenant-picker-role {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

@media (max-width: 720px) {
  .tenant-picker-item {
    flex-direction: column;
    align-items: stretch;
  }

  .tenant-picker-item .btn {
    width: 100%;
  }
}

.nav-item.active,
.nav-item:hover {
  background: var(--blue-100);
  color: var(--blue-900);
}

.user-main .card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  margin-top: 10px;
}

.stat-card {
  background: #f7f9ff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.stat-grid-compact .stat-card {
  padding: 9px 12px;
  min-height: 78px;
  border-radius: 12px;
}

.stat-card-storage {
  display: grid;
  gap: 5px;
}

.stat-card-double {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: 64px auto;
  align-items: baseline;
  gap: 8px;
}

.stat-grid-compact .stat-row .stat-label,
.stat-grid-compact .stat-row .stat-value {
  margin: 0;
}

.stat-grid-compact .stat-row .stat-label {
  text-align: left;
  width: 64px;
}

.stat-grid-compact .stat-row .stat-value {
  text-align: left;
  justify-self: start;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-grid-compact .stat-label {
  font-size: 10px;
  margin-bottom: 3px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue-900);
}

.stat-grid-compact .stat-value {
  font-size: 18px;
  line-height: 1.05;
}

.stat-value-storage {
  font-size: 24px;
}

.stat-grid-compact .stat-value-storage {
  font-size: 17px;
}

.storage-plan {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-900);
}

.stat-grid-compact .storage-plan {
  font-size: 11px;
}

.storage-meta,
.storage-free {
  font-size: 12px;
  color: var(--muted);
}

.stat-grid-compact .storage-meta,
.stat-grid-compact .storage-free {
  font-size: 11px;
  line-height: 1.25;
}

.storage-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(31, 47, 119, 0.12);
  overflow: hidden;
  border: 1px solid rgba(59, 83, 182, 0.14);
}

.stat-grid-compact .storage-bar {
  height: 8px;
}

.storage-bar-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-600));
  transition: width 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.card-header > * {
  min-width: 0;
}

.search-grid {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.search-advanced {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

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

.date-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.date-field input {
  width: 100%;
}

.search-meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.search-meta-summary,
.search-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-meta,
.search-meta-summary,
.search-pagination,
.search-pagination-row,
.search-pagination-nav,
.search-pagination-jump,
.search-pagination-size,
.search-results-viewport,
.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.search-results-viewport {
  margin-top: 12px;
  min-height: 420px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.search-pagination {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.search-pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.search-pagination-row-main {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.search-pagination-row-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.search-pagination-label {
  font-size: 12px;
  color: var(--muted);
  text-align: left;
}

.search-pagination-nav,
.search-pagination-size,
.search-pagination-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.search-pagination-nav {
  flex-wrap: nowrap;
}

.search-pagination-nav-start {
  justify-content: flex-start;
}

.search-pagination-nav-end {
  justify-content: flex-end;
}

.search-pagination-jump-label {
  font-size: 12px;
  color: var(--muted);
}

.search-pagination-jump-controls {
  display: flex;
  align-items: center;
  gap: 0;
}

.search-pagination-jump-controls input {
  width: 60px;
  min-width: 0;
  padding: 6px 7px;
  font-size: 11px;
  text-align: center;
}

.search-pagination-size {
  font-size: 12px;
  color: var(--muted);
  justify-content: flex-end;
}

.search-pagination-size-label {
  font-size: 12px;
  color: var(--muted);
}

.search-pagination-size select {
  width: 72px;
  min-width: 0;
  padding: 6px 24px 6px 8px;
  font-size: 11px;
}

.search-pagination .btn {
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.form-message:empty {
  display: none;
}

.form-message[data-empty="true"] {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

#search-table {
  table-layout: auto;
}

#search-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8faff;
}

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

.data-table th {
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  background: #fafbff;
}

.data-table td.actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
  width: 1%;
  white-space: nowrap;
}

#search-table td.actions {
  border-bottom-color: transparent;
  gap: 3px;
  min-width: 0;
  justify-content: flex-start;
}

#search-table td.actions .btn {
  padding: 3px 5px;
  font-size: 10px;
  border-radius: 8px;
  white-space: nowrap;
}

#search-table td,
#search-table th {
  padding: 7px 8px;
}

#search-table th:nth-child(1),
#search-table td:nth-child(1) {
  width: 20%;
}

#search-table th:nth-child(2),
#search-table td:nth-child(2) {
  width: 9%;
}

#search-table td:nth-child(3),
#search-table th:nth-child(3),
#search-table tr.search-result-row td[data-label="Категорија"] {
    width: 24%;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

#search-table th:nth-child(4),
#search-table td:nth-child(4) {
  width: 8%;
}

#search-table th:nth-child(5),
#search-table td:nth-child(5) {
  width: 9%;
}

#search-table th:nth-child(6),
#search-table td:nth-child(6) {
  width: 10%;
}

#search-table th:nth-child(7),
#search-table td:nth-child(7) {
  width: 20%;
}

#search-table td:nth-child(1) {
  overflow-wrap: anywhere;
}

.search-detail-row td {
  background: #fbfcff;
  padding-top: 0;
}

.search-detail-panel {
  margin: 8px 0 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(231, 236, 251, 0.45), rgba(255, 255, 255, 0.98));
}

.search-detail-header {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.search-detail-subtitle,
.search-detail-status {
  font-size: 13px;
  color: var(--muted);
}

.search-detail-table-wrap {
  margin-top: 0;
}

.search-detail-table th,
.search-detail-table td {
  font-size: 13px;
}

.search-preview-frame {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.image-preview-shell {
  display: grid;
  gap: 10px;
}

.image-preview-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-preview-toolbar .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.image-preview-hint {
  font-size: 12px;
  color: var(--muted);
}

.image-preview-viewport {
  position: relative;
  width: 100%;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(231, 236, 251, 0.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(231, 236, 251, 0.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(231, 236, 251, 0.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(231, 236, 251, 0.45) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  touch-action: none;
  cursor: default;
}

.image-preview-viewport.is-pannable {
  cursor: grab;
}

.image-preview-viewport.dragging {
  cursor: grabbing;
}

.image-preview-media {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}

.image-preview-shell-mobile .image-preview-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-preview-shell-mobile .image-preview-media {
  position: static;
  top: auto;
  left: auto;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
}

.mobile-image-preview-shell {
  display: grid;
  gap: 10px;
}

.mobile-image-preview-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mobile-image-preview-actions .btn {
  width: 100%;
}

.mobile-image-preview-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.mobile-image-preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 60vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}

.mobile-image-preview-media {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(60vh - 16px);
  height: auto;
  object-fit: contain;
}

.history-panel {
  margin-top: 16px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  padding: 12px 16px;
  background: #fafbff;
}

.preview-panel {
  margin-top: 16px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  padding: 12px 16px;
  background: #fafbff;
}

.preview-panel iframe {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.history-row:last-child {
  border-bottom: none;
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  width: 100%;
  max-width: 100%;
}

@media (max-width: 900px) {
  .user-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

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

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

  .search-advanced {
    grid-template-columns: 1fr;
  }

  .date-range {
    grid-template-columns: 1fr;
  }

  .search-meta,
  .search-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .search-pagination-size {
    justify-content: center;
  }

  .desktop-only-nav,
  .desktop-only-section {
    display: none !important;
  }

  .search-results-viewport {
    min-height: 380px;
    max-height: 380px;
  }

  #search-table td.actions {
    flex-wrap: wrap;
  }

  .search-preview-frame {
    min-height: 360px;
  }

  .image-preview-viewport {
    min-height: 360px;
  }
}

.file-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.upload-mobile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.upload-bulk-controls {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(170px, 0.95fr) minmax(240px, 1.4fr) minmax(140px, 0.75fr) minmax(160px, 180px);
  gap: 10px;
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
}

.upload-bulk-controls select {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-bulk-controls #upload-chapter,
.upload-bulk-controls #upload-category {
  max-width: 100%;
}

.upload-bulk-controls .btn,
.file-picker .btn,
.upload-actions .btn {
  min-height: 42px;
}

#section-upload .upload-note {
  margin-bottom: 14px;
}

.upload-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  grid-column: 1 / -1;
}

.upload-selection-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
}

.upload-selection-summary-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(231, 236, 251, 0.28);
  min-width: 0;
}

.upload-selection-summary-label {
  font-size: 12px;
  color: var(--muted);
}

.upload-selection-summary-value {
  font-size: 16px;
  line-height: 1.2;
  color: var(--blue-900);
}

.file-list {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.upload-file-list {
  display: grid;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 6px 4px 0;
  align-content: start;
}

.upload-file-list-items {
  display: grid;
  gap: 8px;
  align-content: start;
}

.upload-file-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.upload-file-item:hover {
  border-color: rgba(43, 62, 143, 0.24);
  background: #fbfcff;
}

.upload-file-item.active {
  border-color: rgba(43, 62, 143, 0.32);
  background: rgba(231, 236, 251, 0.6);
  box-shadow: inset 0 0 0 1px rgba(43, 62, 143, 0.06);
}

.upload-file-name {
  font-weight: 700;
  color: var(--blue-900);
  word-break: break-word;
}

.upload-file-meta {
  font-size: 12px;
  color: var(--muted);
}

.upload-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(231, 236, 251, 0.32);
}

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

.field-stack > span {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-900);
}

.upload-editor-help {
  font-size: 12px;
  color: var(--muted);
}

.upload-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1.45fr) minmax(140px, 0.8fr);
  gap: 10px;
}

.upload-editor-grid > .field-stack {
  min-width: 0;
}

.upload-editor-grid select,
.upload-editor-grid input {
  width: 100%;
  min-width: 0;
}

.upload-capture-preview {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(231, 236, 251, 0.35);
}

.upload-capture-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.upload-capture-preview-header strong {
  color: var(--blue-900);
}

.upload-capture-preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: 460px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(31, 47, 119, 0.08), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(59, 83, 182, 0.14);
}

.upload-capture-preview-frame img {
  max-width: 100%;
  max-height: 440px;
  object-fit: contain;
  display: block;
}

.upload-capture-preview-frame iframe {
  width: 100%;
  min-height: 440px;
  border: 0;
  background: #fff;
}

.upload-capture-preview-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.upload-progress {
  display: grid;
  gap: 8px;
  width: 100%;
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(231, 236, 251, 0.65), rgba(255, 255, 255, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.upload-progress-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue-900);
  line-height: 1;
}

.upload-progress-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(31, 47, 119, 0.12);
  overflow: hidden;
  border: 1px solid rgba(59, 83, 182, 0.14);
}

.upload-progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-600));
  transition: width 0.12s ease;
}

.upload-progress-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.upload-summary,
.upload-failed-list {
  font-size: 13px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

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

.upload-summary-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(231, 236, 251, 0.4);
  line-height: 1.35;
}

.upload-summary,
.upload-failed,
#upload-message {
  grid-column: 1 / -1;
}

.upload-failed {
  font-size: 13px;
  color: var(--muted);
}

.upload-failed summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--blue-900);
}

.upload-failed-list {
  margin-top: 8px;
}

.upload-failed-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 980px) {
  .upload-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .upload-summary {
    grid-template-columns: 1fr;
  }

  .upload-capture-preview-frame {
    min-height: 220px;
  }
}

@media (max-width: 640px) {
  .single-content {
    padding: 12px;
    place-items: stretch;
  }

  .login-card,
  .admin-card {
    width: 100%;
    max-width: none;
    border-radius: 14px;
    padding: 18px 16px;
  }

  .user-shell {
    width: 100%;
    min-width: 0;
  }

  .user-topbar {
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 14px;
  }

  .user-topbar .brand,
  .tenant-pill,
  .user-actions,
  .user-identity,
  .user-display-name,
  .user-email,
  .user-actions .btn {
    width: 100%;
  }

  .tenant-pill {
    text-align: center;
  }

  .user-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .user-identity {
    align-items: flex-start;
  }

  .user-email {
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
    text-align: left;
  }

  .user-role {
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
  }

  .user-display-name {
    text-align: left;
  }

  .user-layout {
    gap: 14px;
  }

  .sidebar {
    padding: 12px;
  }

  .nav-title {
    margin-bottom: 8px;
  }

  .nav-item {
    margin-bottom: 6px;
    padding: 11px 12px;
  }

  .card,
  .user-main .card {
    border-radius: 14px;
    padding: 16px 14px;
    margin-bottom: 14px;
    min-width: 0;
    overflow: hidden;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .tenant-member-controls {
    grid-template-columns: 1fr;
  }

  .card-header .btn,
  .search-grid .btn,
  .upload-actions .btn,
  .file-picker .btn,
  .upload-mobile-actions .btn,
  .search-pagination .btn {
    width: 100%;
  }

  .search-grid,
  .search-advanced,
  .upload-grid,
  .date-range {
    grid-template-columns: 1fr;
  }

  .search-meta-summary,
  .search-pagination,
  .search-pagination-size {
    width: 100%;
  }

  .search-pagination {
    gap: 12px;
    justify-content: stretch;
  }

  .search-pagination-size {
    justify-content: flex-start;
  }

  .data-table {
    font-size: 13px;
  }

  .data-table th,
  .data-table td {
    padding-left: 8px;
    padding-right: 8px;
    white-space: nowrap;
  }

  .upload-mobile-actions,
  .file-picker,
  .upload-actions {
    flex-direction: column;
  }

  .upload-capture-preview-frame {
    min-height: 200px;
    max-height: 320px;
  }
}

@media (max-width: 430px) {
  :root {
    --mobile-gutter: 12px;
    --mobile-card-padding: var(--mobile-gutter);
    --mobile-card-radius: 10px;
    --mobile-block-gap: 10px;
  }

  .app.single {
    overflow-x: hidden;
  }

  .single-content {
    display: block;
    min-height: auto;
    padding: 8px var(--mobile-gutter) calc(20px + env(safe-area-inset-bottom, 0));
  }

  .user-shell {
    display: block;
    width: 100%;
    gap: 0;
  }

  .user-topbar {
    width: 100%;
    padding: 10px var(--mobile-card-padding);
    gap: 8px;
    margin-bottom: var(--mobile-block-gap);
    border-radius: var(--mobile-card-radius);
  }

  .user-topbar .brand {
    font-size: 16px;
    gap: 0;
  }

  .version-text {
    display: block;
    font-size: 11px;
    line-height: 1.2;
  }

  .tenant-pill {
    padding: 8px 10px;
    font-size: 13px;
  }

  .sidebar {
    width: 100%;
    padding: var(--mobile-card-padding);
    border-radius: var(--mobile-card-radius);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
  }

  .nav-title {
    display: none;
  }

  .card,
  .user-main .card,
  .login-card,
  .admin-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: var(--mobile-card-padding);
    border-radius: var(--mobile-card-radius);
    margin-bottom: var(--mobile-block-gap);
  }

  .user-layout {
    display: block;
    gap: 10px;
  }

  .user-main {
    width: 100%;
    min-width: 0;
  }

  .user-main > * {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .nav-item {
    width: 100%;
    min-width: 0;
    margin-bottom: 0;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 10px;
    white-space: normal;
    text-align: center;
    font-size: 13px;
  }

  .user-main .card {
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.04);
  }

  .card h2,
  .card h1,
  .admin-card h2,
  .admin-card h1 {
    font-size: 16px;
    line-height: 1.2;
    margin-bottom: 4px;
  }

  .muted,
  .upload-note,
  .search-pagination-label,
  .search-pagination-size,
  .file-list,
  .form-message,
  .law-links a,
  .card p {
    font-size: 12px;
    line-height: 1.35;
  }

  input,
  select,
  .btn {
    font-size: 13px;
  }

  input,
  select {
    padding: 9px 10px;
    border-radius: 9px;
  }

  .btn {
    padding: 9px 12px;
    border-radius: 9px;
  }

  .search-meta-summary,
  .search-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .search-pagination-row,
  .search-pagination-nav,
  .search-pagination-jump,
  .search-pagination-jump-controls,
  .search-pagination-size {
    width: 100%;
    justify-content: center;
  }

  .search-grid,
  .search-advanced,
  .date-range,
  .search-meta,
  .search-meta-summary,
  .search-pagination,
  .search-pagination-row,
  .search-pagination-nav,
  .search-pagination-jump,
  .search-pagination-jump-controls,
  .search-pagination-size,
  .table-wrap,
  .search-detail-panel,
  .history-panel,
  .preview-panel,
  .upload-grid,
  .upload-workspace,
  .upload-editor,
  .upload-editor-grid,
  .upload-capture-preview,
  .upload-progress,
  .upload-failed,
  .upload-summary,
  .file-picker,
  .upload-mobile-actions,
  .upload-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .search-pagination-label {
    text-align: center;
  }

  .search-results-viewport {
    min-height: 340px;
    max-height: 340px;
    margin-top: 12px;
  }

  .search-pagination-row {
    display: grid;
    gap: 8px;
  }

  .search-pagination-row-main {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .search-pagination-row-summary {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .search-pagination-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .search-pagination-jump {
    display: grid;
    gap: 6px;
    justify-items: stretch;
    justify-content: stretch;
  }

  .search-pagination-jump-label {
    text-align: center;
  }

  .search-pagination-jump-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .search-pagination-jump-controls input {
    width: 100%;
    min-width: 0;
  }

  .search-pagination-size {
    justify-content: center;
    gap: 6px;
  }

  .search-pagination-size-label {
    width: 100%;
    text-align: center;
  }

  .search-pagination-size select {
    width: 100%;
    max-width: 160px;
    justify-self: center;
  }

  .user-main .table-wrap,
  #section-search .table-wrap,
  #section-ledger .table-wrap,
  #section-registry .table-wrap {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .search-mobile-results {
    display: grid;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: var(--mobile-block-gap);
    margin: 0;
    padding: 0;
  }

  .search-mobile-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    gap: 8px;
    margin: 0;
    padding: var(--mobile-card-padding);
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
  }

  .search-mobile-field {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .search-mobile-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .search-mobile-value {
    min-width: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text);
    word-break: break-word;
  }

  .search-mobile-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    min-width: 0;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid rgba(225, 230, 240, 0.7);
  }

  .search-mobile-actions .btn {
    width: 100%;
    min-width: 0;
    padding: 8px;
    font-size: 11px;
  }

  .search-mobile-detail {
    width: 100%;
    min-width: 0;
    margin-top: 4px;
  }

  #search-table {
    display: block;
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    margin: 0;
    border-collapse: collapse;
    border-spacing: 0;
  }

  #search-table thead {
    display: none;
  }

  #search-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
  }

  #search-table tr.search-result-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.04);
    margin-bottom: 10px;
  }

  #search-table tr.search-result-row td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    align-items: start;
    padding: 0;
    border: none;
    white-space: normal;
    word-break: break-word;
    font-size: 12px;
  }

  #search-table tr.search-result-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #search-table tr.search-result-row td.actions {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 6px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(225, 230, 240, 0.7);
  }

  #search-table tr.search-result-row td.actions::before {
    width: 100%;
    margin-bottom: 4px;
  }

  #search-table tr.search-result-row td.actions .btn {
    flex: 1 1 calc(33.333% - 4px);
    min-width: 0;
    padding: 8px 8px;
    font-size: 11px;
  }

  .search-detail-row {
    display: block;
  }

  .search-detail-row td {
    display: block;
    padding: 0;
    border: none;
  }

  #section-upload .upload-grid {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-block-gap);
  }

  #section-upload .upload-grid > * {
    width: 100%;
    min-width: 0;
  }

  #section-upload .file-picker,
  #section-upload .upload-bulk-controls,
  #section-upload .upload-mobile-actions,
  #section-upload .upload-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  #section-upload .file-picker > *,
  #section-upload .upload-bulk-controls > *,
  #section-upload .upload-mobile-actions > *,
  #section-upload .upload-actions > * {
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  #section-upload .upload-bulk-controls select,
  #section-upload .upload-bulk-controls .btn,
  #section-upload .file-picker .btn,
  #section-upload .upload-mobile-actions .btn,
  #section-upload .upload-actions .btn {
    display: flex;
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  #section-upload .upload-workspace,
  #section-upload .upload-editor-grid,
  #section-upload .upload-selection-summary {
    grid-template-columns: 1fr;
  }

  #section-upload .upload-file-list {
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 0 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #section-upload .upload-file-list::-webkit-scrollbar {
    display: none;
  }

  #section-upload .upload-file-list-items {
    display: flex;
    gap: 8px;
    align-items: stretch;
  }

  #section-upload .upload-file-item {
    flex: 0 0 180px;
    min-height: 84px;
  }

  #section-upload .file-picker .btn,
  #section-upload .upload-bulk-controls .btn,
  #section-upload .upload-mobile-actions .btn,
  #section-upload .upload-actions .btn,
  #section-upload .upload-capture-preview-actions .btn {
    width: 100%;
  }

  #section-upload .file-list,
  #section-upload #upload-message {
    padding: 4px 0 0;
  }

  #section-upload .upload-capture-preview,
  #section-upload .upload-progress,
  #section-upload .upload-failed {
    border-radius: 10px;
  }

  #section-upload .upload-capture-preview {
    padding: 10px;
  }

  #section-upload .upload-capture-preview-header {
    display: grid;
    gap: 4px;
  }

  #section-upload .upload-summary {
    grid-template-columns: 1fr;
  }

  #section-file-export .file-export-job-header {
    display: grid;
  }

  #section-file-export .file-export-job-header,
  #section-file-export .file-export-part {
    grid-template-columns: 1fr;
  }

  #section-file-export .file-export-job-status,
  #section-file-export .file-export-part-size {
    text-align: left;
  }

  .search-detail-panel {
    padding: 10px;
    border-radius: 10px;
  }

  .search-detail-subtitle,
  .search-detail-status {
    font-size: 12px;
    line-height: 1.4;
    word-break: break-word;
  }

  .image-preview-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .image-preview-toolbar .btn {
    width: 100%;
    padding: 7px 8px;
    font-size: 11px;
    white-space: nowrap;
  }

  .image-preview-hint {
    font-size: 11px;
    line-height: 1.35;
  }

  .image-preview-viewport {
    min-height: min(52vh, 320px);
    max-height: min(52vh, 320px);
  }

  .search-preview-frame {
    min-height: min(52vh, 340px);
    height: min(52vh, 340px);
  }

  .search-detail-table thead {
    display: none;
  }

  .search-detail-table tbody {
    display: grid;
    gap: 8px;
  }

  .search-detail-table tr {
    display: grid;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
  }

  .search-detail-table td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    border: none;
    padding: 0;
    white-space: normal;
    word-break: break-word;
    font-size: 12px;
  }

  .search-detail-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .search-detail-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .search-detail-table td.actions::before {
    width: 100%;
    margin-bottom: 2px;
  }

  .search-detail-table td.actions .btn {
    width: 100%;
  }

  .table-wrap {
      margin-left: 0;
      margin-right: 0;
      padding-left: 0;
      padding-right: 0;
    }

  .data-table {
    font-size: 12px;
  }

  .data-table th,
  .data-table td {
    padding: 7px 6px;
  }

  #search-table td.actions .btn {
    padding: 4px 5px;
    font-size: 10px;
  }

  .upload-capture-preview-frame {
    min-height: 180px;
    max-height: 260px;
  }

  .upload-grid,
  .form-grid,
  .search-grid,
  .search-advanced {
    gap: 10px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
  }

  .stat-grid-compact {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 12px;
    border-radius: 10px;
  }

  .stat-value {
    font-size: 22px;
  }

  .law-links {
    gap: 8px;
  }
}

.upload-note {
  margin: 8px 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.upload-note strong {
  color: var(--blue-900);
}

.audit-entity-meta {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.audit-row td {
  vertical-align: top;
}

.audit-user-name {
  font-weight: 700;
  color: var(--blue-900);
  overflow-wrap: anywhere;
}

.audit-user-email {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.audit-details-toggle {
  min-width: 84px;
}

.audit-detail-row td {
  padding-top: 0;
  background: #fafbff;
}

.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 0 4px;
}

.audit-detail-block {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.audit-detail-block-wide {
  grid-column: 1 / -1;
}

.audit-detail-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.audit-detail-value {
  color: var(--text);
  overflow-wrap: anywhere;
}

.audit-payload {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
}

#section-registry .data-table {
  table-layout: auto;
}

#section-registry .data-table th,
#section-registry .data-table td {
  white-space: normal;
}

.law-links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.law-links a {
  color: var(--blue-900);
  text-decoration: none;
  font-weight: 600;
}

.law-links a:hover {
  text-decoration: underline;
}

.law-cards {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.law-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.law-card h4 {
  margin: 0 0 8px;
  color: var(--blue-900);
}

.law-card p {
  margin: 0 0 10px;
}

.law-card a {
  color: var(--blue-900);
  text-decoration: none;
  font-weight: 700;
}

.law-card a:hover {
  text-decoration: underline;
}

.invite-members {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}

.invite-members-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.invite-members-header strong {
  color: var(--blue-900);
}

.invite-members-header span,
.invite-members-message {
  font-size: 13px;
  color: var(--muted);
}

.invite-members-list {
  display: grid;
  gap: 8px;
}

.invite-member-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  gap: 4px;
}

.invite-member-name {
  font-weight: 700;
  color: var(--blue-900);
}

.invite-member-email {
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

.invite-member-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.invite-member-role {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(45, 58, 136, 0.08);
  color: var(--blue-900);
  font-size: 12px;
  font-weight: 600;
}

.tenant-role-help {
  margin-top: 14px;
}

.tenant-member-item {
  gap: 10px;
}

.tenant-member-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.tenant-member-controls .btn {
  white-space: nowrap;
}

.tenant-member-role-select {
  min-width: 0;
}

.file-export-jobs {
  display: grid;
  gap: 12px;
}

.file-export-job {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 10px;
}

.file-export-job-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.file-export-job-title {
  font-weight: 700;
  color: var(--blue-900);
}

.file-export-job-meta {
  font-size: 13px;
  color: var(--muted);
}

.file-export-job-expiry {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.file-export-job-status {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.file-export-parts {
  display: grid;
  gap: 8px;
}

.file-export-progress {
  margin-top: 2px;
}

.file-export-part {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(45, 58, 136, 0.05);
}

.file-export-part-name {
  font-weight: 600;
  color: var(--blue-900);
  word-break: break-word;
}

.file-export-part-size {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.file-export-retention-note {
  margin-top: 6px;
}

.storage-plan {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-900);
}

.desktop-only-nav,
.desktop-only-section {
  display: initial;
}

.info-banner {
  margin-top: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8faff;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.info-banner-muted {
  background: #f7f9ff;
  color: var(--muted);
}

.archive-book-previous-actions {
  display: grid;
  grid-template-columns: minmax(160px, 180px) repeat(4, auto);
  gap: 8px;
  align-items: end;
  margin-top: 12px;
  margin-bottom: 12px;
}

.archive-book-previous-actions .field-stack {
  min-width: 0;
}

.archive-book-previous-actions .btn {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}

.archive-book-previous-table {
  table-layout: fixed;
  font-size: 12px;
}

.archive-book-previous-table th,
.archive-book-previous-table td {
  min-width: 0;
  vertical-align: top;
  padding: 7px 6px;
}

.archive-book-previous-table th:nth-child(1),
.archive-book-previous-table td:nth-child(1) { width: 5%; }
.archive-book-previous-table th:nth-child(2),
.archive-book-previous-table td:nth-child(2) { width: 7%; }
.archive-book-previous-table th:nth-child(3),
.archive-book-previous-table td:nth-child(3) { width: 7%; }
.archive-book-previous-table th:nth-child(4),
.archive-book-previous-table td:nth-child(4) { width: 16%; }
.archive-book-previous-table th:nth-child(5),
.archive-book-previous-table td:nth-child(5) { width: 8%; }
.archive-book-previous-table th:nth-child(6),
.archive-book-previous-table td:nth-child(6) { width: 10%; }
.archive-book-previous-table th:nth-child(7),
.archive-book-previous-table td:nth-child(7) { width: 12%; }
.archive-book-previous-table th:nth-child(8),
.archive-book-previous-table td:nth-child(8) { width: 8%; }
.archive-book-previous-table th:nth-child(9),
.archive-book-previous-table td:nth-child(9) { width: 9%; }
.archive-book-previous-table th:nth-child(10),
.archive-book-previous-table td:nth-child(10) { width: 8%; }
.archive-book-previous-table th:nth-child(11),
.archive-book-previous-table td:nth-child(11) { width: 10%; }

.archive-book-previous-table input,
.archive-book-previous-table textarea {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 12px;
  padding: 6px 7px;
}

.archive-book-previous-table textarea {
  resize: vertical;
  min-height: 56px;
}

.archive-book-previous-empty td {
  text-align: center;
  color: var(--muted);
}

.archive-book-previous-years {
  margin-top: 18px;
}

.archive-book-previous-years-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.archive-book-previous-years-header h3 {
  margin: 0;
}

.archive-book-previous-years-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(247, 249, 255, 0.95), rgba(255, 255, 255, 1));
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.04);
  overflow: hidden;
}

.archive-book-previous-years-row {
  display: grid;
  grid-template-columns: minmax(80px, 110px) minmax(180px, 220px) minmax(180px, 1fr) minmax(220px, auto);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.archive-book-previous-years-row:first-child {
  border-top: 0;
}

.archive-book-previous-years-row-header {
  background: #eef2fb;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.archive-book-previous-years-year,
.archive-book-previous-years-updated,
.archive-book-previous-years-user {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
}

.archive-book-previous-years-year {
  color: var(--blue-900);
  font-weight: 700;
}

.archive-book-previous-years-user,
.archive-book-previous-years-updated {
  color: var(--text);
}

.archive-book-previous-years-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
}

.archive-book-previous-year-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.archive-book-previous-year-actions .btn {
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.rule-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.rule-card h3 {
  margin: 0 0 8px;
  color: var(--blue-900);
}

.rule-card p {
  margin: 0;
}

.guidance-panel {
  margin: 18px 0 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.guidance-panel summary {
  padding: 16px 18px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--blue-900);
  list-style: none;
}

.guidance-panel summary::-webkit-details-marker {
  display: none;
}

.guidance-content {
  padding: 0 18px 18px;
}

.guidance-content h4 {
  margin: 14px 0 8px;
  color: var(--blue-900);
}

.guidance-list {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
  font-weight: 400;
}

.guidance-list li {
  margin: 0 0 4px;
  font: inherit;
  color: inherit;
}

.law-card h4 a {
  color: var(--blue-900);
  text-decoration: none;
}

.law-card h4 a:hover,
.law-card h4 a:focus-visible {
  text-decoration: underline;
}

.tenant-plan-cell {
  display: grid;
  gap: 8px;
  min-width: 190px;
}

.tenant-plan-select {
  min-width: 0;
}

.tenant-package-admin {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.tenant-package-note {
  margin-top: -2px;
}

.tenant-package-current {
  margin-top: -2px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.category-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.category-sidebar,
.category-main,
.category-detail,
.category-group-items {
  min-width: 0;
}

.category-sidebar {
  display: grid;
  gap: 12px;
}

.category-sidebar-actions {
  display: grid;
  gap: 8px;
}

.category-group-list {
  display: grid;
  gap: 8px;
}

.category-group-button {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  font: inherit;
  color: var(--blue-900);
  font-weight: 700;
  cursor: pointer;
}

.category-group-button-title {
  display: block;
}

.category-group-button-meta {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.category-group-button.active {
  background: rgba(43, 57, 138, 0.1);
  border-color: rgba(43, 57, 138, 0.24);
}

.category-main {
  display: grid;
  gap: 16px;
}

.category-group-items {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.category-items-header,
.category-item-row {
  display: grid;
  grid-template-columns: minmax(0, 100px) minmax(0, 1fr) minmax(120px, 160px) minmax(220px, 280px);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
}

.category-items-header {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.category-item-row + .category-item-row {
  border-top: 1px solid var(--border);
}

.category-item-name {
  font-weight: 700;
  color: var(--blue-900);
}

.category-item-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.category-item-status.is-active {
  background: rgba(28, 122, 74, 0.12);
  color: #186a43;
}

.category-item-status.is-inactive {
  background: rgba(160, 31, 55, 0.1);
  color: #8a2035;
}

.category-item-retention {
  color: var(--muted);
  font-size: 13px;
}

.category-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.category-detail {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.category-detail-empty {
  color: var(--muted);
}

.category-detail-grid {
  display: grid;
  gap: 12px;
}

.category-retention-readonly {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(241, 244, 255, 0.8);
  font-weight: 700;
  color: var(--blue-900);
}

.category-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
