:root {
  --bg: #f5f3ee;
  --surface: #fffdf8;
  --surface-2: #ece7df;
  --ink: #20211f;
  --muted: #6f6a61;
  --line: #d8d1c6;
  --blue: #235d8d;
  --green: #2d6f5f;
  --red: #a5483d;
  --yellow: #855a18;
  --shadow: 0 18px 42px rgba(32, 33, 31, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border: 2px solid #ffffff;
  border-radius: 6px;
  background: #111310;
  color: #ffffff;
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:where(button, input, select, textarea, summary, a, [tabindex]):focus-visible {
  outline: 3px solid #0b72b9;
  outline-offset: 3px;
}

:where(h2, main, section, div)[tabindex="-1"]:focus {
  outline: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.form-grid label,
.stack-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.stack-form input,
.stack-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
}

.form-grid textarea,
.stack-form textarea {
  resize: vertical;
}

.stack-form select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
}

.form-grid label:has(input[type="checkbox"]),
.stack-form label:has(input[type="checkbox"]),
.editable-grid label:has(input[type="checkbox"]),
label.checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 36px;
}

.form-grid input[type="checkbox"],
.stack-form input[type="checkbox"],
.editable-grid input[type="checkbox"],
label.checkbox input[type="checkbox"] {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
}

.form-span {
  grid-column: 1 / -1;
}

.stack-form {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stack-form > details {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.stack-form > details > summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.stack-form > details > .form-grid {
  padding-top: 9px;
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #242522;
  color: #faf7ef;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 8px;
}

.brand-mark {
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(250, 247, 239, 0.28);
  background: rgba(250, 247, 239, 0.08);
  border-radius: 8px;
  font-weight: 800;
  font-size: 14px;
}

.brand h1,
.brand p,
.topbar h2,
.panel h3,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.15;
}

.brand p {
  color: rgba(250, 247, 239, 0.62);
  font-size: 12px;
  margin-top: 3px;
}

.nav-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(250, 247, 239, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.nav-modes button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(250, 247, 239, 0.68);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.nav-modes button.active {
  background: rgba(250, 247, 239, 0.14);
  color: #fffdf8;
}

.nav {
  display: grid;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  align-content: start;
}

.nav button {
  width: 100%;
  border: 0;
  color: rgba(250, 247, 239, 0.78);
  background: transparent;
  border-radius: 8px;
  padding: 10px 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: rgba(250, 247, 239, 0.1);
  color: #fffdf8;
}

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(250, 247, 239, 0.2);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.nav-count {
  min-width: 32px;
  text-align: right;
  color: rgba(250, 247, 239, 0.58);
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  color: rgba(250, 247, 239, 0.72);
  font-size: 12px;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--yellow);
}

.state-dot.good {
  background: var(--green);
}

.state-dot.bad {
  background: var(--red);
}

.main {
  min-width: 0;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 27px;
  line-height: 1.1;
}

.top-actions,
.panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.session-user {
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.ghost-button,
.segmented button,
.small-action {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 40px;
  font-weight: 800;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
  font-size: 13px;
}

.small-action {
  min-height: 36px;
  height: auto;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

.small-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.small-action.danger {
  border-color: #b9473f;
  color: #8f2f29;
}

.primary-command {
  min-width: 160px;
  max-width: 240px;
  background: #242522;
  border-color: #242522;
  color: #fffdf8;
}

.action-message {
  border-left: 4px solid var(--blue);
}

.export-menu {
  position: relative;
}

.export-menu summary {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  list-style: none;
}

.export-menu summary::-webkit-details-marker {
  display: none;
}

.export-menu-list {
  position: absolute;
  z-index: 30;
  top: 42px;
  right: 0;
  width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.export-menu-list a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
}

.export-menu-list a:hover {
  background: var(--surface-2);
}

.stack-section {
  min-width: 0;
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.section-heading h3 {
  font-size: 17px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.section-heading p {
  color: var(--muted);
  font-size: 13px;
  max-width: 760px;
}

.secret-rule code {
  display: block;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.login-panel {
  display: grid;
  gap: 14px;
  max-width: 420px;
}

.login-primary-action {
  width: 100%;
  max-width: 420px;
  min-height: 42px;
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.login-primary-action:hover,
.login-primary-action:focus-visible {
  background: #343632;
  color: #ffffff;
}

.local-login-panel.with-sso {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-panel input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.form-error {
  color: var(--red);
  font-size: 13px;
  margin: 0;
}

.metric-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.compact-strip {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.metric {
  min-height: 78px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 25px;
  line-height: 1;
}

.toolbar {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.segmented {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.segmented button {
  min-width: 48px;
  padding: 0 10px;
  background: transparent;
  box-shadow: none;
}

.segmented button.active {
  background: #242522;
  color: #fffdf8;
  border-color: #242522;
}

.search {
  display: grid;
  grid-template-columns: auto minmax(200px, 360px);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.search input {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
}

.content-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.8fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.panel-head {
  min-height: 70px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h3 {
  font-size: 17px;
}

.panel p {
  color: var(--muted);
  font-size: 12px;
  margin: 5px 0 0;
}

.table-wrap {
  min-height: 0;
  min-width: 0;
  overflow: auto;
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 10px 10px 6px;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.wide-table {
  min-width: 1180px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0ebe3;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  white-space: nowrap;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
  max-width: 300px;
  overflow-wrap: break-word;
  word-break: normal;
}

.wide-table th,
.wide-table td {
  min-width: 128px;
}

.wide-table td {
  max-width: 360px;
}

tr:hover td {
  background: #faf8f2;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
}

.pill.good {
  background: #e5f1ed;
  color: var(--green);
  border-color: #c4ded5;
}

.pill.warn {
  background: #f5ead8;
  color: var(--yellow);
  border-color: #e6d0ab;
}

.pill.bad {
  background: #f5dfdc;
  color: var(--red);
  border-color: #e5bbb5;
}

.stack {
  min-width: 0;
  overflow: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-content: start;
}

.stack > *,
.rule,
.mini-list,
.task-outcome-item,
.complete-relationship-task-form {
  min-width: 0;
  max-width: 100%;
}

.rule {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbf8f1;
}

.rule h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.rule p,
.rule li {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.rule ul {
  margin: 8px 0 0;
  padding-left: 16px;
}

.empty {
  padding: 28px;
  color: var(--muted);
  font-size: 13px;
}

.command-empty-state {
  display: grid;
  gap: 6px;
  padding: 18px 0;
}

.command-empty-state strong {
  color: var(--text);
  font-size: 14px;
}

.today-focus,
.today-next {
  padding: 18px;
}

.today-focus {
  display: grid;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.today-focus-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.today-focus-heading h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.today-answer {
  display: grid;
  gap: 5px;
  max-width: 800px;
}

.today-answer strong,
.today-contract strong,
.today-decision-row strong {
  font-size: 13px;
}

.today-answer p,
.today-answer small,
.today-contract li,
.today-decision-row p,
.today-side-section p,
.today-side-section li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.today-answer p,
.today-decision-row p,
.today-side-section p {
  margin: 0;
}

.today-contract {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.today-contract ul,
.today-side-section ul {
  margin: 7px 0 0;
  padding-left: 17px;
}

.today-next {
  display: grid;
  gap: 12px;
}

.today-decision-list {
  display: grid;
}

.today-decision-row {
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.today-decision-row > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.today-side-section {
  display: grid;
  gap: 6px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.today-side-section:last-child {
  border-bottom: 0;
}

.today-side-section h4 {
  margin: 0;
  font-size: 14px;
}

.editable-grid {
  display: grid;
  gap: 8px;
}

.editable-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule pre {
  max-width: 100%;
  margin: 8px 0 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f8f8;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.inline-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #ffffff;
}

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

.inline-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-form .primary-command {
  width: 100%;
  max-width: none;
}

.relationship-controls,
.relationship-save-view,
.relationship-bulk-form,
.relationship-bulk-preview,
.relationship-bulk-receipt,
.relationship-pagination {
  flex: 0 0 auto;
  min-width: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.content-grid.relationship-decision-layout {
  grid-template-columns: minmax(300px, 0.9fr) minmax(440px, 1.1fr);
}

.relationship-decision-focus {
  padding: 18px;
}

.relationship-decision-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.relationship-decision-heading h3,
.relationship-decision-next h4,
.relationship-decision-step h4 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.3;
}

.relationship-decision-location,
.relationship-decision-matter,
.relationship-decision-inspect,
.relationship-decision-next {
  display: grid;
  gap: 5px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.relationship-decision-location strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.relationship-decision-matter p,
.relationship-decision-next p,
.relationship-decision-step p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}

.relationship-decision-state,
.relationship-decision-contract {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.relationship-decision-state div,
.relationship-decision-contract div {
  min-width: 0;
  padding: 10px;
  background: var(--surface);
}

.relationship-decision-state dt,
.relationship-decision-contract dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.relationship-decision-state dd,
.relationship-decision-contract dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.45;
}

.relationship-decision-inspect ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.relationship-decision-next {
  align-items: start;
  background: #eef5f1;
  margin: 0 -18px;
  padding: 16px 18px;
  border-bottom-color: #9fb9ad;
}

.relationship-decision-next .small-action {
  justify-self: start;
  margin-top: 5px;
}

.relationship-decision-contract {
  grid-template-columns: minmax(0, 1fr);
  padding-bottom: 0;
  border-bottom: 0;
}

.relationship-queue-disclosure,
.relationship-supporting-control,
.relationship-history-disclosure {
  min-width: 0;
  border-top: 1px solid var(--line);
}

.relationship-queue-disclosure > summary,
.relationship-supporting-control > summary,
.relationship-history-disclosure > summary {
  padding: 12px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.relationship-supporting-control[open] > summary,
.relationship-history-disclosure[open] > summary {
  border-bottom: 1px solid var(--line);
}

.relationship-supporting-control > .rule,
.relationship-history-disclosure > .rule {
  margin: 10px;
}

.relationship-decision-step {
  margin: -14px -14px 0;
  padding: 16px 14px;
  border-bottom: 1px solid #9fb9ad;
  background: #eef5f1;
}

.relationship-current-action {
  scroll-margin-top: 20px;
  border-color: #9fb9ad;
  box-shadow: inset 4px 0 0 var(--green);
  background: #ffffff;
}

.relationship-decision-layout .relationship-noncurrent-controls {
  display: none;
}

.relationship-due-action-workspace {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.rehearsal-guide {
  padding: 16px;
  border-bottom: 1px solid #9fb9ad;
  background: #eef5f1;
}

.rehearsal-guide-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rehearsal-guide h3,
.rehearsal-record-guide h4 {
  margin: 3px 0 0;
  font-size: 17px;
  line-height: 1.3;
}

.rehearsal-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 10px;
  padding: 0;
  list-style: none;
}

.rehearsal-steps li {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

.rehearsal-steps li.current {
  border-color: var(--green);
  background: #ffffff;
  color: var(--ink);
  box-shadow: inset 4px 0 0 var(--green);
}

.rehearsal-steps li.complete {
  color: var(--green);
}

.rehearsal-steps strong,
.rehearsal-steps span {
  display: block;
}

.rehearsal-steps span {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
}

.rehearsal-record-guide {
  padding: 14px;
  border: 1px solid #9fb9ad;
  border-left: 4px solid var(--green);
  border-radius: 7px;
  background: #eef5f1;
}

.rehearsal-record-guide p {
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.5;
}

#relationship-activity-form,
#relationship-open-tasks {
  scroll-margin-top: 20px;
}

.relationship-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.relationship-pagination > div {
  display: flex;
  gap: 8px;
}

.relationship-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr)) auto auto;
  gap: 8px;
  align-items: end;
  background: #f7f4ed;
}

.relationship-save-view,
.relationship-bulk-form,
.relationship-bulk-preview,
.relationship-bulk-receipt,
.relationship-bulk-preview form,
.relationship-bulk-receipt form {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.relationship-bulk-preview {
  background: #f5ead8;
}

.relationship-bulk-receipt {
  background: #e5f1ed;
}

.relationship-controls label,
.relationship-save-view label,
.relationship-bulk-form label,
.relationship-bulk-preview label,
.relationship-bulk-receipt label {
  display: grid;
  gap: 4px;
  min-width: 120px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.relationship-save-view label:first-child,
.relationship-bulk-preview label,
.relationship-bulk-receipt label {
  min-width: 180px;
}

.relationship-controls .small-action,
.relationship-save-view .small-action,
.relationship-bulk-form .small-action,
.relationship-bulk-preview .small-action,
.relationship-bulk-receipt .small-action {
  min-height: 35px;
}

.checkline {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  min-width: 92px !important;
  min-height: 35px;
}

.checkline input,
.select-relationship-row {
  width: 26px;
  height: 26px;
  margin: 0;
}

.mini-kpi {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

textarea.inline-input {
  min-height: 86px;
  resize: vertical;
}

.link-action {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.mini-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mini-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-row strong {
  font-size: 11px;
  color: var(--muted);
}

.mini-row small {
  grid-column: 1 / -1;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.mini-row.active {
  border-color: var(--accent);
  background: #eef6f3;
}

.task-outcome-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.task-outcome-item summary {
  display: grid;
  gap: 3px;
  padding: 10px;
  cursor: pointer;
}

.task-outcome-item summary small {
  color: var(--muted);
  font-size: 11px;
}

.task-outcome-item[open] summary {
  border-bottom: 1px solid var(--line);
}

.complete-relationship-task-form {
  padding: 10px;
}

.form-consequence {
  margin: 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

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

  .content-grid.relationship-decision-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .shell {
    display: block;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    gap: 8px;
    padding: 8px 10px;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
  }

  .brand {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 2px;
  }

  .brand-mark {
    height: 36px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p,
  .sidebar-footer,
  .nav-count {
    display: none;
  }

  .nav-modes {
    width: 100%;
  }

  .nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    padding: 0;
  }

  .nav button {
    width: 100%;
    min-width: 0;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
    padding: 7px 8px;
    white-space: normal;
  }

  .nav-icon {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  .main {
    padding: 12px;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  .metric-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    overflow: visible;
    padding-bottom: 0;
  }

  .metric-strip .metric {
    min-width: 0;
    min-height: 68px;
  }

  .metric-strip .metric strong {
    font-size: 21px;
  }

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

  .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions,
  .panel-actions {
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    padding-bottom: 0;
  }

  .panel-actions > * {
    flex: 0 1 auto;
    max-width: 100%;
  }

  .session-user {
    flex: 1 1 100%;
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .toolbar,
  .content-grid,
  .panel,
  .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .content-grid > .panel:not(.panel-wide) {
    order: 2;
  }

  .content-grid > .panel-wide {
    order: 1;
  }

  .content-grid.today-layout > .panel-wide {
    order: 1;
  }

  .content-grid.today-layout > .panel:not(.panel-wide) {
    order: 2;
  }

  .content-grid.relationship-batch-layout > .panel-wide {
    order: 1;
  }

  .content-grid.relationship-batch-layout > .panel:not(.panel-wide) {
    order: 2;
  }

  .content-grid.relationship-decision-layout > .panel-wide {
    order: 1;
  }

  .content-grid.relationship-decision-layout > .panel:not(.panel-wide) {
    order: 2;
  }

  .content-grid.jobs-layout > .panel-wide {
    order: 1;
  }

  .content-grid.jobs-layout > .panel:not(.panel-wide) {
    order: 2;
  }

  .content-grid.login-layout > .panel-wide {
    order: 1;
  }

  .content-grid.login-layout > .panel:not(.panel-wide) {
    order: 2;
  }

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

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

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

  .rehearsal-guide-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .rehearsal-steps {
    grid-template-columns: 1fr;
  }

  .relationship-decision-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .relationship-decision-state,
  .relationship-decision-inspect ul {
    grid-template-columns: minmax(0, 1fr);
  }

  .relationship-controls .small-action {
    width: 100%;
  }

  .relationship-save-view,
  .relationship-bulk-form,
  .relationship-bulk-preview,
  .relationship-bulk-receipt,
  .relationship-bulk-preview form,
  .relationship-bulk-receipt form {
    align-items: stretch;
  }

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

  .relationship-pagination > div,
  .relationship-pagination .small-action {
    width: 100%;
  }

  .relationship-save-view label,
  .relationship-bulk-form label,
  .relationship-bulk-preview label,
  .relationship-bulk-receipt label {
    flex: 1 1 150px;
    min-width: 0;
  }

  .relationship-bulk-form .bulk-operation-field {
    flex-basis: 100%;
  }

  .today-focus,
  .today-next {
    padding: 14px;
  }

  .today-contract {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

  .today-decision-row .small-action {
    width: 100%;
    max-width: none;
  }
}

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

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

  .panel-actions > * {
    width: 100%;
    max-width: none;
  }
}
