:root {
  --bg: #f3efe8;
  --surface: rgba(255, 255, 253, 0.94);
  --surface-strong: #fffefa;
  --panel: rgba(255, 255, 253, 0.98);
  --line: rgba(31, 43, 47, 0.12);
  --line-strong: rgba(31, 43, 47, 0.2);
  --ink: #182326;
  --muted: #65737a;
  --accent: #145f63;
  --accent-dark: #0e4a4d;
  --warm: #8b5a30;
  --good: #0d6b4c;
  --warning: #8a561e;
  --danger: #8f3b2b;
  --text: var(--ink);
  --muted-copy: #5f6d74;
  --shadow: 0 18px 40px rgba(18, 31, 35, 0.06);
  --shadow-soft: 0 8px 18px rgba(18, 31, 35, 0.04);
  --radius: 22px;
  --radius-small: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(139, 90, 48, 0.08), transparent 28%),
    linear-gradient(180deg, #faf7f1 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", "Trebuchet MS", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: none;
}

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

button {
  cursor: pointer;
}

.directory-entry,
.metric-link-card,
.dashboard-link-card,
.reminder-link-card,
.record-highlight-card {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  font: inherit;
  color: inherit;
}

.app-shell {
  position: relative;
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  max-width: 1660px;
  margin: 0 auto;
  padding: clamp(14px, 2.6vw, 28px);
}

.app-header,
.main-nav,
.panel {
  position: relative;
  z-index: 1;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr);
  gap: clamp(18px, 2vw, 28px);
  padding: clamp(20px, 2.4vw, 30px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  align-items: start;
}

.brand-block {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  width: 100%;
  max-width: none;
}

.brand-block h1,
.section-heading h2,
.detail-header h2,
.empty-state h2,
.service-editor h2,
.panel h3 {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.06;
}

.brand-block h1 {
  font-size: clamp(2.25rem, 4vw, 3.8rem);
  width: 100%;
}

.section-heading h2,
.detail-header h2 {
  font-size: clamp(1.45rem, 2.3vw, 2.1rem);
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: var(--warm);
}

.lede,
.detail-subtitle,
.empty-state p,
.helper-text,
.field span,
.entry-subtle,
.table-note {
  color: var(--muted);
}

.lede,
.detail-subtitle,
.empty-state p {
  line-height: 1.6;
}

.brand-block .lede {
  max-width: 70ch;
  margin-top: 6px;
}

#serviceLinkedAsset {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(20, 95, 99, 0.14);
  background: rgba(20, 95, 99, 0.08);
  color: var(--text);
  font-weight: 600;
}

.header-actions,
.action-row,
.badge-row,
.section-heading,
.nav-pill,
.tab-pill,
.directory-entry-meta,
.service-entry-head,
.document-head,
.timeline-entry-head {
  display: flex;
  align-items: center;
}

.header-actions,
.action-row,
.badge-row {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions {
  align-self: start;
  width: 100%;
  padding-top: 0;
  border-top: 0;
  justify-content: flex-end;
}

.header-actions > .button,
.header-actions > .field,
.header-actions > .header-session,
.header-actions > .persistence-badge {
  flex: 0 1 auto;
}

#newAssetAction {
  margin-left: 0;
}

.persistence-badge {
  border-radius: 999px;
  border: 1px solid rgba(20, 95, 99, 0.14);
  background: rgba(20, 95, 99, 0.08);
  color: var(--accent-dark);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.persistence-badge.is-local {
  border-color: rgba(164, 107, 51, 0.18);
  background: rgba(164, 107, 51, 0.08);
  color: var(--warm);
}

.button,
.nav-pill,
.tab-pill,
.inline-button {
  appearance: none;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 11px 15px;
  font-weight: 600;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.button:hover,
.button:focus-visible,
.nav-pill:hover,
.nav-pill:focus-visible,
.tab-pill:hover,
.tab-pill:focus-visible,
.inline-button:hover,
.inline-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.98);
}

.button-primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 20px rgba(20, 95, 99, 0.18);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: linear-gradient(135deg, #177277, #0d474a);
}

.compact-field {
  width: 136px;
}

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

.field span {
  font-size: 0.88rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(29, 46, 52, 0.18);
  background: rgba(255, 255, 255, 0.76);
  outline: none;
  color: var(--ink);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  background: #fff;
  border-color: rgba(20, 95, 99, 0.42);
  box-shadow: 0 0 0 4px rgba(20, 95, 99, 0.12);
}

.main-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  width: 100%;
  overflow: auto;
}

.nav-pill,
.tab-pill {
  padding: 10px 16px;
  white-space: nowrap;
}

.nav-pill.is-active,
.tab-pill.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.app-main,
.view-panel {
  position: relative;
  z-index: 1;
}

.dashboard-grid,
.workspace-grid,
.reports-grid,
.tab-grid,
.documents-layout,
.service-layout {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  align-items: start;
}

.dashboard-main-stack {
  display: grid;
  gap: 22px;
  align-content: start;
}

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

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

.tab-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 320px);
}

.record-links-panel {
  display: grid;
  gap: 16px;
  padding: 18px 16px;
  border-radius: 22px;
  border: 1px solid rgba(28, 47, 52, 0.1);
  background: linear-gradient(180deg, rgba(252, 249, 244, 0.96), rgba(247, 244, 238, 0.9));
}

.record-links-grid {
  display: grid;
  gap: 14px;
}

.related-records-vertical {
  gap: 10px;
}

.record-link-card {
  display: grid;
  gap: 12px;
  width: 100%;
  position: relative;
  padding: 18px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid rgba(20, 95, 99, 0.14);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(18, 31, 35, 0.04);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.record-link-card:hover,
.record-link-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 99, 0.32);
  box-shadow: 0 16px 28px rgba(18, 31, 35, 0.08);
  background: #fff;
}

.record-link-card:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.record-link-card .section-label {
  margin: 0 0 6px;
}

.record-link-card strong {
  display: block;
  font-size: 1.02rem;
}

.record-link-card p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}

.related-records-vertical .record-link-card {
  gap: 8px;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  border-left: 4px solid rgba(20, 95, 99, 0.26);
  box-shadow: none;
}

.related-records-vertical .record-link-card:hover,
.related-records-vertical .record-link-card:focus-visible {
  box-shadow: 0 10px 20px rgba(18, 31, 35, 0.06);
}

.related-records-vertical .record-link-card .section-label {
  margin: 0 0 2px;
  font-size: 0.68rem;
}

.related-records-vertical .record-link-card strong {
  font-size: 0.98rem;
}

.related-records-vertical .record-link-card p {
  font-size: 0.9rem;
}

.related-records-vertical .record-link-card .status-chip {
  justify-self: start;
}

.record-related-vendors {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(28, 47, 52, 0.08);
}

.field-group-heading {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(28, 47, 52, 0.08);
  background: rgba(247, 244, 238, 0.76);
}

.field-group-heading > span {
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--text);
}

.field-group-heading .helper-text {
  margin: 0;
}

.compact-heading h2,
.compact-heading h3 {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.documents-layout {
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
}

.documents-layout.list-mode,
.documents-layout.detail-mode {
  grid-template-columns: 1fr;
}

.documents-layout.detail-mode .document-editor {
  max-width: 900px;
}

.service-layout {
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
}

.service-layout.list-mode,
.service-layout.detail-mode {
  grid-template-columns: 1fr;
}

.service-layout.detail-mode .service-editor {
  max-width: 980px;
}

.stack-column,
.directory-panel,
.detail-panel,
.form-panel,
.inset-panel,
.summary-panel,
.service-directory,
.service-editor {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel,
.summary-panel,
.inset-panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.summary-panel,
.inset-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(251, 248, 242, 0.98));
}

.directory-panel,
.detail-panel {
  min-height: calc(100vh - 235px);
}

.workspace-header-panel {
  padding: 16px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 241, 0.98));
}

.workspace-grid.page-list,
.workspace-grid.page-detail {
  grid-template-columns: 1fr;
}

.view-panel.view-record-mode .workspace-header-panel {
  display: none;
}

.view-panel.view-record-mode .detail-panel {
  min-height: auto;
}

.workspace-heading,
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.workspace-actions {
  justify-content: flex-start;
}

.detail-quick-note {
  margin: 0 0 6px;
}

.detail-toolbar {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-toolbar-actions {
  align-items: center;
}

.detail-toolbar .section-label {
  margin: 0;
}

.record-page-nav {
  display: grid;
  gap: 10px;
  padding: 16px 18px 6px;
  border-radius: 18px;
  border: 1px solid rgba(28, 47, 52, 0.08);
  background: rgba(247, 244, 238, 0.72);
}

.record-detail-layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.record-sidebar {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 16px;
}

.record-main {
  display: grid;
  gap: 18px;
}

.tab-grid .summary-panel {
  position: sticky;
  top: 24px;
}

.record-highlights-panel {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.record-highlights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.record-highlight-card {
  display: grid;
  gap: 10px;
  width: 100%;
  position: relative;
  padding: 16px 18px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid rgba(28, 47, 52, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(251, 248, 242, 0.98));
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.record-highlight-card.highlight-tone-good {
  border-color: rgba(13, 107, 76, 0.18);
}

.record-highlight-card.highlight-tone-warning {
  border-color: rgba(166, 89, 43, 0.22);
}

.record-highlight-card.highlight-tone-danger {
  border-color: rgba(143, 59, 43, 0.2);
}

.record-highlight-card:hover,
.record-highlight-card:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(18, 31, 35, 0.08);
  background: #fff;
}

.record-highlight-card:disabled {
  cursor: not-allowed;
  opacity: 0.72;
  box-shadow: none;
}

.record-highlight-card.is-current {
  cursor: default;
  opacity: 1;
  box-shadow: none;
  border-color: rgba(20, 95, 99, 0.24);
  background: linear-gradient(180deg, rgba(250, 247, 241, 0.98), rgba(247, 244, 238, 0.98));
}

.record-highlight-card .section-label {
  margin: 0;
}

.record-highlight-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.record-highlight-card strong {
  font-size: 1.1rem;
}

.record-highlight-value-row,
.record-link-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.field-grid,
.filter-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.directory-list,
.list-stack,
.dashboard-board,
.attachment-list,
.timeline-list,
.spare-stack {
  display: grid;
  gap: 12px;
}

.directory-entry,
.reminder-card,
.metric-card,
.dashboard-card,
.service-card,
.spare-card,
.document-card,
.timeline-entry,
.empty-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(28, 47, 52, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(252, 249, 244, 0.98));
}

.dashboard-card,
.reminder-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: clamp(156px, 18vw, 184px);
}

.follow-up-card {
  min-height: auto;
}

.directory-entry {
  text-align: left;
  width: 100%;
  position: relative;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.dashboard-link-card,
.reminder-link-card {
  text-align: left;
  width: 100%;
  position: relative;
  border: 1px solid rgba(28, 47, 52, 0.12);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.directory-entry:hover,
.directory-entry:focus-visible,
.dashboard-link-card:hover,
.dashboard-link-card:focus-visible,
.reminder-link-card:hover,
.reminder-link-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 99, 0.24);
  box-shadow: 0 14px 28px rgba(18, 31, 35, 0.06);
}

.directory-entry.is-selected,
.service-card.is-selected,
.document-card.is-selected {
  border-color: rgba(20, 95, 99, 0.34);
  box-shadow: 0 0 0 2px rgba(20, 95, 99, 0.12);
}

.document-card,
.timeline-entry {
  scroll-margin-top: 24px;
}

.timeline-link-entry {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.timeline-link-entry:hover,
.timeline-link-entry:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 99, 0.28);
  box-shadow: 0 14px 28px rgba(18, 31, 35, 0.06);
}

.directory-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.workspace-grid.page-list .directory-panel,
.workspace-grid.page-detail .detail-panel {
  min-height: calc(100vh - 235px);
}

.directory-entry strong,
.reminder-card strong,
.metric-card strong,
.dashboard-card strong,
.service-card strong,
.spare-card strong,
.document-card strong,
.timeline-entry strong {
  display: block;
  font-size: 1rem;
}

.directory-entry p,
.dashboard-card p,
.reminder-card p,
.document-card p,
.timeline-entry p,
.service-card p,
.spare-card p,
.empty-card p {
  margin: 6px 0 0;
  line-height: 1.5;
  color: var(--muted);
}

.entry-link-note,
.report-link-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(20, 95, 99, 0.16);
  background: rgba(20, 95, 99, 0.08);
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 600;
}

.entry-link-note::after,
.report-link-note::after {
  content: ">";
  font-weight: 700;
}

.directory-entry-meta,
.service-entry-head,
.document-head,
.timeline-entry-head {
  justify-content: space-between;
  gap: 12px;
}

.dashboard-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.dashboard-card-head .status-chip {
  justify-self: start;
}

.dashboard-card-head strong {
  display: block;
  font-size: 1.08rem;
  line-height: 1.2;
}

.dashboard-card .entry-link-note,
.reminder-card .entry-link-note {
  margin-top: auto;
}

.follow-up-actions {
  justify-content: flex-start;
  margin-top: 4px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

#dashboardMetrics.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.dashboard-snapshot-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 241, 0.98));
  box-shadow: 0 14px 28px rgba(18, 31, 35, 0.05);
}

.metric-link-card {
  width: 100%;
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: clamp(144px, 17vw, 168px);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.metric-link-card:hover,
.metric-link-card:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 99, 0.24);
  box-shadow: 0 14px 28px rgba(18, 31, 35, 0.06);
}

.metric-link-card p:first-of-type {
  margin-top: 0;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.25;
}

.metric-link-card strong {
  font-size: clamp(1.7rem, 3vw, 2rem);
  line-height: 1;
}

.metric-link-card .entry-link-note {
  margin-top: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-link-card .entry-link-note::after {
  content: ">";
}

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

.metric-card strong {
  font-size: 1.5rem;
  line-height: 1;
}

.dashboard-board {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.dashboard-main-stack > .panel {
  min-width: 0;
}

.dashboard-main-stack .section-heading {
  margin-bottom: 4px;
}

.stack-column > .panel {
  min-width: 0;
}

.badge,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid transparent;
  font-weight: 600;
}

.tone-good {
  color: var(--good);
  background: rgba(13, 107, 76, 0.12);
}

.tone-warning {
  color: var(--warning);
  background: rgba(166, 89, 43, 0.14);
}

.tone-danger {
  color: var(--danger);
  background: rgba(143, 59, 43, 0.14);
}

.tone-muted {
  color: var(--muted);
  background: rgba(23, 36, 39, 0.08);
}

.tab-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.asset-tab-panel {
  margin-top: 18px;
}

.subpanel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(247, 244, 238, 0.72);
}

.subpanel-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.subpanel-heading > div {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.subpanel-heading .section-label {
  margin-bottom: 0;
}

.subpanel-heading .button {
  margin-left: auto;
  align-self: flex-start;
  flex: 0 0 auto;
}

.document-editor-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.document-editor-heading > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.document-editor-back {
  margin-left: auto;
  align-self: flex-start;
  flex: 0 0 auto;
}

.service-directory-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.service-directory-heading > div:first-child {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.service-directory-add {
  margin-left: auto;
  align-self: flex-start;
  flex: 0 0 auto;
}

.service-editor-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.service-editor-heading > div:first-child {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1 1 520px;
}

.service-editor-actions {
  margin-left: auto;
  align-self: flex-start;
  flex: 0 0 auto;
}

.service-editor-back {
  flex: 0 0 auto;
}

.context-links {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(28, 47, 52, 0.1);
  background: rgba(247, 244, 238, 0.72);
}

.link-chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(20, 95, 99, 0.16);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.link-chip:hover,
.link-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(20, 95, 99, 0.28);
  box-shadow: 0 10px 20px rgba(18, 31, 35, 0.05);
}

.link-chip span {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  gap: 12px;
  max-width: 560px;
}

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

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

.inline-button {
  padding: 8px 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(248, 245, 239, 0.96);
}

.report-row {
  cursor: pointer;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.report-row:hover,
.report-row:focus-within {
  background: rgba(20, 95, 99, 0.06);
}

.report-link-note {
  margin-top: 0;
  white-space: nowrap;
}

.report-tab-bar {
  margin-top: 16px;
  flex-wrap: wrap;
}

.report-section {
  min-width: 0;
}

.report-section.is-focused {
  grid-column: 1 / -1;
  border-color: rgba(20, 95, 99, 0.22);
  box-shadow: 0 18px 34px rgba(18, 31, 35, 0.08);
}

.helper-text {
  margin: 0;
  font-size: 0.9rem;
}

.view-panel {
  animation: view-fade 180ms ease;
}

@keyframes view-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .dashboard-main-stack,
  .workspace-grid,
  .record-detail-layout,
  .service-layout,
  .documents-layout,
  .tab-grid,
  .reports-grid,
  .record-highlights-grid {
    grid-template-columns: 1fr;
  }

  .directory-panel,
  .detail-panel {
    min-height: auto;
  }

  .directory-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .record-sidebar {
    position: static;
  }

  .tab-grid .summary-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .document-editor-back {
    margin-left: 0;
  }

  .service-directory-add {
    margin-left: 0;
  }

  .app-header {
    grid-template-columns: 1fr;
  }

  .header-actions {
    align-self: stretch;
    padding-top: 10px;
    border-top: 1px solid rgba(31, 43, 47, 0.08);
    justify-content: flex-start;
  }

  #newAssetAction {
    margin-left: 0;
  }

  .header-actions > .button,
  .header-actions > .field,
  .header-actions > .header-session,
  .header-actions > .persistence-badge {
    flex: 1 1 calc(50% - 10px);
  }

  .dashboard-board,
  .metric-grid,
  .filter-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .subpanel-heading .button {
    margin-left: 0;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    gap: 14px;
    padding: 14px;
  }

  .app-header {
    gap: 16px;
    padding: 18px;
  }

  .brand-block h1 {
    font-size: clamp(1.9rem, 10vw, 2.45rem);
  }

  .brand-block .lede {
    font-size: 0.98rem;
    line-height: 1.5;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    padding-top: 10px;
  }

  .main-nav {
    gap: 8px;
    padding: 6px;
  }

  .header-actions > .button {
    min-width: 0;
    width: 100%;
  }

  .header-actions > .field,
  .header-actions > .header-session,
  .header-actions > .persistence-badge {
    grid-column: 1 / -1;
    width: 100%;
  }

  #dashboardMetrics.metric-grid {
    grid-template-columns: 1fr;
  }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  width: min(720px, 100%);
  background: #fff;
  border: 1px solid rgba(18, 40, 46, 0.08);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(14, 28, 32, 0.08);
  padding: clamp(22px, 3vw, 34px);
}

.auth-copy {
  max-width: 58ch;
  margin: 0 0 20px;
  color: var(--muted-copy);
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-note {
  margin: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(18, 40, 46, 0.04);
  color: var(--muted-copy);
}

.auth-message {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(29, 102, 84, 0.08);
  color: #184a40;
  font-weight: 600;
}

.auth-message.is-error {
  background: rgba(174, 67, 57, 0.1);
  color: #8a2f29;
}

#usersAdminMessage {
  margin: 0;
}

.remember-browser {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted-copy);
  font-size: 0.96rem;
}

.remember-browser input {
  margin-top: 3px;
}

.recovery-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.recovery-code {
  padding: 14px 16px;
  border: 1px dashed rgba(18, 40, 46, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
}

.header-session {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(18, 40, 46, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  max-width: 100%;
}

.header-session-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.header-session-copy strong {
  font-size: 0.95rem;
}

.header-session-copy span {
  color: var(--muted-copy);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

@media (max-width: 960px) {
  .auth-card {
    padding: 24px;
  }

  .recovery-code-grid {
    grid-template-columns: 1fr 1fr;
  }

  .header-session {
    width: 100%;
    justify-content: space-between;
  }
}

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

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .header-actions {
    justify-content: flex-start;
    align-self: stretch;
    padding-top: 10px;
    border-top: 1px solid rgba(31, 43, 47, 0.08);
  }

  #newAssetAction {
    margin-left: 0;
  }
}

/* Protected record history and recovery */
.record-safety-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; box-sizing: border-box; border: 1px solid #d4dfda; border-radius: 16px; padding: 24px; color: #263c33; }
.record-safety-dialog::backdrop { background: rgb(15 35 28 / 45%); }
.record-safety-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.record-safety-header h2 { margin: 0; }
.record-safety-item { padding: 16px 0; border-top: 1px solid #d4dfda; overflow-wrap: anywhere; }
.record-safety-dialog summary { cursor: pointer; }
@media (max-width: 600px) { .record-safety-dialog { padding: 16px; } .record-safety-header { align-items: flex-start; } }

.record-history-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
.record-history-table th, .record-history-table td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid #d4dfda; overflow-wrap: anywhere; }
.record-history-table thead { background: #f3f6f4; }
