:root {
  --cream: #f7f2e8;
  --paper: rgba(255, 252, 246, 0.9);
  --ink: #18302d;
  --muted: #55726e;
  --accent: #dc6b42;
  --accent-2: #8ea44f;
  --line: rgba(24, 48, 45, 0.12);
  --danger: #b24c40;
  --shadow: 0 16px 44px rgba(24, 48, 45, 0.11);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(220, 107, 66, 0.22), transparent 28%),
    radial-gradient(circle at left bottom, rgba(142, 164, 79, 0.24), transparent 30%),
    linear-gradient(180deg, #fffdf8 0%, var(--cream) 100%);
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

code,
pre {
  font-family: "SF Mono", "Menlo", monospace;
}

.page-shell {
  width: min(1540px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: "Georgia", serif;
  font-size: 1.26rem;
  font-weight: 700;
  text-decoration: none;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.nav-link-active {
  background: rgba(24, 48, 45, 0.09);
  color: var(--ink);
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  align-items: center;
}

.topbar-logout-form {
  margin: 0;
}

.topbar-logout-button {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.topbar-login-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.auth-shell {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
  padding: 24px 0 40px;
}

.auth-card {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-copy,
.auth-actions {
  display: grid;
  gap: 10px;
}

.auth-copy h1 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.08;
}

.auth-form {
  gap: 12px;
}

.layout,
.detail-layout {
  display: grid;
  gap: 18px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

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

.access-stat-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.access-stat-card strong {
  font-size: 1.4rem;
  line-height: 1;
}

.roles-page {
  display: grid;
  gap: 14px;
}

.roles-browser {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.role-compose-card,
.role-card,
.role-detail-summary-card,
.role-detail-editor-card,
.role-danger-zone {
  padding: 16px;
}

.role-compose-card {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  display: grid;
  gap: 12px;
}

.roles-section-divider {
  width: 100%;
  border-top: 1px solid rgba(24, 48, 45, 0.12);
  margin: 8px 0 18px;
}

.role-compose-copy {
  margin: 0;
}

.roles-browser-toolbar,
.role-compose-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.role-panel-title,
.role-group-title {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.role-panel-subtitle {
  margin: 4px 0 0;
}

.roles-table {
  min-width: 920px;
}

.roles-table .document-actions-heading,
.roles-table .document-actions-cell {
  width: 240px;
  min-width: 240px;
}

.role-table-actions {
  gap: 6px;
}

.role-selection-summary {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.role-selection-summary strong {
  font-size: 1.15rem;
  line-height: 1;
}

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

.role-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.role-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.role-card-head form {
  margin: 0;
}

.role-card-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.role-card-title h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.15;
}

.role-card-title p {
  margin: 0;
}

.role-card-badges {
  align-items: center;
}

.role-card-badges code {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(24, 48, 45, 0.06);
  border: 1px solid rgba(24, 48, 45, 0.08);
  font-size: 0.75rem;
}

.role-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.role-card-stats div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.role-card-stats span {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.role-card-stats strong {
  font-size: 1.04rem;
  line-height: 1;
}

.role-card-section {
  display: grid;
  gap: 6px;
}

.role-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-group-list {
  display: grid;
  gap: 12px;
}

.role-permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.permission-group-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.permission-group-card-active {
  border-color: rgba(220, 107, 66, 0.24);
  background: rgba(220, 107, 66, 0.06);
}

.permission-group-card-readonly {
  background: rgba(255, 255, 255, 0.62);
}

.permission-group-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.permission-group-header h4 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.permission-group-header p {
  margin: 0;
}

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

.permission-group-button {
  padding: 6px 10px;
  font-size: 0.76rem;
}

.role-detail-summary-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.role-detail-page {
  align-content: start;
}

.role-detail-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.role-detail-context h2 {
  margin: 6px 0 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

.role-detail-context p {
  margin: 4px 0 0;
}

.role-detail-summary-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.role-detail-summary-main h2 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: 1.4rem;
  line-height: 1.05;
}

.role-detail-summary-main p {
  margin: 0;
}

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

.role-detail-editor-card {
  display: grid;
  gap: 14px;
}

.role-detail-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
}

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

.role-detail-side-column {
  display: grid;
  gap: 14px;
  align-self: start;
}

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

.role-member-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  text-decoration: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.role-member-card strong {
  font-size: 0.95rem;
}

.role-member-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.role-danger-zone {
  display: grid;
  gap: 10px;
}

.role-danger-zone p {
  margin: 0;
}

.danger-button-compact {
  padding: 7px 11px;
  font-size: 0.78rem;
}

.role-users-table {
  min-width: 980px;
}

.users-table {
  min-width: 940px;
}

.role-users-table .document-actions-heading,
.role-users-table .document-actions-cell,
.users-table .document-actions-heading,
.users-table .document-actions-cell {
  width: 190px;
  min-width: 190px;
}

.role-users-table form,
.users-table form {
  display: flex;
  justify-content: flex-end;
  margin: 0;
}

.user-table-actions {
  min-width: 170px;
}

.user-compose-fields {
  grid-template-columns: minmax(220px, 320px) minmax(220px, 320px) minmax(220px, 1fr);
}

.user-active-toggle {
  align-self: end;
  min-height: 42px;
}

.user-role-picker {
  max-width: none;
}

.user-role-checklist {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.role-user-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diagnostics-page {
  align-content: start;
}

.diagnostics-browser {
  min-width: 0;
}

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

.diagnostics-panel,
.diagnostics-overview-card {
  display: grid;
  gap: 12px;
}

.diagnostics-overview-card {
  align-content: start;
}

.diagnostics-table {
  min-width: 760px;
}

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

.diagnostics-path {
  display: inline-block;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

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

.diagnostics-list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(24, 48, 45, 0.08);
}

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

.diagnostics-list-row p {
  margin: 4px 0 0;
}

.diagnostics-maintenance-form {
  gap: 10px;
}

.diagnostics-maintenance-copy {
  display: grid;
  gap: 4px;
}

.diagnostics-maintenance-copy p {
  margin: 0;
}

.diagnostics-maintenance-controls {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(120px, 160px) auto;
  gap: 10px;
  align-items: end;
  justify-content: start;
}

.diagnostic-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.diagnostic-status-ok {
  color: var(--accent-2);
}

.diagnostic-status-warn {
  color: #a36d17;
}

.diagnostic-status-error {
  color: var(--danger);
}

.diagnostic-status-info {
  color: var(--muted);
}

.roles-page .secondary-button:disabled,
.roles-page button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.role-compose-form {
  gap: 12px;
}

.role-compose-fields {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(340px, 1fr);
  gap: 12px;
  align-items: start;
}

.role-compose-field {
  display: grid;
  gap: 8px;
}

.role-compose-actions {
  display: flex;
  justify-content: flex-start;
}

.roles-page button,
.roles-page .secondary-button {
  padding: 7px 11px;
  font-size: 0.8rem;
}

.roles-page .icon-button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.roles-page .icon-button svg {
  width: 16px;
  height: 16px;
}

.roles-page .permission-option {
  padding: 9px 10px;
}

.roles-page .permission-option strong,
.roles-page .document-primary-cell strong {
  font-size: 0.92rem;
}

.roles-page .permission-option small {
  font-size: 0.78rem;
}

.roles-page .chip,
.roles-page .role-card-badges code {
  font-size: 0.76rem;
}

.admin-sidebar-card {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 12px;
  padding: 18px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.admin-nav-link {
  display: block;
  padding: 12px 14px;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.admin-nav-link-active {
  color: var(--ink);
  background: rgba(220, 107, 66, 0.12);
  border-color: rgba(220, 107, 66, 0.24);
}

.hero,
.detail-hero,
.search-panel,
.detail-card,
.recipe-card,
.admin-table-card,
.document-card,
.empty-state {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 18px;
  padding: 22px;
}

.hero-copy h1,
.detail-hero h1 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 1.05;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.64rem;
  color: var(--accent);
  font-weight: 700;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.hero-stats article,
.document-card dl div,
.nutrition-grid div {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.hero-stats strong {
  display: block;
  font-size: 1.42rem;
}

.hero-panel,
.stacked-form,
.compact-form {
  display: grid;
  gap: 14px;
}

.banner {
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 600;
}

.banner-success {
  background: rgba(142, 164, 79, 0.18);
  color: #30451d;
}

.banner-error {
  background: rgba(178, 76, 64, 0.16);
  color: #6f2c24;
}

label {
  font-weight: 700;
}

input[type="file"],
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid rgba(24, 48, 45, 0.18);
  border-radius: 14px;
  background: white;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #e58f58);
  color: white;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.checkbox-row input {
  width: auto;
}

.permission-fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(24, 48, 45, 0.1);
  border-radius: 16px;
  display: grid;
  gap: 10px;
}

.permission-fieldset legend {
  padding: 0 6px;
  font-weight: 700;
  color: var(--muted);
}

.permission-checklist {
  display: grid;
  gap: 8px;
}

.permission-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.permission-option input {
  margin-top: 2px;
}

.permission-option span {
  display: grid;
  gap: 4px;
}

.permission-option small {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.permission-option-readonly {
  opacity: 0.82;
}

.stacked-actions {
  display: grid;
  gap: 12px;
}

.chip-link {
  text-decoration: none;
}

.danger-button {
  background: linear-gradient(135deg, var(--danger), #d46858);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(24, 48, 45, 0.16);
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.sample-list,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sample-list span,
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(24, 48, 45, 0.08);
  color: var(--ink);
  font-size: 0.8rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.section-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.section-heading-compact {
  align-items: start;
}

.section-heading h2,
.detail-card h2 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: 1.32rem;
  line-height: 1.1;
}

.search-panel {
  padding: 18px;
}

.chat-thread {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  margin: 14px 0;
}

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

.message-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.message-body {
  padding: 13px 15px;
  border-radius: 18px;
  max-width: min(960px, 100%);
}

.message.user .message-body {
  margin-left: auto;
  background: linear-gradient(135deg, #1f4e48, #285b54);
  color: white;
}

.message.assistant .message-body {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(24, 48, 45, 0.08);
}

.message.assistant .message-body > p:first-child {
  margin-top: 0;
}

.message.assistant .message-body > p:last-child {
  margin-bottom: 0;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.search-form-actions {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  align-self: stretch;
}

.search-mode-panel {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.search-mode-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.search-mode-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  background: rgba(24, 48, 45, 0.08);
}

.search-mode-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-mode-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.search-mode-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: 100%;
  padding: 0 10px;
  border-radius: 14px;
  font-weight: 700;
  color: var(--ink);
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.search-mode-option input:checked + span {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(24, 48, 45, 0.1);
}

.search-mode-option-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.search-form button[type="submit"] {
  min-width: 160px;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-items: start;
}

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

.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 900px));
  justify-content: start;
  align-items: start;
  gap: 16px;
}

.recipes-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  align-items: start;
}

.recipes-main {
  display: grid;
  gap: 14px;
}

.recipes-sidebar {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.tag-filter-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.tag-filter-link {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(24, 48, 45, 0.08);
  font-size: 0.92rem;
}

.tag-filter-link-active {
  background: rgba(220, 107, 66, 0.12);
  border-color: rgba(220, 107, 66, 0.22);
}

.recipe-card,
.document-card,
.admin-table-card,
.empty-state,
.detail-card {
  padding: 16px;
}

.recipe-card,
.chat-result-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  overflow: hidden;
}

.recipe-card-top h3,
.document-card h3 {
  margin: 4px 0 6px;
  font-size: 1rem;
  line-height: 1.22;
  min-width: 0;
}

.recipe-card-top h3 a,
.chat-result-card h3 a {
  display: -webkit-box;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.recipe-card-topbar,
.chat-result-topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  min-width: 0;
}

.recipe-category,
.document-status {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 700;
}

.recipe-snippet,
.document-error {
  color: var(--muted);
}

.recipe-card-media {
  position: relative;
  height: 104px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(24, 48, 45, 0.08);
  background:
    linear-gradient(135deg, rgba(220, 107, 66, 0.16), rgba(142, 164, 79, 0.18)),
    rgba(255, 255, 255, 0.72);
}

.recipe-card-media-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
  font-weight: 600;
}

.recipe-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  min-width: 0;
}

.recipe-card .recipe-meta,
.chat-result-card .recipe-meta {
  display: grid;
  gap: 4px;
}

.recipe-meta-primary,
.recipe-meta-secondary {
  min-width: 0;
}

.recipe-meta-primary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.favorite-toggle-form,
.favorite-detail-form {
  margin: 0;
}

.favorite-toggle-button,
.favorite-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid rgba(24, 48, 45, 0.14);
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  box-shadow: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.favorite-toggle-button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.favorite-pill {
  padding: 9px 13px;
}

.favorite-toggle-button:hover,
.favorite-pill:hover {
  transform: translateY(-1px);
  background: white;
  border-color: rgba(220, 107, 66, 0.28);
  color: var(--accent);
}

.favorite-toggle-button:disabled,
.favorite-pill:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.favorite-toggle-button-active,
.favorite-pill-active {
  background: rgba(220, 107, 66, 0.14);
  border-color: rgba(220, 107, 66, 0.28);
  color: var(--accent);
}

.favorite-toggle-button span,
.favorite-pill span {
  font-size: 1rem;
  line-height: 1;
}

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

.document-card dl,
.nutrition-grid {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
}

.document-card dt,
.nutrition-grid dt {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.document-card dd,
.nutrition-grid dd {
  margin: 4px 0 0;
  font-weight: 700;
}

.admin-table-card {
  padding: 0;
  overflow: hidden;
}

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

.document-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

.document-table th,
.document-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(24, 48, 45, 0.08);
}

.document-table th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

.document-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.55);
}

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

.document-primary-cell {
  display: grid;
  gap: 4px;
}

.document-primary-cell strong {
  font-size: 0.95rem;
}

.document-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.document-actions-heading {
  text-align: right;
  width: 190px;
  min-width: 190px;
}

.document-actions-cell {
  width: 190px;
  min-width: 190px;
  white-space: nowrap;
}

.document-icon-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 168px;
}

.document-icon-actions form {
  margin: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(24, 48, 45, 0.14);
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: white;
  border-color: rgba(24, 48, 45, 0.22);
}

.icon-button-with-label {
  width: auto;
  height: auto;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 700;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-button-danger {
  color: var(--danger);
  border-color: rgba(178, 76, 64, 0.24);
}

.icon-button-accent {
  color: var(--accent-2);
  border-color: rgba(92, 112, 92, 0.24);
}

.icon-button-accent:hover {
  background: rgba(92, 112, 92, 0.08);
  border-color: rgba(92, 112, 92, 0.4);
}

.icon-button-danger:hover {
  background: rgba(178, 76, 64, 0.08);
  border-color: rgba(178, 76, 64, 0.4);
}

.status-processed {
  color: var(--accent-2);
}

.status-failed {
  color: var(--danger);
}

.status-needs_ocr {
  color: #a36d17;
}

.status-no_recipes {
  color: #7f6f2f;
}

.detail-hero,
.detail-card {
  padding: 14px 16px;
}

.detail-hero {
  display: grid;
  gap: 6px;
}

.detail-hero .eyebrow {
  margin-bottom: 0;
}

.detail-hero h1 {
  font-size: clamp(1.08rem, 1.55vw, 1.45rem);
  line-height: 1;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-hero .chip-row {
  gap: 4px;
}

.detail-hero .chip {
  padding: 3px 8px;
  font-size: 0.74rem;
}

.detail-hero .detail-meta {
  gap: 6px;
  margin-top: 2px;
  font-size: 0.78rem;
}

.detail-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid rgba(24, 48, 45, 0.08);
}

.detail-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.detail-toolbar-group-end {
  justify-content: flex-end;
}

.detail-toolbar-group form {
  margin: 0;
}

.detail-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(24, 48, 45, 0.14);
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  box-shadow: none;
  font-weight: 700;
  font-size: 0.84rem;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.detail-action-button:hover {
  transform: translateY(-1px);
  background: white;
  border-color: rgba(220, 107, 66, 0.28);
  color: var(--accent);
}

.detail-action-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.detail-action-button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.detail-action-button-danger {
  background: linear-gradient(135deg, var(--danger), #d46858);
  border-color: rgba(178, 76, 64, 0.4);
  color: white;
}

.detail-action-button-danger:hover {
  background: linear-gradient(135deg, #a94439, #cb5d4f);
  border-color: rgba(178, 76, 64, 0.48);
  color: white;
}

.document-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 48, 45, 0.34);
  backdrop-filter: blur(6px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  background: #fffdf8;
  border-radius: 22px;
  border: 1px solid rgba(24, 48, 45, 0.1);
  box-shadow: 0 24px 80px rgba(24, 48, 45, 0.18);
  padding: 20px;
  display: grid;
  gap: 16px;
}

.modal-card h3 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: 1.3rem;
}

.modal-copy {
  display: grid;
  gap: 8px;
}

.modal-copy p {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.modal-actions form {
  margin: 0;
}

.back-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.list-block,
.step-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

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

.comment-form {
  margin-top: 14px;
}

.comment-form-actions {
  display: flex;
  justify-content: flex-start;
}

.comment-feedback,
.comment-summary {
  margin: 0;
  color: var(--muted);
}

.comment-feedback-success {
  color: #30451d;
}

.comment-feedback-error {
  color: #6f2c24;
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.comment-item {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(24, 48, 45, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.comment-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.comment-item-top strong {
  font-size: 0.92rem;
}

.comment-item-top span,
.comment-empty {
  color: var(--muted);
}

.comment-item p {
  margin: 0;
  white-space: pre-wrap;
}

.comment-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

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

.comment-page-button {
  min-width: 40px;
  padding: 10px 12px;
  font-size: 1rem;
  line-height: 1;
}

.comment-page-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.comment-page-indicator {
  color: var(--muted);
  font-weight: 600;
}

.raw-text {
  white-space: pre-wrap;
  background: rgba(24, 48, 45, 0.05);
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
}

.detail-card-media {
  padding: 12px;
}

.detail-card-media .recipe-image-link {
  height: 100%;
}

.detail-grid-spacer {
  min-height: 1px;
}

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

.recipe-image-link {
  display: block;
  width: 100%;
}

.recipe-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(24, 48, 45, 0.1);
  box-shadow: 0 12px 28px rgba(24, 48, 45, 0.12);
}

.chat-result-card {
  border-top: 1px solid rgba(24, 48, 45, 0.08);
  padding-top: 10px;
  margin-top: 10px;
}

.chat-result-card h3 {
  margin: 0;
}

.chat-search-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}

.recipe-grid-loading {
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.recipe-grid-loading-error {
  color: var(--danger);
}

.recipe-grid-sentinel {
  height: 1px;
}

.table-link {
  font-weight: 700;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.defect-message-cell {
  min-width: 260px;
  white-space: pre-wrap;
  color: var(--muted);
}

@media (max-width: 960px) {
  .access-stats-grid,
  .role-card-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .role-detail-context,
  .role-detail-bottom-grid,
  .diagnostics-grid {
    grid-template-columns: 1fr;
  }

  .roles-browser-toolbar,
  .role-compose-header,
  .role-compose-fields,
  .diagnostics-maintenance-controls {
    grid-template-columns: 1fr;
  }

  .role-detail-summary-card {
    flex-direction: column;
    align-items: stretch;
  }

  .permission-group-header {
    flex-direction: column;
  }

  .permission-group-actions {
    justify-content: flex-start;
  }

  .role-permission-grid {
    grid-template-columns: 1fr;
  }

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

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

  .search-form-actions {
    justify-items: stretch;
  }

  .search-mode-panel {
    min-width: 0;
  }

  .recipes-shell {
    grid-template-columns: 1fr;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .recipes-sidebar {
    position: static;
    max-height: none;
  }

  .admin-sidebar-card {
    position: static;
  }

  .tag-filter-list {
    overflow: visible;
    padding-right: 0;
  }

  .detail-hero h1 {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

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

  .detail-grid-spacer {
    display: none;
  }

  .recipe-image-grid {
    max-width: none;
    grid-template-columns: 1fr;
  }

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

  .detail-toolbar-group,
  .detail-toolbar-group-end {
    justify-content: flex-start;
  }

  .document-table {
    min-width: 720px;
  }

  .modal-card {
    padding: 18px;
  }
}
