:root {
  --ink: #1a2429;
  --ink-soft: #4b5b63;
  --paper: #f5efe3;
  --paper-strong: #ece2ce;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.95);
  --accent: #0e7a6b;
  --accent-strong: #08584d;
  --accent-warm: #c6864b;
  --accent-cool: #3f6e8f;
  --border: rgba(26, 36, 41, 0.14);
  --border-strong: rgba(26, 36, 41, 0.24);
  --shadow: 0 18px 40px rgba(13, 26, 31, 0.12);
  --shadow-soft: 0 8px 18px rgba(13, 26, 31, 0.08);
  --radius: 18px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --transition: 170ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(198, 134, 75, 0.16), transparent 32%),
    radial-gradient(circle at 88% 0%, rgba(14, 122, 107, 0.13), transparent 32%),
    linear-gradient(180deg, #faf6ee 0%, var(--paper) 52%, #efe4cf 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-family: 'Fraunces', serif;
  margin: 0 0 0.58rem;
  letter-spacing: 0.2px;
  line-height: 1.22;
}

h1 {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.2rem);
}

h2 {
  font-size: clamp(1.2rem, 1rem + 0.7vw, 1.55rem);
}

p {
  line-height: 1.62;
  margin: 0 0 1rem;
}

a {
  color: inherit;
  text-decoration: none;
}

.background-orbit {
  position: fixed;
  inset: -24% 0 auto;
  height: 64vh;
  background: radial-gradient(circle, rgba(198, 134, 75, 0.16), rgba(14, 122, 107, 0.07) 44%, transparent 72%);
  filter: blur(14px);
  z-index: 0;
}

.background-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(26, 36, 41, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 36, 41, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  z-index: 0;
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.4rem clamp(0.9rem, 2.2vw, 2.3rem) 3rem;
}

.app-header {
  position: sticky;
  top: 0.9rem;
  z-index: 60;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.2rem;
  padding: 0.9rem 1.1rem;
  background: rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  animation: fadeSlide 0.52s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(140deg, var(--accent), var(--accent-warm));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: 'Fraunces', serif;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.15px;
}

.brand-sub {
  font-size: 0.77rem;
  color: var(--ink-soft);
}

.app-nav {
  justify-self: center;
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

.nav-link {
  padding: 0.42rem 0.84rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.89rem;
  color: var(--ink-soft);
  transition: var(--transition);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(14, 122, 107, 0.2), rgba(63, 110, 143, 0.12));
  color: var(--accent-strong);
}

.nav-link:hover {
  color: var(--accent-strong);
  background: rgba(14, 122, 107, 0.1);
}

.user-chip {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: right;
  font-size: 0.8rem;
  min-width: 170px;
}

.user-email {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.app-main {
  margin-top: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  gap: 0.62rem;
  flex-wrap: wrap;
  align-items: center;
}

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

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  animation: fadeSlide 0.45s ease;
}

.card > :last-child {
  margin-bottom: 0;
}

[id] {
  scroll-margin-top: 5.8rem;
}

.card:target,
.cms-panel:target {
  border-color: rgba(8, 88, 77, 0.4);
  box-shadow: 0 0 0 3px rgba(8, 88, 77, 0.15), var(--shadow);
}

.doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  transition: var(--transition);
}

.doc-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.doc-type {
  font-size: 0.69rem;
  text-transform: uppercase;
  letter-spacing: 0.14rem;
  color: var(--accent-strong);
  font-weight: 700;
}

.empty-state {
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  border-radius: 999px;
  padding: 0.57rem 1.08rem;
  border: 1px solid transparent;
  background: linear-gradient(145deg, var(--accent-strong), #0d6b5e);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 10px 18px rgba(8, 88, 77, 0.18);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(8, 88, 77, 0.24);
}

.btn:focus-visible {
  outline: 2px solid rgba(8, 88, 77, 0.42);
  outline-offset: 2px;
}

.btn.btn-outline {
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
  border: 1px solid rgba(8, 88, 77, 0.26);
  box-shadow: none;
}

.btn.btn-outline:hover {
  background: rgba(8, 88, 77, 0.08);
  box-shadow: none;
}

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

label {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.34rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.67rem 0.76rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: 'Manrope', sans-serif;
  font-size: 0.94rem;
  margin-bottom: 0.8rem;
  background: var(--panel-strong);
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: rgba(8, 88, 77, 0.55);
  box-shadow: 0 0 0 3px rgba(8, 88, 77, 0.16);
}

.reference-input {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.reference-prefix {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--paper-strong);
  font-weight: 600;
  white-space: nowrap;
}

.reference-input input {
  margin-bottom: 0;
  flex: 1;
}

textarea {
  resize: vertical;
}

.small {
  font-size: 0.82rem;
}

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

.banner {
  border-radius: var(--radius-sm);
  padding: 0.78rem 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
}

.banner-success {
  border-color: rgba(42, 127, 111, 0.3);
  background: rgba(42, 127, 111, 0.12);
}

.banner-error {
  border-color: rgba(197, 73, 46, 0.3);
  background: rgba(197, 73, 46, 0.12);
}

.banner-warning {
  border-color: rgba(217, 144, 79, 0.3);
  background: rgba(217, 144, 79, 0.18);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.15rem;
}

.auth-panel {
  display: grid;
  gap: 1rem;
}

.feature-list {
  padding-left: 1.2rem;
  margin: 1rem 0 0;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 2rem;
  align-items: start;
}

.editor-shell.editor-shell-case {
  grid-template-columns: minmax(0, 1.6fr) minmax(240px, 320px);
}

.editor-meta {
  display: grid;
  gap: 1.5rem;
}

.editor-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
}

.editor-toolbar button {
  border: 1px solid rgba(31, 36, 33, 0.2);
  background: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.editor-toolbar button:hover {
  background: rgba(42, 127, 111, 0.12);
}

.editor {
  min-height: 520px;
  border-radius: var(--radius);
  padding: 2rem;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.editor:focus {
  outline: 2px solid rgba(42, 127, 111, 0.4);
}

.doc {
  font-family: 'Fraunces', serif;
  color: var(--ink);
}

.doc h1,
.doc h2,
.doc h3 {
  font-family: 'Fraunces', serif;
}

.doc-meta {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.doc-court {
  text-transform: uppercase;
  letter-spacing: 0.18rem;
  font-size: 0.85rem;
}

.doc-sign {
  margin-top: 2rem;
  font-weight: 600;
}

sup {
  font-size: 0.75em;
  vertical-align: super;
}

cite {
  font-style: italic;
}

.doc-footnotes {
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding-left: 1.2rem;
  margin-top: 0.6rem;
}

.doc-footnotes li {
  margin-bottom: 0.4rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 0.56rem 0.68rem;
  text-align: left;
  border-bottom: 1px solid rgba(26, 36, 41, 0.09);
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
  font-size: 0.68rem;
  color: var(--ink-soft);
  background: rgba(240, 234, 221, 0.88);
}

.data-table tbody tr:nth-child(2n) {
  background: rgba(14, 122, 107, 0.03);
}

.data-table tbody tr:hover {
  background: rgba(14, 122, 107, 0.07);
}

.audit-filter-form {
  margin-top: 0.6rem;
}

.audit-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem 0.85rem;
  align-items: end;
}

.audit-filter-grid input,
.audit-filter-grid select {
  margin-bottom: 0;
}

.audit-filter-actions {
  margin-top: 0.95rem;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.audit-summary-row {
  margin-bottom: 0.7rem;
}

.audit-table {
  min-width: 980px;
}

.audit-target-links {
  display: grid;
  gap: 0.25rem;
}

.audit-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-strong);
}

.audit-json {
  margin-top: 0.55rem;
  max-height: 300px;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  padding: 0.55rem;
  font-size: 0.76rem;
  line-height: 1.45;
}

.audit-pagination {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.audit-page-links {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.audit-page-link,
.audit-page-current {
  min-width: 2rem;
  text-align: center;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.audit-page-link {
  border: 1px solid rgba(8, 88, 77, 0.26);
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.8);
}

.audit-page-link:hover {
  background: rgba(8, 88, 77, 0.09);
}

.audit-page-current {
  border: 1px solid rgba(8, 88, 77, 0.35);
  color: #fff;
  background: linear-gradient(145deg, var(--accent-strong), #0d6b5e);
}

.link {
  color: var(--accent-strong);
  font-weight: 600;
  text-underline-offset: 0.18em;
}

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

.note-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.75rem;
}

.note-list li {
  padding: 0.84rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid rgba(14, 122, 107, 0.22);
  background: rgba(255, 255, 255, 0.75);
}

.note-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.order-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.75rem;
}

.order-list li {
  padding: 0.84rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid rgba(63, 110, 143, 0.25);
  background: rgba(255, 255, 255, 0.75);
}

.status-history {
  margin-top: 1rem;
}

.status-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.status-history-list li {
  padding: 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.74);
}

.case-jump {
  display: grid;
  gap: 0.55rem;
}

.jump-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.jump-link {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.68rem;
  border-radius: 999px;
  border: 1px solid rgba(8, 88, 77, 0.2);
  background: rgba(8, 88, 77, 0.06);
  color: var(--accent-strong);
  font-size: 0.81rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: var(--transition);
}

.jump-link:hover {
  background: rgba(8, 88, 77, 0.12);
  border-color: rgba(8, 88, 77, 0.34);
}

.child-list {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.child-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.child-nights input {
  margin-bottom: 0;
}

.child-actions {
  padding-bottom: 0.75rem;
}

.child-summary {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.cms-card {
  display: grid;
  gap: 1.2rem;
}

.cms-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.cms-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.cms-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.cms-preferences {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

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

.cms-preferences select {
  width: auto;
  min-width: 140px;
  margin-bottom: 0;
}

.cms-grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
}

.cms-summary,
.cms-links {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.7);
}

.cms-amount {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-bottom: 0.25rem;
}

.cms-metadata {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.cms-notes,
.cms-links ul,
.cms-shared-care ul {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 0;
  display: grid;
  gap: 0.35rem;
}

.cms-primary {
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cms-primary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  color: var(--ink-soft);
}

.cms-primary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.cms-panels {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
}

.cms-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.cms-panel > summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem;
}

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

.cms-panel-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.cms-panel-summary h3 {
  margin: 0;
}

.cms-panel-summary p {
  margin: 0.25rem 0 0;
}

.cms-panel-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-weight: 700;
  flex: 0 0 auto;
}

.cms-panel-toggle::after {
  content: "+";
}

.cms-panel > summary:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.cms-panel[open] > summary {
  border-bottom: 1px solid var(--border);
}

.cms-panel[open] .cms-panel-toggle::after {
  content: "-";
}

.cms-panel-body {
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.cms-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.cms-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  display: grid;
  gap: 0.35rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cms-item.latest {
  border-color: rgba(29, 92, 81, 0.35);
  background: rgba(29, 92, 81, 0.08);
}

.cms-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cms-item-title {
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cms-item-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cms-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
  background: rgba(29, 92, 81, 0.12);
  color: var(--accent-strong);
}

.cms-tag.neutral {
  background: rgba(91, 99, 102, 0.12);
  color: var(--ink-soft);
}

.cms-tag.success {
  background: rgba(42, 127, 111, 0.16);
  color: var(--accent-strong);
}

.cms-tag.warning {
  background: rgba(207, 142, 41, 0.18);
  color: #8a5300;
}

.cms-tag.danger {
  background: rgba(186, 57, 57, 0.16);
  color: #8b1a1a;
}

.cms-file-list {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  display: grid;
  gap: 0.25rem;
}

.cms-file-list a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cms-details {
  border-top: 1px dashed var(--border);
  padding-top: 0.6rem;
}

.cms-details summary {
  cursor: pointer;
  font-weight: 600;
}

.cms-form {
  margin-top: 0.5rem;
}

.cms-steps {
  display: grid;
  gap: 1rem;
}

.cms-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.8);
}

.cms-step-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.8rem;
}

.cms-step-number {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(29, 92, 81, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.cms-step-fields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.order-link {
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
}

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

.order-link:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.order-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.order-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

.order-actions form {
  margin: 0;
  display: inline-flex;
  flex: 0 0 auto;
  width: auto;
}

.order-actions .btn {
  flex: 0 0 auto;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 34, 31, 0.48);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-dialog-wide {
  width: min(980px, 95vw);
}

.modal-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: 0 24px 60px rgba(22, 34, 31, 0.3);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.modal-delete {
  margin-top: 0.4rem;
}

.text-link {
  border: none;
  background: none;
  padding: 0;
  font-weight: 600;
  color: var(--accent-strong);
  cursor: pointer;
  transition: var(--transition);
}

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

.text-link.danger {
  color: #9a2c2c;
}

.inline-action-form {
  display: inline-block;
  margin-left: 0.6rem;
}

body.modal-open {
  overflow: hidden;
}


.order-meta {
  margin-top: 0.35rem;
}

.order-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02rem;
  text-transform: uppercase;
  background: rgba(217, 144, 79, 0.18);
  color: #8a4f1d;
}

.order-form {
  margin-top: 1rem;
}

.bundle-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 1rem;
}

.bundle-list li {
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.bundle-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.bundle-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.bundle-warning {
  color: #8a4f1d;
  font-size: 0.85rem;
  font-weight: 600;
}

.bundle-form {
  margin-top: 1rem;
}

.bundle-guidance {
  margin: 0.8rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
}

.bundle-guidance h4 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.bundle-guidance-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}

.bundle-guidance-list li {
  margin-bottom: 0.35rem;
}

.bundle-export-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.bundle-tool-status {
  margin: 0.75rem 0;
}

.bundle-tool-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.bundle-tool-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.bundle-tool-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9db0a4;
  flex: none;
}

.bundle-tool-dot.ok {
  background: #2a7f6f;
}

.bundle-tool-dot.missing {
  background: #d9904f;
}

.bundle-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.comm-form {
  margin-top: 1rem;
}

.guidance-list-simple {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

.guidance-list-simple li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.guidance-list-simple li:last-child {
  border-bottom: none;
}

.guidance-inline-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.guidance-settings {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.guidance-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 1rem;
}

.guidance-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.guidance-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.guidance-post {
  line-height: 1.7;
}

.header-actions form {
  margin: 0;
}

.handover-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.handover-preview {
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.handover-render {
  line-height: 1.55;
}

.handover-render h1,
.handover-render h2,
.handover-render h3,
.handover-render h4 {
  margin: 0.9rem 0 0.4rem;
  color: var(--ink);
}

.handover-render h1 {
  font-size: 1.15rem;
}

.handover-render h2 {
  font-size: 1.03rem;
}

.handover-render h3,
.handover-render h4 {
  font-size: 0.95rem;
}

.handover-render p {
  margin: 0.45rem 0;
}

.handover-render ul,
.handover-render ol {
  margin: 0.5rem 0 0.7rem 1.2rem;
}

.handover-render blockquote {
  margin: 0.75rem 0;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border);
  color: var(--ink-soft);
}

.handover-archives {
  margin-top: 1.25rem;
}

.handover-archive-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.handover-archive-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
}

.handover-archive-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.handover-archive-item > summary::-webkit-details-marker {
  display: none;
}

.handover-archive-content {
  padding: 0 1rem 1rem;
  display: grid;
  gap: 0.9rem;
}

.handover-archive-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.link-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.75rem;
}

.link-list li {
  padding: 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.link-form {
  margin-top: 1rem;
}

.letterhead,
.letter-to {
  margin-bottom: 1rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.radio-row {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.radio-row input {
  margin-right: 0.4rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.toggle-label {
  font-weight: 600;
  color: var(--ink-soft);
}

.toggle {
  position: relative;
  width: 3rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(29, 92, 81, 0.12);
  transition: var(--transition);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  top: 50%;
  left: 0.2rem;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 8px rgba(22, 34, 31, 0.2);
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: rgba(29, 92, 81, 0.25);
  border-color: rgba(29, 92, 81, 0.4);
}

.toggle input:checked + .toggle-slider::after {
  transform: translate(1.4rem, -50%);
}

.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.is-loaded .card,
.is-loaded .app-header {
  animation: fadeSlide 0.6s ease;
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1000px) {
  .app-header {
    position: relative;
    top: 0;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .app-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    white-space: nowrap;
    flex-wrap: nowrap;
  }

  .user-chip {
    text-align: left;
    min-width: 0;
  }

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

@media (max-width: 800px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .page-header {
    align-items: flex-start;
  }

  .card {
    padding: 0.95rem;
  }

  .child-row {
    grid-template-columns: 1fr;
  }

  .child-actions {
    padding-bottom: 0;
  }

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

  .cms-step-fields {
    grid-template-columns: 1fr;
  }

  .jump-links {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
