:root {
  --bg-main: linear-gradient(140deg, #edf0ea, #e9eee8 55%, #eef2ed);
  --bg-panel: rgba(242, 244, 240, 0.9);
  --stroke: rgba(116, 128, 122, 0.32);
  --stroke-soft: rgba(116, 128, 122, 0.2);
  --ink: #1f2b27;
  --ink-soft: #4f5b57;
  --accent: #1d6a55;
  --accent-soft: rgba(199, 214, 209, 0.9);
  --accent-2: #bf5e25;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --shadow: 0 6px 16px rgba(38, 53, 46, 0.08);
  --link: #1a7b64;
  --table-bg: rgba(246, 247, 245, 0.92);
  --table-head-bg: #c8d7d2;
  --table-head-ink: #1f5d4a;
  --table-row-hover: rgba(202, 214, 209, 0.5);
  --table-pill-bg: #d7e1dd;
  --table-pill-border: #b8c6c0;
  --table-pill-ink: #2e4d43;
}

:root.theme-atlas,
body.theme-atlas {
  --bg-main: linear-gradient(140deg, #edf0ea, #e9eee8 55%, #eef2ed);
  --bg-panel: rgba(242, 244, 240, 0.9);
  --stroke: rgba(116, 128, 122, 0.32);
  --stroke-soft: rgba(116, 128, 122, 0.2);
  --ink: #1f2b27;
  --ink-soft: #4f5b57;
  --accent: #1d6a55;
  --accent-soft: rgba(199, 214, 209, 0.9);
  --accent-2: #bf5e25;
  --shadow: 0 6px 16px rgba(38, 53, 46, 0.08);
  --link: #1a7b64;
  --table-bg: rgba(246, 247, 245, 0.92);
  --table-head-bg: #c8d7d2;
  --table-head-ink: #1f5d4a;
  --table-row-hover: rgba(202, 214, 209, 0.5);
  --table-pill-bg: #d7e1dd;
  --table-pill-border: #b8c6c0;
  --table-pill-ink: #2e4d43;
}

:root.theme-ledger,
body.theme-ledger {
  --bg-main: linear-gradient(150deg, #f1f6fb, #edf2f9 55%, #f2f6fa);
  --bg-panel: rgba(249, 252, 255, 0.92);
  --stroke: rgba(97, 121, 153, 0.3);
  --stroke-soft: rgba(97, 121, 153, 0.18);
  --ink: #1d2a3b;
  --ink-soft: #586b82;
  --accent: #1f6feb;
  --accent-soft: rgba(194, 215, 249, 0.9);
  --accent-2: #da7a22;
  --shadow: 0 8px 18px rgba(35, 60, 99, 0.09);
  --link: #1b5dc8;
  --table-bg: rgba(243, 247, 253, 0.94);
  --table-head-bg: #d4e1f4;
  --table-head-ink: #214d86;
  --table-row-hover: rgba(188, 209, 238, 0.42);
  --table-pill-bg: #d8e5f7;
  --table-pill-border: #b5c9e8;
  --table-pill-ink: #2a4c80;
}

:root.theme-moss,
body.theme-moss {
  --bg-main: linear-gradient(145deg, #f2efe4, #edf3e8 52%, #f4f2e9);
  --bg-panel: rgba(250, 251, 246, 0.9);
  --stroke: rgba(116, 124, 95, 0.33);
  --stroke-soft: rgba(116, 124, 95, 0.2);
  --ink: #2b3120;
  --ink-soft: #5e654f;
  --accent: #4d6d2e;
  --accent-soft: rgba(205, 220, 191, 0.86);
  --accent-2: #9c6a1f;
  --shadow: 0 7px 16px rgba(55, 62, 42, 0.1);
  --link: #4a6f2a;
  --table-bg: rgba(247, 248, 241, 0.92);
  --table-head-bg: #d6dec4;
  --table-head-ink: #435b2a;
  --table-row-hover: rgba(211, 223, 186, 0.44);
  --table-pill-bg: #dbe5cb;
  --table-pill-border: #becdaf;
  --table-pill-ink: #3f5a2b;
}

:root.theme-ember,
body.theme-ember {
  --bg-main: linear-gradient(150deg, #f6ede7, #f3ece6 52%, #f8f2eb);
  --bg-panel: rgba(255, 250, 246, 0.92);
  --stroke: rgba(142, 110, 95, 0.33);
  --stroke-soft: rgba(142, 110, 95, 0.2);
  --ink: #362620;
  --ink-soft: #6f5a4f;
  --accent: #b0552f;
  --accent-soft: rgba(234, 206, 191, 0.92);
  --accent-2: #3d7a66;
  --shadow: 0 8px 17px rgba(90, 62, 49, 0.1);
  --link: #9f4a28;
  --table-bg: rgba(252, 245, 240, 0.92);
  --table-head-bg: #e8d3c6;
  --table-head-ink: #7a3e26;
  --table-row-hover: rgba(235, 204, 186, 0.42);
  --table-pill-bg: #edd8cd;
  --table-pill-border: #dfbfad;
  --table-pill-ink: #74412b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg-main);
  font-family: var(--sans);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(84, 102, 93, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(84, 102, 93, 0.07) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  display: none;
}

.bg-orb-a {
  width: 350px;
  height: 350px;
  right: -40px;
  top: -80px;
  background: rgba(191, 94, 37, 0.3);
}

.bg-orb-b {
  width: 320px;
  height: 320px;
  left: -90px;
  bottom: -110px;
  background: rgba(20, 115, 82, 0.26);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1720px, 97vw);
  margin: 24px auto 30px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
}

:root.has-session .app-shell.view-hidden {
  display: grid;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  border-radius: 14px;
}

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

.brand-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.brand-home-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 36%, white);
  outline-offset: 3px;
  border-radius: 10px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--stroke-soft);
  background: rgba(255, 255, 255, 0.75);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.brand-home-btn:hover .brand-icon {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 16%, transparent);
}

.brand-home-btn:hover .brand-title {
  color: var(--accent);
}

.brand-copy {
  display: grid;
  gap: 2px;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.32rem;
}

.brand-subtitle {
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

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

.profile-label {
  display: inline-block;
  max-width: 48vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.sidebar,
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  border-radius: 16px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: fit-content;
  padding: 14px;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.65rem;
  line-height: 1.05;
}

.subhead {
  margin: 10px 0 14px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  text-align: left;
  border: 1px solid var(--stroke);
  background: rgba(247, 248, 246, 0.9);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-weight: 600;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.nav-link:visited {
  color: var(--ink);
  text-decoration: none;
}

.nav-link:hover,
.nav-link:focus-visible {
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-soft);
  color: #1f5f4c;
  border-color: transparent;
}

.nav-link-settings {
  margin-top: 0;
}

.nav-divider {
  margin: 8px 4px 2px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent) 55%, transparent),
    color-mix(in srgb, var(--stroke) 85%, transparent)
  );
  opacity: 0.95;
}

.content-pane {
  display: grid;
  gap: 14px;
}

.auth-gate {
  position: relative;
  z-index: 2;
  width: min(560px, 94vw);
  margin: 40px auto 8px;
}

:root.has-session .auth-gate {
  display: none;
}

.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 18px;
}

.auth-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  margin: 14px 0 10px;
  border: 1px solid var(--stroke-soft);
  border-radius: 999px;
  background: rgba(246, 241, 230, 0.72);
}

.auth-tab {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.auth-tab:hover {
  color: var(--ink);
}

.auth-tab.is-active {
  background: var(--accent);
  color: var(--bg-base);
  box-shadow: 0 8px 18px rgba(95, 88, 61, 0.18);
}

.auth-layout {
  margin: 8px 0 8px;
}

.auth-panel {
  border: 1px solid var(--stroke-soft);
  background: rgba(252, 253, 251, 0.78);
  border-radius: 12px;
  padding: 14px;
}

.auth-panel-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.05rem;
}

.auth-panel-note {
  margin: 6px 0 10px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.auth-message {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.view-hidden {
  display: none;
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-family: var(--serif);
  letter-spacing: 0.01em;
}

.activity-token-total {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-family: var(--mono);
}

.stack {
  display: grid;
  gap: 8px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

input[type="text"],
input[type="file"],
input[type="date"],
input[type="number"],
input[type="password"],
textarea,
.settings-form select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-family: var(--sans);
}

.settings-form select {
  min-height: 44px;
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #4e5d58 50%),
    linear-gradient(135deg, #4e5d58 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[type="date"] {
  min-height: 42px;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%234e5d58' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 10px) 50%;
  background-size: 18px 18px;
}

input[type="text"]:focus-visible,
input[type="file"]:focus-visible,
input[type="date"]:focus-visible,
input[type="number"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible,
.settings-form select:focus-visible {
  outline: 2px solid rgba(29, 106, 85, 0.35);
  outline-offset: 1px;
  border-color: #5a8378;
}

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

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0;
  width: 20px;
  height: 20px;
  margin-right: 2px;
  background: transparent;
}

#metaDate {
  width: min(220px, 100%);
  justify-self: start;
}

.upload-dropzone {
  border: 1px dashed #6f8f85;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone:focus-visible,
.upload-dropzone.is-drag-over {
  background: rgba(215, 233, 225, 0.45);
  border-color: #3d7a67;
  outline: none;
}

.upload-dropzone.is-disabled {
  cursor: not-allowed;
  opacity: 0.72;
  background: rgba(244, 244, 242, 0.86);
  border-color: var(--stroke-strong);
}

.upload-dropzone-title {
  margin: 0;
  font-weight: 700;
}

.upload-dropzone-subtitle {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

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

.btn {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: rgba(247, 248, 246, 0.95);
  color: var(--ink);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(46, 57, 52, 0.12);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #118260);
  color: #f5fff9;
  border-color: rgba(0, 0, 0, 0.1);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--link);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.document-actions {
  align-items: center;
  justify-content: space-between;
}

.document-actions-left,
.document-actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.document-detail-card {
  border: 1px solid var(--stroke-soft);
  border-radius: 12px;
  background: rgba(248, 250, 248, 0.92);
  padding: 12px;
  margin-bottom: 12px;
}

.document-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.document-detail-item {
  display: grid;
  gap: 3px;
}

.document-detail-item-full {
  margin-top: 2px;
}

.document-detail-label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.document-detail-value {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
}

.document-detail-path {
  display: block;
  border: 1px solid var(--stroke-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  white-space: pre-wrap;
}

.document-ocr-preview {
  margin: 0;
  display: block;
  border: 1px solid var(--stroke-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.35;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.document-history-card {
  border: 1px solid var(--stroke-soft);
  border-radius: 12px;
  background: rgba(248, 250, 248, 0.92);
  padding: 12px;
  margin-top: 12px;
}

.document-history-title {
  margin: 0 0 10px;
  font-size: 0.98rem;
  font-family: var(--serif);
}

.document-history-list {
  display: grid;
  gap: 8px;
}

.document-history-empty {
  margin: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.document-history-item {
  border: 1px solid var(--stroke-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  padding: 10px;
}

.document-history-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  margin-bottom: 6px;
}

.document-history-type {
  font-weight: 700;
  font-size: 0.82rem;
  color: #1f5f4c;
}

.document-history-meta {
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.document-history-changes {
  margin: 0;
  display: grid;
  gap: 3px;
}

.document-history-change {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

.filters-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.pagination-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 12px;
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.docs-total-label {
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-family: var(--mono);
}

.page-indicator {
  min-width: 70px;
  text-align: center;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.settings-form {
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.settings-column {
  display: grid;
  gap: 12px;
  align-content: start;
}

.settings-subnav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settings-subnav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.88rem;
}

.settings-subnav-link.active {
  color: var(--ink);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
}

.settings-subsection.view-hidden {
  display: none;
}

#settings-section-models {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

#settings-section-models.view-hidden {
  display: none;
}

.settings-group {
  border: 1px solid var(--stroke-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
}

.settings-group-title {
  margin: 0;
  font-size: 0.94rem;
  font-family: var(--serif);
}

.settings-group-note {
  margin: 4px 0 10px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.settings-group-fields {
  display: grid;
  gap: 8px;
}

.settings-model-summary-table td {
  vertical-align: top;
}

#settings-section-models .settings-group-wide .docs-table-wrap {
  margin-top: 10px;
}

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

.settings-connection-card,
.settings-task-card {
  border: 1px solid var(--stroke-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
  padding: 10px;
}

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

.settings-task-title {
  margin: 0;
  font-size: 0.84rem;
  font-family: var(--serif);
}

.settings-route-grid {
  display: grid;
  gap: 8px;
}

.settings-compact-number-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.settings-compact-field {
  display: grid;
  gap: 4px;
}

.settings-compact-field .label {
  margin-bottom: 0;
  font-size: 0.78rem;
}

.settings-compact-field input[type="number"] {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.settings-compact-field input[type="number"]::-webkit-outer-spin-button,
.settings-compact-field input[type="number"]::-webkit-inner-spin-button {
  margin-left: 4px;
}

.settings-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink);
}

.settings-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.settings-group .actions {
  margin-top: 10px;
  margin-bottom: 0;
  align-items: center;
}

.settings-group-wide {
  grid-column: 1 / -1;
}

.settings-form-actions {
  grid-column: 1 / -1;
}

.search-shared-scope {
  border: 1px solid var(--stroke-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
  margin-bottom: 12px;
}

.search-scope-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.search-subsection.view-hidden {
  display: none;
}

.search-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.search-card {
  border: 1px solid var(--stroke-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
  margin-bottom: 12px;
}

.search-card h3 {
  margin: 0 0 10px;
  font-size: 0.96rem;
  font-family: var(--serif);
}

.search-card select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px 11px;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-family: var(--sans);
}

.search-hint {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.search-scope-row {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}

.search-scope-actions {
  margin-bottom: 8px;
}

.search-debug-output {
  margin-top: 10px;
  max-height: 320px;
  overflow: auto;
}

#search-section-ask .docs-table-wrap {
  margin-top: 10px;
}

@media (max-width: 960px) {
  .settings-form {
    grid-template-columns: 1fr;
  }

  #settings-section-models {
    grid-template-columns: 1fr;
  }

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

  .settings-column {
    gap: 12px;
  }

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

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

.settings-inline-status {
  font-size: 0.84rem;
  color: var(--ink-soft);
  min-height: 1.1em;
}

.settings-inline-status.is-success {
  color: #1d6a55;
}

.settings-inline-status.is-error {
  color: #9f3f1d;
}

.filter-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 8px 6px 12px;
  background: rgba(247, 248, 246, 0.9);
  min-height: 48px;
}

.filter-chip-search {
  min-width: 280px;
  flex: 1 1 340px;
}

.filter-chip-search input[type="text"] {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.92rem;
}

.filter-chip-search input[type="text"]:focus-visible {
  outline: none;
  border: 0;
}

.chip-prefix {
  font-weight: 700;
  font-size: 0.9rem;
  color: #2a3a35;
  white-space: nowrap;
}

.filter-select {
  border: 0;
  background: transparent;
  color: #25342f;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0 28px 0 0;
  min-width: 130px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #4e5d58 50%),
    linear-gradient(135deg, #4e5d58 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 3px), calc(100% - 8px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
}

.filter-select-native {
  display: none;
}

.filter-dropdown {
  position: relative;
}

.filter-dropdown-trigger {
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #1f2f2a;
  min-height: 34px;
  min-width: 170px;
  padding: 6px 30px 6px 10px;
  text-align: left;
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
  position: relative;
}

.filter-dropdown-value {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.filter-dropdown-caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #45615a;
}

.filter-chip.is-open .filter-dropdown-trigger {
  border-color: #6f8f85;
  background: #f4f8f6;
}

.filter-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(320px, 78vw);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #eff2ef;
  box-shadow: 0 12px 24px rgba(36, 47, 42, 0.18);
  padding: 10px;
  z-index: 30;
}

.filter-dropdown-search {
  width: 100%;
  border: 1px solid #a6b7af;
  border-radius: 8px;
  background: #f8faf8;
  padding: 9px 10px;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.filter-dropdown-options {
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid #d3dbd7;
}

.filter-dropdown-option {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #d3dbd7;
  background: transparent;
  text-align: left;
  padding: 10px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: #21302b;
}

.filter-dropdown-option:hover {
  background: rgba(130, 157, 148, 0.14);
}

.filter-dropdown-check {
  width: 18px;
  height: 18px;
  border: 1px solid #9fb0a9;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: #1f5f4c;
  font-size: 0.74rem;
  font-weight: 700;
  flex: 0 0 18px;
}

.filter-dropdown-option.is-selected .filter-dropdown-check {
  background: #d7e9e1;
  border-color: #6f8f85;
}

.filter-dropdown-option-label {
  line-height: 1.25;
}

.filter-dropdown-empty {
  padding: 10px 4px;
  color: #5a6662;
  font-size: 0.9rem;
}

.btn-muted {
  background: #e8ebea;
  color: #5a6467;
  border-color: #8f989d;
}

.btn-muted:hover:not(:disabled) {
  box-shadow: 0 8px 16px rgba(70, 78, 83, 0.14);
}

#restartPendingBtn:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 22%, white);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--stroke));
  color: color-mix(in srgb, var(--accent) 80%, black);
}

#restartPendingBtn:not(:disabled):hover {
  box-shadow: 0 8px 16px color-mix(in srgb, var(--accent) 25%, transparent);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.filters-grid select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-family: var(--sans);
}

.filters-grid .actions {
  margin: 0;
}

.output {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke-soft);
  background: rgba(247, 248, 246, 0.88);
  min-height: 150px;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.markdown-output {
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: normal;
}

.markdown-output p,
.markdown-output ul,
.markdown-output ol,
.markdown-output blockquote,
.markdown-output table {
  margin: 0 0 10px 0;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3 {
  margin: 0 0 8px 0;
  font-family: var(--serif);
  line-height: 1.25;
}

.markdown-output h1 {
  font-size: 1.15rem;
}

.markdown-output h2 {
  font-size: 1.05rem;
}

.markdown-output h3 {
  font-size: 0.98rem;
}

.markdown-output ul,
.markdown-output ol {
  padding-left: 18px;
}

.markdown-output code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: color-mix(in srgb, var(--accent-soft) 38%, white);
  border-radius: 5px;
  padding: 1px 4px;
}

.markdown-output blockquote {
  border-left: 3px solid var(--stroke);
  padding-left: 10px;
  color: var(--ink-soft);
}

.markdown-output table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--stroke);
  background: var(--table-bg);
}

.markdown-output th,
.markdown-output td {
  border: 1px solid var(--stroke-soft);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.markdown-output th {
  background: var(--table-head-bg);
  color: var(--table-head-ink);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.docs-table-wrap {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: auto;
  background: var(--table-bg);
  margin-bottom: 10px;
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.tags-table {
  min-width: 360px;
}

.pending-table {
  min-width: 600px;
}

.docs-table th,
.docs-table td {
  border-bottom: 1px solid var(--stroke-soft);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.82rem;
}

.tags-table td {
  vertical-align: middle;
}

.activity-table th,
.activity-table td {
  vertical-align: middle;
}

.docs-table th {
  position: sticky;
  top: 0;
  background: var(--table-head-bg);
  color: var(--table-head-ink);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.table-sort-button:hover,
.table-sort-button:focus-visible {
  color: var(--ink);
}

.table-sort-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.table-sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 10px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.docs-table th[aria-sort="ascending"] .table-sort-indicator,
.docs-table th[aria-sort="descending"] .table-sort-indicator {
  color: var(--ink);
}

.docs-table tbody tr:hover {
  background: var(--table-row-hover);
}

.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.74rem;
  line-height: 1.3;
  background: var(--table-pill-bg);
  border: 1px solid var(--table-pill-border);
  color: var(--table-pill-ink);
  white-space: nowrap;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.action-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(247, 248, 246, 0.95);
  color: #2a3a35;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.action-icon-svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

.action-icon-btn:hover {
  background: #e7efeb;
  border-color: #739286;
}

.action-icon-btn:focus-visible {
  outline: 2px solid rgba(29, 106, 85, 0.35);
  outline-offset: 1px;
}

@media (max-width: 980px) {
  .auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .profile-label {
    max-width: 72vw;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: min(100%, 98vw);
    margin: 14px auto 18px;
  }

  .sidebar {
    position: static;
  }

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

  .filters-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-controls {
    justify-content: space-between;
  }

  .filter-chip {
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }

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

  .document-actions-left,
  .document-actions-right {
    width: 100%;
  }

  .btn-muted {
    width: 100%;
  }

  .docs-table-wrap {
    overflow: visible;
  }

  .docs-table,
  .tags-table,
  .pending-table {
    min-width: 0;
  }
}

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

  .document-detail-grid {
    grid-template-columns: 1fr;
  }

  .docs-table thead {
    display: none;
  }

  .docs-table,
  .docs-table tbody,
  .docs-table tr,
  .docs-table td {
    display: block;
    width: 100%;
  }

  .docs-table tr {
    border: 1px solid var(--stroke-soft);
    border-radius: 10px;
    margin: 0 0 10px;
    background: rgba(255, 255, 255, 0.88);
    overflow: hidden;
  }

  .docs-table td {
    border-bottom: 1px solid var(--stroke-soft);
    padding: 10px 10px 10px 44%;
    position: relative;
    min-height: 38px;
  }

  .docs-table td:last-child {
    border-bottom: 0;
  }

  .docs-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    top: 10px;
    width: 40%;
    color: var(--ink-soft);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
  }

  .docs-table td[colspan] {
    padding: 12px;
  }

  .docs-table td[colspan]::before {
    content: none;
  }

  .docs-table td[data-label="Action"] {
    padding-left: 10px;
  }

  .docs-table td[data-label="Action"]::before {
    content: none;
  }

  .table-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .tag-pills {
    gap: 4px;
  }
}

@media (min-width: 1400px) {
  .app-shell {
    grid-template-columns: 276px minmax(0, 1fr);
    gap: 20px;
  }

  .sidebar {
    padding: 16px;
  }

  .panel {
    padding: 20px;
  }

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

  .docs-table {
    min-width: 1060px;
  }
}

@media (min-width: 1800px) {
  .app-shell {
    width: min(1960px, 98vw);
    grid-template-columns: 292px minmax(0, 1fr);
  }

  .sidebar {
    padding: 18px;
  }

  .document-detail-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
