/* Ticket #131: existing UPS card only; estimates are never measured power. */
:is(#ups-card,#ups-panel){min-width:0;overflow-wrap:anywhere}
:is(#ups-card,#ups-panel) .ups-estimate-grid,:is(#ups-card,#ups-panel) .ups-history-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:12px 0}
:is(#ups-card,#ups-panel) .ups-estimate-grid>div{min-width:0}
:is(#ups-card,#ups-panel) .ups-estimate-grid dt{font-size:12px;opacity:.8}
:is(#ups-card,#ups-panel) .ups-estimate-grid dd{margin:4px 0;font-weight:650}
:is(#ups-card,#ups-panel) .ups-draw-history{border-top:1px solid var(--line,#3b3d45);padding-top:12px;margin-top:16px}
:is(#ups-card,#ups-panel) .ups-warning{border-left:4px solid #96928b;padding:10px 12px;border-radius:6px;background:rgba(150,146,139,.08)}
:is(#ups-card,#ups-panel) .ups-warning[data-severity="warning"]{border-color:#e7bd67;color:#e7bd67;background:rgba(231,189,103,.08)}
:is(#ups-card,#ups-panel) .ups-warning[data-severity="critical"]{border-color:#ff857a;color:#ffb4ac;background:rgba(255,133,122,.12)}
:is(#ups-card,#ups-panel) .ups-warning[data-severity="healthy"]{border-color:#75d895}
:is(#ups-card,#ups-panel) .ups-history-plot{min-width:0;margin-top:14px}
@media(max-width:700px){:is(#ups-card,#ups-panel) .ups-history-grid,:is(#ups-card,#ups-panel) .ups-estimate-grid{grid-template-columns:minmax(0,1fr)}}
@media(max-width:600px){#ups-panel .health-detail-list.health-detail-list>div{display:block}#ups-panel .health-detail-list.health-detail-list dd{margin:4px 0;white-space:nowrap}}

/* Native Watchdog: compact grouped inventory and per-device pressure. */
.home-watchdog-native #disk-device-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.home-watchdog-native .disk-device-card { min-width: 0; }
.home-watchdog-native .device-pressure-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.home-watchdog-native .resource-pressure { margin-top: 12px; display: grid; gap: 8px; }
.home-watchdog-native #labelled-processes { max-height: 34rem; overflow: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.home-watchdog-native .program-group { padding: 10px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.home-watchdog-native .program-group > summary { cursor: pointer; line-height: 1.6; }
.home-watchdog-native .program-group .process-group { margin: 10px 0 10px 12px; }
.home-watchdog-native #storage-card .crm-disk-usage { margin-top: 18px; }
.home-watchdog-native .pressure-diagnostics { margin-top: 18px; }
#ups-panel .health-detail-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
#ups-panel .health-detail-list > div { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; }
@media (max-width: 800px) {
 .home-watchdog-native #disk-device-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
 #ups-panel .health-detail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
 .home-watchdog-native .device-pressure-charts { grid-template-columns: minmax(0, 1fr); }
}

/* UPS is an independent read-only panel; wrap long model/status text on phones. */
#ups-panel { min-width: 0; overflow-wrap: anywhere; }
#ups-panel .panel-title { flex-wrap: wrap; gap: 12px; }
#ups-panel .panel-title > div { min-width: 0; max-width: 100%; }
#ups-panel h2, #ups-panel .pressure-status { white-space: normal; }
#ups-panel .health-detail-list > div { min-width: 0; }
@media (max-width: 600px) {
  #ups-panel .health-detail-list > div { grid-template-columns: minmax(0, 1fr) auto; }
}

:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
}

.skip {
  position: fixed;
  z-index: 1000;
  top: 16px;
  left: -10000px;
}

.skip:focus-visible {
  left: 16px;
  background: var(--paper);
  color: #171717;
  padding: 12px 16px;
  border-radius: 10px;
}

.simulator-bar,
.mode-control,
#simulation-notice {
  display: none !important;
}

.brand small {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
}

.nav-link .section-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-status-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.live-status-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 44px;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 9px 12px;
  white-space: nowrap;
}



.live-status-trigger:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
}

.live-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(215, 211, 202, .12);
}

.live-status-trigger[data-status-state="checking"] .live-status-dot {
  animation: live-status-pulse 1.4s ease-in-out infinite;
}

.live-status-trigger[data-status-state="current"] .live-status-dot {
  background: var(--status-good);
  box-shadow: 0 0 0 3px rgba(117, 216, 149, .16);
}

.live-status-trigger[data-status-state="stale"] .live-status-dot {
  background: var(--status-warn);
  box-shadow: 0 0 0 3px rgba(231, 189, 103, .16);
}

.live-status-trigger[data-status-state="offline"] .live-status-dot {
  background: var(--status-bad);
  box-shadow: 0 0 0 3px rgba(255, 133, 122, .16);
}

.live-status-trigger[data-status-state="unavailable"] .live-status-dot {
  background: #8d94a3;
}

.live-status-panel {
  position: fixed;
  z-index: 60;
  top: max(72px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: min(390px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 96px));
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-card);
  color: var(--ink);
  box-shadow: var(--shadow-elevated);
  padding: 14px;
}

.live-status-panel:not([open]) {
  display: none !important;
}

.live-status-panel-head,
.live-status-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.live-status-panel h2 {
  margin: 0;
  font-size: 15px;
}

.live-status-close,
.live-status-actions button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--ink);
}

.live-status-evidence {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.live-status-row {
  display: grid;
  grid-template-columns: minmax(104px, .42fr) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  background: var(--surface-soft);
}

.live-status-row dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.live-status-row dd {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.live-status-panel .microcopy {
  color: var(--muted);
}

.live-status-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

@keyframes live-status-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(215, 211, 202, .1); }
  50% { box-shadow: 0 0 0 7px rgba(215, 211, 202, .04); }
}

@media (max-width: 900px) {

  .live-status-trigger {
    padding-inline: 10px;
  }
}

@media (max-width: 520px) {
  .live-status-panel {
    top: 64px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 76px);
  }

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

@media (prefers-reduced-motion: reduce) {
  .live-status-dot {
    animation: none !important;
  }
}

.planning-live-stack {
  display: grid;
  gap: 16px;
}

.watchdog-live-card[data-truth-state="fresh"],
.watchdog-live-card[data-truth-state="healthy"] {
  border-color: rgba(154, 214, 169, .55);
}

.watchdog-live-card[data-truth-state="stale"],
.watchdog-live-card[data-truth-state="partial"] {
  border-color: rgba(240, 205, 128, .58);
}

.watchdog-live-card[data-truth-state="unavailable"] {
  border-color: rgba(239, 155, 155, .58);
}

.watchdog-live-card strong,
.watchdog-live-card span,
.watchdog-live-card a {
  display: block;
  margin-top: 6px;
}

.home-dashboard-link {
  font-weight: 800;
}

[data-agent-live-target] {
  display: grid;
  gap: 18px;
}

[data-agent-live-target] > h3 {
  margin: 8px 0 0;
  color: var(--paper);
  font-size: 16px;
  line-height: 1.3;
}

[data-agent-live-target] > h3:first-of-type {
  margin-top: 0;
}

[data-agent-results] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

[data-agent-results="mia"] {
  grid-template-columns: minmax(0, 1fr);
}

.agents-owner-banner,
.agents-activity-card,
.light-profile-card {
  border: 1px solid rgba(215, 211, 202, .48);
  border-radius: 8px;
  background: var(--paper);
  color: #202227;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
}

.agents-owner-banner {
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.55;
}

.agents-activity-card,
.light-profile-card {
  padding: 16px;
}

.agents-activity-card h3,
.light-profile-card h3,
.light-profile-card p,
.light-profile-card small {
  color: #202227;
}

.agents-activity-card h3,
.light-profile-card h3 {
  margin: 0 0 10px;
  line-height: 1.25;
}

.agents-activity-card p,
.light-profile-card p {
  margin-bottom: 0;
}

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

.agent-role-label {
  flex-shrink: 0;
  border: 1px solid rgba(32, 34, 39, .18);
  border-radius: 999px;
  padding: 5px 8px;
  color: #3f4249;
  font-size: 11px;
  font-weight: 800;
}

.agent-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.agent-facts div {
  min-width: 0;
  border: 1px solid rgba(32, 34, 39, .16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, .28);
}

.agent-facts dt {
  color: #5d5f66;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.agent-facts dd {
  margin: 5px 0 0;
  color: #202227;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.agent-source-note {
  margin-top: 12px;
  color: #6d5528 !important;
  font-size: 12px;
  font-weight: 800;
}

.disabled-authority {
  opacity: .78;
}

.mia-service-strip {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
}

.mia-service-strip span {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151d;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.mia-service-strip span::before {
  color: var(--paper);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.mia-service-strip [data-mia-service-state]::before {
  content: "Status";
}

.mia-service-strip [data-mia-session-id]::before {
  content: "Session";
}

.mia-service-strip [data-mia-live-authority] {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.mia-service-strip [data-mia-live-authority]::before {
  content: "Authority";
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.mia-service-strip [data-mia-live-message]::before {
  content: "Bridge";
}

.mia-service-strip [data-mia-error]::before {
  content: "Errors";
}

.mia-service-strip [data-mia-error]:empty::after {
  color: var(--muted);
  content: "None";
}

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

.mia-simple-form label {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.mia-simple-form label span {
  display: block;
  line-height: 1.35;
}

.mia-simple-form input,
.mia-simple-form textarea {
  display: block;
}

.mia-simple > .panel-head {
  align-items: flex-start;
  flex-wrap: wrap;
}

.mia-simple > .panel-head .badge {
  flex: 0 0 auto;
  white-space: nowrap;
}



.mia-transcript {
  overflow-wrap: anywhere;
}

.canvas-frame-wrap iframe {
  min-height: 320px;
  width: 100%;
}

[data-mia-canvas-code] {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

[data-mia-canvas-history] span {
  display: block;
  min-width: 1px;
  width: 100%;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100%;
    min-width: 0;
  }

  .workspace,
  .content,
  .page-head,
  .panel,
  .card,
  .mia-layout,
  .mia-detail,
  .mia-view-panel,
  .mia-canvas-grid,
  .stats {
    max-width: 100%;
    min-width: 0;
  }

  .mia-view-panel[data-mia-conversation] .mia-service-strip {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }
}

.accounting-workspace {
  display: grid;
  gap: 14px;
  max-width: 100%;
  min-width: 0;
  background: #111714;
  color: #edf4ef;
}

.accounting-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #314039;
  border-radius: 15px;
  background: #17201c;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
}

.accounting-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 15px 17px;
  border-bottom: 1px solid #314039;
}

.accounting-card-head h1,
.accounting-card-head h2,
.accounting-card-head h3,
.accounting-card-head p {
  margin: 0;
}

.accounting-card-head h1,
.accounting-card-head h2 {
  color: #f3f8f4;
  font-size: 20px;
  letter-spacing: -.02em;
}

.accounting-card-head p:not(.eyebrow),
.accounting-card-head small,
.accounting-basis,
.accounting-source-foot,
.accounting-tax-toolbar small {
  color: #98a79f;
  font-size: 12px;
}

.accounting-head-actions,
.accounting-card-head .actions {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.accounting-workspace .badge {
  border-color: #3b4b44;
  background: #1d2a24;
  color: #dbe8e0;
}

.accounting-primary-button,
.accounting-workspace .secondary,
.accounting-link-button,
.accounting-workspace button,
.accounting-workspace input,
.accounting-workspace select {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

.accounting-primary-button,
.accounting-workspace .secondary,
.accounting-workspace button {
  border: 1px solid #3b4b44;
  background: #1d2a24;
  color: #dbe8e0;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.accounting-primary-button,
.accounting-workspace button.accounting-primary-button {
  border-color: #dcebe4;
  background: #dcebe4;
  color: #173f36;
}

.accounting-workspace button:disabled,
.accounting-workspace select:disabled,
.accounting-workspace input:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.accounting-link-button {
  border: 0;
  background: transparent;
  color: #84c7b2;
  padding: 8px 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.accounting-status-strip {
  margin: 11px 14px 0;
  padding: 9px 11px;
  border: 1px solid #6c532f;
  border-radius: 9px;
  background: #2c2418;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.accounting-status-strip.ok {
  border-color: #426f60;
  background: #172a23;
}

.accounting-status-strip.blocked {
  border-color: #70413b;
  background: #2b1b19;
}

.accounting-status-main {
  display: flex;
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.accounting-status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d89a4e;
  box-shadow: 0 0 0 4px rgba(216, 154, 78, .12);
}

.accounting-status-strip.ok .accounting-status-dot { background: #75bda6; box-shadow: 0 0 0 4px rgba(117, 189, 166, .12); }
.accounting-status-strip.blocked .accounting-status-dot { background: #dd8b82; box-shadow: 0 0 0 4px rgba(221, 139, 130, .12); }
.accounting-status-strip strong { display: block; color: #f7d5a2; }
.accounting-status-strip.ok strong { color: #bfe6d7; }
.accounting-status-strip span { color: #c7b79f; }
.accounting-status-strip.ok span { color: #a9c9bd; }

.accounting-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 14px 0;
  padding: 4px;
  border: 1px solid #314039;
  border-radius: 10px;
  background: #101713;
  width: max-content;
  max-width: calc(100% - 28px);
}

.accounting-tabs [role="tab"] {
  border: 0;
  background: transparent;
  color: #91a097;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 780;
}

.accounting-tabs [role="tab"][aria-selected="true"] {
  background: #dcebe4;
  color: #173f36;
}

.accounting-pane[hidden] { display: none !important; }
.accounting-pane.active { display: grid; gap: 0; }

.accounting-table-wrap,
.accounting-transactions-scroll {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.accounting-table-wrap {
  margin: 11px 14px 0;
  border: 1px solid #2c3933;
  border-radius: 10px;
}

.accounting-field-table,
.accounting-transactions-table {
  width: 100%;
  border-collapse: collapse;
}

.accounting-field-table {
  min-width: 760px;
  font-size: 12px;
}

.accounting-field-table th,
.accounting-field-table td,
.accounting-transactions-table th,
.accounting-transactions-table td {
  padding: 8px 9px;
  border-bottom: 1px solid #2c3933;
  text-align: left;
  vertical-align: middle;
}

.accounting-field-table th,
.accounting-transactions-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #17201c;
  color: #8fa097;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.accounting-field-table td:nth-child(2),
.accounting-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  white-space: nowrap;
}

.accounting-amount.in { color: #8bceb9; }
.accounting-amount.out { color: #f2c083; }

.accounting-state {
  color: #81b6cd;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.accounting-state.ok { color: #85cbb5; }
.accounting-state.warn { color: #f1b76d; }
.accounting-state.blocked { color: #dd8b82; }
.ticket-card .badge.blocked, .ticket-accept-controls button.blocked {
  color: #8d251d; background: #fff0ed; border: 1px solid #d0533f; opacity: 1;
}
.accounting-state.info { color: #81b6cd; }

.accounting-source-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 0;
  border-top: 1px solid #314039;
}

.accounting-source-metric {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid #314039;
}

.accounting-source-metric:last-child { border-right: 0; }
.accounting-source-metric span { display: block; color: #8fa097; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.accounting-source-metric strong { display: block; margin-top: 2px; overflow-wrap: anywhere; font-size: 15px; }
.accounting-source-foot { margin: 0; padding: 8px 14px; border-top: 1px solid #29352f; }

.accounting-tax-toolbar,
.accounting-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid #314039;
}

.accounting-tax-toolbar { justify-content: space-between; border-top: 1px solid #314039; }
.accounting-tax-toolbar strong { display: block; }

.accounting-tax-section,
.accounting-annual-package,
.accounting-confirmation-panel {
  margin: 12px 14px 0;
  border: 1px solid #314039;
  border-radius: 11px;
  background: #141d19;
  overflow: hidden;
}

.accounting-tax-section-head,
.accounting-annual-package {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.accounting-tax-section-head { border-bottom: 1px solid #2c3933; }
.accounting-tax-section-head h3,
.accounting-annual-package h3,
.accounting-period-card h4,
.accounting-confirmation-panel h3,
.accounting-confirmation-panel p { margin: 0; }

.accounting-period-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
}

.accounting-period-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  border: 1px solid #2e3c35;
  border-radius: 9px;
  background: #17221d;
}

.accounting-period-card.eligible {
  border-color: #6c532f;
  background: #211f18;
}

.accounting-period-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.accounting-period-card p { margin: 0; font-size: 11px; }
.accounting-provenance-list,
.accounting-detail-list { display: grid; gap: 6px; margin: 0; }
.accounting-provenance-list div,
.accounting-detail-list div { display: grid; grid-template-columns: minmax(80px, .35fr) minmax(0, 1fr); gap: 8px; }
.accounting-provenance-list dt,
.accounting-detail-list dt { color: #8fa097; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.accounting-provenance-list dd,
.accounting-detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.accounting-lifecycle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  padding: 8px 10px 10px;
  border-top: 1px solid #2e3a34;
  list-style: none;
}

.accounting-lifecycle li {
  border: 1px solid #3b4b44;
  border-radius: 999px;
  padding: 4px 8px;
  color: #b9c7bf;
  font-size: 10px;
  font-weight: 750;
}

.accounting-annual-package { margin-bottom: 12px; }
.accounting-confirmation-panel { display: grid; gap: 10px; padding: 12px; border-color: #75bda6; }

.accounting-toolbar input,
.accounting-toolbar select,
.accounting-workspace td select,
.accounting-dialog-form input,
.accounting-dialog-form select {
  min-width: 0;
  border: 1px solid #3b4943;
  background: #111814;
  color: #edf4ef;
  padding: 8px 10px;
}

.accounting-toolbar input { flex: 1 1 230px; }
.accounting-toolbar select { flex: 0 1 180px; }
.accounting-transactions-scroll { flex: 1; }
.accounting-transactions-table { min-width: 1070px; font-size: 11px; }
.accounting-transactions-table td:nth-child(3) { text-align: right; }
.accounting-transactions-table select { width: 100%; min-width: 138px; }
.accounting-transactions-table select.changed,
.accounting-row-changed select { border-color: #75bda6; background: #183229; }
.accounting-row-changed { background: rgba(117, 189, 166, .06); }
.accounting-evidence-controls, .accounting-row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.accounting-evidence { display: inline-flex; align-items: center; gap: 5px; min-height: 44px; color: inherit; text-decoration: none; }
.accounting-evidence::before { content: none; }
.accounting-evidence-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #df6464; }
.accounting-evidence.missing .accounting-evidence-dot { background: #df6464; }
.accounting-evidence.pending .accounting-evidence-dot { background: #e7a44f; }
.accounting-evidence.reviewed .accounting-evidence-dot { background: #75bda6; }
.accounting-icon-control { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 6px; border: 0; background: transparent; color: inherit; text-decoration: none; cursor: pointer; font-size: 19px; }
.accounting-icon-control:focus-visible, a.accounting-evidence:focus-visible { outline: 2px solid #84c7b2; outline-offset: 2px; }
.accounting-proof-file-input[hidden] { display: none !important; }
.accounting-vat-numbers { display: grid; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.accounting-server-context, .accounting-category-heading { display: block; color: #a9bcb0; margin: 3px 0; }
.accounting-save-status { display: block; }
.accounting-save-status.unsaved, .accounting-save-status.saving { color: #e7a44f; }
.accounting-save-status.error { color: #df6464; }
.accounting-save-status.saved { color: #75bda6; }
.accounting-document-links { margin: 4px 0 0; padding-left: 16px; }
.accounting-document-links a { color: #84c7b2; }
.accounting-upload-proof { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 4px; border: 1px solid #3b4b44; border-radius: 8px; padding: 8px 10px; color: #dbe8e0; background: #1d2a24; cursor: pointer; overflow: hidden; }
.accounting-upload-proof:focus-within { outline: 3px solid #75bda6; outline-offset: 2px; box-shadow: 0 0 0 4px rgba(117, 189, 166, .16); }
.accounting-upload-proof input { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 44px; opacity: 0; cursor: pointer; }
.accounting-upload-proof:has(input:disabled) { cursor: not-allowed; opacity: .52; }
.accounting-workspace .accounting-upload-proof input:disabled { cursor: not-allowed; opacity: 0; }
.accounting-transactions-table th:nth-child(8),
.accounting-transactions-table td:nth-child(8) { min-width: 58px; }
.accounting-transactions-table td:nth-child(8) .accounting-link-button { white-space: nowrap; }

.accounting-dialog-form {
  display: grid;
  gap: 12px;
  padding-bottom: 4px;
}

.accounting-dialog-form .field {
  display: grid;
  gap: 5px;
}

.accounting-dialog-form .field span {
  color: #98a79f;
  font-size: 11px;
  font-weight: 750;
}

#overlay .accounting-detail-list,
#overlay .accounting-document-links,
#overlay .accounting-upload-proof,
#overlay .modal-actions {
  margin-top: 12px;
}

@media (min-width: 1200px) {
  .accounting-workspace { gap: 16px; }
  .accounting-card-head { padding: 15px 17px; }
  .accounting-card-primary { min-height: 0; }
}

@media (max-width: 760px) {
  .accounting-workspace,
  .accounting-card,
  .accounting-pane,
  .accounting-table-wrap,
  .accounting-transactions-scroll {
    max-width: 100%;
    min-width: 0;
  }
}

@media (max-width: 680px) {
  .accounting-workspace {
    width: 100%;
    overflow-x: clip;
    gap: 10px;
  }

  .accounting-card {
    border-radius: 12px;
  }

  .accounting-card-head,
  .accounting-status-strip,
  .accounting-tax-toolbar,
  .accounting-toolbar,
  .accounting-annual-package {
    align-items: stretch;
    flex-direction: column;
  }

  .accounting-tabs {
    width: calc(100% - 28px);
  }

  .accounting-tabs [role="tab"] {
    flex: 1 1 0;
  }

  .accounting-source-strip {
    grid-template-columns: 1fr 1fr;
  }

  .accounting-source-metric {
    border-top: 1px solid #314039;
  }

  .accounting-source-metric:nth-child(2n) { border-right: 0; }

  .accounting-period-grid {
    grid-template-columns: 1fr;
  }

  .accounting-toolbar input,
  .accounting-toolbar select,
  .accounting-head-actions,
  .accounting-head-actions button,
  .accounting-head-actions .badge {
    width: 100%;
  }

  .accounting-field-table th,
  .accounting-field-table td,
  .accounting-transactions-table th,
  .accounting-transactions-table td {
    padding: 8px 7px;
  }

  .accounting-provenance-list div,
  .accounting-detail-list div {
    grid-template-columns: 1fr;
  }
}

/* Accounting 0.5 visual-remediation density: benchmark-sized desktop first card. */
.accounting-card-primary .accounting-card-head {
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.accounting-card-primary .accounting-card-head p:not(.eyebrow) {
  font-size: 11px;
  line-height: 1.25;
}

.accounting-card-primary .accounting-head-actions {
  gap: 5px;
}

.accounting-card-primary .accounting-head-actions .badge {
  padding: 4px 6px;
  font-size: 10px;
  line-height: 1.1;
}

.accounting-card-primary .accounting-head-actions .accounting-primary-button {
  min-height: 32px;
  padding: 5px 8px;
  font-size: 11px;
}

.accounting-card-primary .accounting-status-strip {
  margin-top: 8px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.25;
}

.accounting-card-primary .accounting-status-strip .accounting-link-button {
  min-height: 0;
  padding: 0 4px;
  font-size: 11px;
}

.accounting-card-primary .accounting-tabs {
  margin-top: 8px;
}

.accounting-card-primary .accounting-tabs [role="tab"] {
  min-height: 0;
  padding: 6px 10px;
}

.accounting-card-primary .accounting-table-wrap {
  margin-top: 8px;
}

.accounting-field-table {
  min-width: 0;
  table-layout: fixed;
  font-size: 11px;
}

.accounting-field-table th,
.accounting-field-table td {
  padding: 9px 8px;
  line-height: 1.25;
}

.accounting-field-table th:nth-child(1),
.accounting-field-table td:nth-child(1) { width: 24%; }
.accounting-field-table th:nth-child(2),
.accounting-field-table td:nth-child(2) { width: 13%; }
.accounting-field-table th:nth-child(3),
.accounting-field-table td:nth-child(3) { width: 15%; }
.accounting-field-table th:nth-child(4),
.accounting-field-table td:nth-child(4) { width: 28%; }
.accounting-field-table th:nth-child(5),
.accounting-field-table td:nth-child(5) { width: 20%; }

.accounting-field-table .accounting-basis {
  font-size: 10.5px;
  line-height: 1.2;
}

.accounting-field-table .accounting-link-button {
  min-height: 0;
  padding: 0;
  font-size: 10.5px;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.accounting-source-metric {
  padding: 11px 12px;
}

.accounting-source-metric strong {
  font-size: 15px;
}

.accounting-source-foot {
  padding: 7px 14px;
  line-height: 1.25;
}

@media (max-width: 680px) {
  .accounting-card-primary .accounting-card-head,
  .accounting-card-head,
  .accounting-status-strip,
  .accounting-tax-toolbar,
  .accounting-toolbar,
  .accounting-annual-package {
    align-items: stretch;
    flex-direction: column;
  }

  .accounting-card-primary .accounting-card-head {
    padding: 13px 14px;
  }

  .accounting-card-primary .accounting-head-actions .accounting-primary-button,
  .accounting-card-primary .accounting-status-strip .accounting-link-button,
  .accounting-card-primary .accounting-tabs [role="tab"],
  .accounting-field-table .accounting-link-button {
    min-height: 44px;
  }

  .accounting-tabs {
    width: calc(100% - 28px);
  }

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

  .accounting-field-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 11px;
  }

  .accounting-field-table th,
  .accounting-field-table td {
    padding: 7px 5px;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .accounting-field-table th:nth-child(1),
  .accounting-field-table td:nth-child(1) { width: 31%; }
  .accounting-field-table th:nth-child(2),
  .accounting-field-table td:nth-child(2) { width: 20%; }
  .accounting-field-table th:nth-child(3),
  .accounting-field-table td:nth-child(3) { width: 24%; }
  .accounting-field-table th:nth-child(4),
  .accounting-field-table td:nth-child(4) { display: none; }
  .accounting-field-table th:nth-child(5),
  .accounting-field-table td:nth-child(5) { width: 25%; }

  .accounting-state {
    white-space: normal;
  }

  .accounting-source-strip {
    grid-template-columns: 1fr 1fr;
  }

  .accounting-period-grid {
    grid-template-columns: 1fr;
  }

  .accounting-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
  }

  .accounting-toolbar input {
    grid-column: 1 / -1;
  }

  .accounting-toolbar input,
  .accounting-toolbar select {
    flex: 0 0 auto;
    width: 100%;
    height: 44px;
    min-height: 44px;
  }

  .accounting-transactions-scroll {
    overflow: visible;
  }

  .accounting-transactions-table {
    display: block;
    width: 100%;
    min-width: 0;
    font-size: 11px;
  }

  .accounting-transactions-table thead {
    display: none;
  }

  .accounting-transactions-table tbody {
    display: grid;
    gap: 8px;
  }

  .accounting-transactions-table tr {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 10px;
    border: 1px solid #2c3933;
    border-radius: 10px;
    background: #141d19;
  }

  .accounting-transactions-table td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    align-items: center;
    overflow-wrap: anywhere;
  }

  .accounting-transactions-table td::before {
    color: #8fa097;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .accounting-transactions-table td:nth-child(1)::before { content: "Date"; }
  .accounting-transactions-table td:nth-child(2)::before { content: "Description"; }
  .accounting-transactions-table td:nth-child(3)::before { content: "Amount"; }
  .accounting-transactions-table td:nth-child(4)::before { content: "VAT / KZ"; }
  .accounting-transactions-table td:nth-child(5)::before { content: "Category"; }
  .accounting-transactions-table td:nth-child(6)::before { content: "Classification"; }
  .accounting-transactions-table td:nth-child(7)::before { content: "Evidence"; }
  .accounting-transactions-table td:nth-child(8)::before { content: "Detail"; }

  .accounting-transactions-table td:nth-child(2),
  .accounting-transactions-table td:nth-child(7) {
    align-items: start;
  }

  .accounting-transactions-table td > *,
  .accounting-transactions-table select,
  .accounting-document-links,
  .accounting-evidence {
    min-width: 0;
    max-width: 100%;
  }

  .accounting-transactions-table select {
    width: 100%;
    min-width: 0;
  }

  .accounting-upload-proof {
    width: 100%;
  }
}

/* HOME Watchdog v0.5.1 native route surface, scoped inside HOME CRM. */
.home-watchdog-native .crm-disk-usage {
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  overflow-wrap: anywhere;
}
.home-watchdog-native .crm-disk-usage > summary {
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
}
.home-watchdog-native .crm-disk-usage .tabs button[aria-selected="false"] { background: transparent; color: #ece7dc; }
.home-watchdog-native .crm-disk-usage .tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.home-watchdog-native .crm-disk-usage p { color: var(--muted); }
.home-watchdog-native .crm-disk-toolbar,
.home-watchdog-native .crm-disk-consumer-title,
.home-watchdog-native .crm-disk-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.home-watchdog-native .crm-disk-toolbar p { flex: 1 1 240px; }
.home-watchdog-native .crm-disk-usage button,
.home-watchdog-native .crm-disk-usage select {
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.home-watchdog-native .crm-disk-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 16px;
  margin: 20px 0;
}
.home-watchdog-native .crm-disk-totals dt { color: var(--muted); font-size: .8rem; }
.home-watchdog-native .crm-disk-totals dd { margin: 6px 0 0; font-weight: 700; }
.home-watchdog-native .crm-disk-consumers { list-style: none; padding: 0; }
.home-watchdog-native .crm-disk-consumer {
  min-width: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.home-watchdog-native .crm-disk-consumer-title button { flex: 1 1 200px; text-align: left; }
.home-watchdog-native .crm-disk-consumer-title strong { flex: 0 1 auto; }
.home-watchdog-native .crm-disk-usage progress { display: block; width: 100%; height: 10px; margin: 12px 0; accent-color: #5aaf97; }
.home-watchdog-native .crm-disk-meta { display: grid; gap: 4px; color: var(--muted); font-size: .8rem; }
.home-watchdog-native .crm-disk-breadcrumb { margin: 20px 0; }
.home-watchdog-native .crm-disk-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.home-watchdog-native .crm-lxd-coverage { margin-top: 12px; line-height: 1.5; }
.home-watchdog-native .crm-lxd-coverage summary { cursor: pointer; padding: 8px 0; }
.home-watchdog-native .crm-lxd-coverage ul { margin: 12px 0 0; padding-left: 20px; }
.home-watchdog-native .crm-lxd-coverage li { padding: 4px 0; overflow-wrap: anywhere; }
.home-watchdog-native .crm-disk-not-measured li { overflow-wrap: anywhere; }
.home-watchdog-native [data-crm-disk-stale] { color: #e2b576; }

.home-watchdog-native {
  display: grid;
  gap: 20px;
  max-width: 100%;
  min-width: 0;
}

.home-watchdog-native .topbar,
.home-watchdog-native .metric-grid,
.home-watchdog-native .panel-grid,
.home-watchdog-native .disk-grid,
.home-watchdog-native .network-grid,
.home-watchdog-native .power-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.home-watchdog-native .topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.home-watchdog-native .watchdog-title-copy,
.home-watchdog-native .watchdog-title-row {
  min-width: 0;
}

.home-watchdog-native .watchdog-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-watchdog-native .watchdog-title-row h1 {
  margin: 0;
}

.home-watchdog-native .health-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.home-watchdog-native .health-dot-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11110f;
  color: var(--ink);
  cursor: pointer;
}

.home-watchdog-native .health-dot-button:hover {
  border-color: var(--paper);
}

.home-watchdog-native .health-dot-button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 2px;
}

.home-watchdog-native .health-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #e7bd67;
  box-shadow: 0 0 0 3px rgba(231, 189, 103, .14);
}

.home-watchdog-native .health-dot-button[data-health-state="green"] .health-dot {
  background: #75d895;
  box-shadow: 0 0 0 3px rgba(117, 216, 149, .14);
}

.home-watchdog-native .health-dot-button[data-health-state="amber"] .health-dot {
  background: #e7bd67;
  box-shadow: 0 0 0 3px rgba(231, 189, 103, .14);
}

.home-watchdog-native .health-dot-button[data-health-state="red"] .health-dot {
  background: #ff857a;
  box-shadow: 0 0 0 3px rgba(255, 133, 122, .14);
}

.home-watchdog-native .health-popover {
  position: fixed;
  z-index: 20;
  top: 64px;
  left: 12px;
  width: min(360px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11151d;
  padding: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .36);
}

.home-watchdog-native .health-popover[hidden] {
  display: none !important;
}

.home-watchdog-native .health-popover h2 {
  margin: 0 0 8px;
  font-size: 14px;
}

.home-watchdog-native .health-detail-list,
.home-watchdog-native .source-list,
.home-watchdog-native .service-list,
.home-watchdog-native .facts-list,
.home-watchdog-native .detail-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.home-watchdog-native .health-detail-list div {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 8px;
}

.home-watchdog-native .health-detail-list dt {
  color: var(--muted);
  font-size: 12px;
}

.home-watchdog-native .health-detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.home-watchdog-native .metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-watchdog-native .metric-card,
.home-watchdog-native .panel,
.home-watchdog-native .source-card,
.home-watchdog-native .detail-card {
  min-width: 0;
  border: 1px solid var(--router-wifi-line);
  border-radius: 8px;
  background: #11151d;
  color: var(--router-wifi-ink);
  padding: 16px;
  overflow: hidden;
}

.home-watchdog-native .metric-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.home-watchdog-native .router-wifi-card {
  --router-wifi-ink: #f5f7fb;
  --router-wifi-muted: #b8c2d1;
  --router-wifi-line: rgba(245, 247, 251, .16);
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--router-wifi-line);
  border-radius: 8px;
  background: #11151d;
  color: var(--router-wifi-ink);
  padding: 16px;
  overflow: visible;
}

.home-watchdog-native .router-wifi-card[data-router-wifi-state="fresh"] {
  border-color: rgba(117, 216, 149, .52);
}

.home-watchdog-native .router-wifi-card[data-router-wifi-state="degraded"],
.home-watchdog-native .router-wifi-card[data-router-wifi-state="stale"] {
  border-color: rgba(231, 189, 103, .58);
}

.home-watchdog-native .router-wifi-orbit {
  position: relative;
  width: 48px;
  aspect-ratio: 1;
  border: 1px solid rgba(215, 211, 202, .28);
  border-radius: 999px;
  background: radial-gradient(circle at center, rgba(117, 216, 149, .22) 0 18%, transparent 19% 100%);
}

.home-watchdog-native .router-wifi-orbit::before,
.home-watchdog-native .router-wifi-orbit::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(114, 185, 255, .34);
  border-radius: inherit;
}

.home-watchdog-native .router-wifi-orbit::after {
  inset: 18px;
  border-color: rgba(231, 189, 103, .42);
}

.home-watchdog-native .router-wifi-orbit span {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 8px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #72b9ff;
}

.home-watchdog-native .router-wifi-content {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.home-watchdog-native .router-wifi-heading,
.home-watchdog-native .router-wifi-summary,
.home-watchdog-native .router-wifi-meta,
.home-watchdog-native .router-connection-grid,
.home-watchdog-native .router-band-grid {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.home-watchdog-native .router-wifi-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.home-watchdog-native .router-wifi-heading h2 {
  margin: 2px 0 0;
  color: var(--router-wifi-ink);
}

.home-watchdog-native .router-wifi-card .eyebrow,
.home-watchdog-native .router-path-summary,
.home-watchdog-native .router-internet-link,
.home-watchdog-native .router-wifi-card .router-wifi-note {
  color: var(--router-wifi-muted);
}

:root[data-theme] .home-watchdog-native .router-wifi-card .metric-truth {
  color: var(--router-wifi-muted) !important;
}

.home-watchdog-native .router-wifi-card .state {
  border-color: var(--router-wifi-line);
  background: rgba(255, 255, 255, .06);
  color: var(--router-wifi-ink);
}

.home-watchdog-native .router-wifi-summary {
  grid-template-columns: minmax(140px, .65fr) minmax(0, 1.35fr);
  align-items: stretch;
}

.home-watchdog-native .router-connection-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.home-watchdog-native .router-connection-panel {
  min-width: 0;
  border: 1px solid var(--router-wifi-line);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  padding: 12px;
  overflow-wrap: anywhere;
}

.home-watchdog-native .router-connection-panel[data-connection-state="active"] {
  border-color: rgba(117, 216, 149, .48);
}

.home-watchdog-native .router-connection-panel[data-connection-state="degraded"] {
  border-color: rgba(231, 189, 103, .58);
}

.home-watchdog-native .router-connection-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
}

.home-watchdog-native .router-connection-head span,
.home-watchdog-native .router-connection-head b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.home-watchdog-native .router-connection-panel dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.home-watchdog-native .router-connection-panel dl div {
  min-width: 0;
}

.home-watchdog-native .router-connection-panel dt,
.home-watchdog-native .router-connection-panel dd,
.home-watchdog-native .router-connection-panel p,
.home-watchdog-native .router-path-summary,
.home-watchdog-native .router-internet-link {
  margin: 0;
}

.home-watchdog-native .router-connection-panel dt {
  color: var(--router-wifi-muted);
  font-size: 12px;
}

.home-watchdog-native .router-connection-panel dd {
  color: var(--router-wifi-ink);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.home-watchdog-native .router-connection-panel p {
  margin-top: 10px;
  color: var(--router-wifi-muted);
}

.home-watchdog-native .router-wifi-total,
.home-watchdog-native .router-band-grid div,
.home-watchdog-native .router-wifi-meta div {
  min-width: 0;
  border: 1px solid var(--router-wifi-line);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  padding: 10px;
  overflow-wrap: anywhere;
}

.home-watchdog-native .router-wifi-total strong,
.home-watchdog-native .router-band-grid strong {
  display: block;
  color: var(--router-wifi-ink);
  font-size: 28px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.home-watchdog-native .router-wifi-meta dd {
  color: var(--router-wifi-ink);
}

.home-watchdog-native .router-wifi-total span,
.home-watchdog-native .router-band-grid span,
.home-watchdog-native .router-wifi-meta dt,
.home-watchdog-native .router-wifi-note {
  color: var(--router-wifi-muted);
}

.home-watchdog-native .router-band-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.home-watchdog-native .router-wifi-meta {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.home-watchdog-native .router-wifi-meta dt,
.home-watchdog-native .router-wifi-meta dd,
.home-watchdog-native .router-wifi-note {
  margin: 0;
}

.home-watchdog-native [data-router-wifi-label] {
  min-width: 0;
  overflow-wrap: anywhere;
}

.home-watchdog-native .metric-title,
.home-watchdog-native .metric-head,
.home-watchdog-native .panel-title,
.home-watchdog-native .source-head,
.home-watchdog-native .section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.home-watchdog-native .metric-title span {
  font-weight: 800;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.home-watchdog-native .metric-title small,
.home-watchdog-native .metric-truth,
.home-watchdog-native .metric-unit {
  color: var(--muted);
}

.home-watchdog-native .metric-primary {
  min-width: 0;
}

.home-watchdog-native .metric-primary strong,
.home-watchdog-native .metric-card > strong {
  display: block;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
  color: var(--ink);
}

.home-watchdog-native .metric-truth {
  min-height: 18px;
  margin: 0;
  overflow-wrap: anywhere;
}

.home-watchdog-native .meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}

.home-watchdog-native .meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--paper);
}

.home-watchdog-native .metric-chart-slot {
  min-width: 0;
}

.home-watchdog-native .history-graph {
  display: block;
  width: 100%;
  height: 160px;
  overflow: hidden;
  border: 1px solid #292824;
  border-radius: 8px;
  background: #11110f;
}

.home-watchdog-native .history-baseline,
.home-watchdog-native .history-grid,
.home-watchdog-native .history-axis {
  stroke: #4a4740;
  vector-effect: non-scaling-stroke;
}

.home-watchdog-native .history-path {
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.home-watchdog-native .history-gap {
  stroke: #ff857a;
  stroke-width: 1;
  stroke-dasharray: 2 2;
  opacity: .9;
  vector-effect: non-scaling-stroke;
}

.home-watchdog-native .history-empty,
.home-watchdog-native .history-tick {
  fill: var(--muted);
  font-size: 7px;
}

.home-watchdog-native .source-item,
.home-watchdog-native .source-row,
.home-watchdog-native .fact-row,
.home-watchdog-native .service-row,
.home-watchdog-native .detail-row,
.home-watchdog-native .container-card,
.home-watchdog-native .disk-usage-pair span,
.home-watchdog-native .network-pair span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  padding: 10px;
  overflow-wrap: anywhere;
}

.home-watchdog-native .power-detail summary {
  min-height: 44px;
  cursor: pointer;
  font-weight: 800;
}

.home-watchdog-native .temperature-plot {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.home-watchdog-native .temperature-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
  max-height: 118px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-block: contain;
  scrollbar-gutter: stable;
  list-style: none;
}

.home-watchdog-native .temperature-legend li {
  position: relative;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.home-watchdog-native .temperature-legend .empty {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.home-watchdog-native .temperature-swatch {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #72d6d1;
}

.home-watchdog-native .sensor-color-0 { background: #75d895; }
.home-watchdog-native .sensor-color-1 { background: #72b9ff; }
.home-watchdog-native .sensor-color-2 { background: #e7bd67; }
.home-watchdog-native .sensor-color-3 { background: #b69cff; }
.home-watchdog-native .sensor-color-4 { background: #ff857a; }
.home-watchdog-native .sensor-color-5 { background: #72d6d1; }
.home-watchdog-native .sensor-color-6 { background: #f2a6d7; }
.home-watchdog-native .sensor-color-7 { background: #b8d986; }

.home-watchdog-native [data-temperature-detail-button] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-watchdog-native [data-temperature-short-label] {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-watchdog-native [data-temperature-detail-button]:hover {
  text-decoration: underline;
}

.home-watchdog-native [data-temperature-detail-button]:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.home-watchdog-native [data-temperature-value] {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home-watchdog-native [data-temperature-sensor-detail] {
  grid-column: 2 / -1;
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11110f;
  color: var(--muted);
  font-size: 12px;
}

.home-watchdog-native [data-temperature-sensor-detail][hidden] {
  display: none !important;
}

.home-watchdog-native .table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  contain: inline-size;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  scrollbar-gutter: stable;
}

.home-watchdog-native table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.home-watchdog-native .process-table-scroll table {
  min-width: 920px;
}

.home-watchdog-native #services-table {
  min-width: 1220px;
}

.home-watchdog-native #process-table {
  min-width: 1160px;
}

.home-watchdog-native .table-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  max-width: 100%;
  min-width: 0;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.home-watchdog-native .table-foot span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.home-watchdog-native #process-reconcile {
  flex: 1 1 260px;
}

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

.home-watchdog-native th,
.home-watchdog-native .sort-button,
.home-watchdog-native #services-table td:nth-child(2),
.home-watchdog-native #services-table td:nth-child(3),
.home-watchdog-native #process-table td[data-col="state"] {
  white-space: nowrap;
}

.home-watchdog-native .numeric-heading,
.home-watchdog-native .numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home-watchdog-native #services-table th:nth-child(1),
.home-watchdog-native #services-table td:nth-child(1) {
  min-width: 170px;
}

.home-watchdog-native #services-table th:nth-child(2),
.home-watchdog-native #services-table td:nth-child(2) {
  min-width: 92px;
}

.home-watchdog-native #services-table th:nth-child(3),
.home-watchdog-native #services-table td:nth-child(3) {
  min-width: 160px;
}

.home-watchdog-native #services-table th:nth-child(4),
.home-watchdog-native #services-table th:nth-child(5),
.home-watchdog-native #services-table td:nth-child(4),
.home-watchdog-native #services-table td:nth-child(5) {
  min-width: 92px;
}

.home-watchdog-native #services-table th:nth-child(6),
.home-watchdog-native #services-table td:nth-child(6) {
  min-width: 118px;
}

.home-watchdog-native #services-table th:nth-child(7),
.home-watchdog-native #services-table td:nth-child(7) {
  min-width: 260px;
}

.home-watchdog-native #process-table th:nth-child(1),
.home-watchdog-native #process-table td[data-col="pid"] {
  min-width: 72px;
}

.home-watchdog-native #process-table th:nth-child(2),
.home-watchdog-native #process-table td[data-col="command"] {
  min-width: 330px;
}

.home-watchdog-native #process-table th:nth-child(4),
.home-watchdog-native #process-table th:nth-child(5),
.home-watchdog-native #process-table th:nth-child(6),
.home-watchdog-native #process-table th:nth-child(8),
.home-watchdog-native #process-table td[data-col="cpu_percent"],
.home-watchdog-native #process-table td[data-col="memory_percent"],
.home-watchdog-native #process-table td[data-col="rss_bytes"],
.home-watchdog-native #process-table td[data-col="elapsed_seconds"] {
  min-width: 86px;
}

.home-watchdog-native #process-table th:nth-child(7),
.home-watchdog-native #process-table td[data-col="state"] {
  min-width: 96px;
}

.home-watchdog-native .numeric-heading .sort-button {
  justify-content: flex-end;
  margin-left: auto;
}

.home-watchdog-native .sort-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  max-width: 100%;
  margin: -8px 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: inherit;
  cursor: pointer;
}

.home-watchdog-native .sort-button:hover {
  text-decoration: underline;
}

.home-watchdog-native .sort-button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 2px;
}

.home-watchdog-native .sort-button.active-sort {
  background: transparent;
  color: var(--ink);
}

.home-watchdog-native .command-cell {
  min-width: 280px;
  max-width: 520px;
}

.home-watchdog-native .command-disclosure summary {
  display: -webkit-box;
  min-height: 44px;
  overflow: hidden;
  cursor: pointer;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}

.home-watchdog-native .command-disclosure code {
  display: block;
  margin-top: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.home-watchdog-native .tabs {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11100e;
}

.home-watchdog-native .tabs button {
  flex: 0 0 auto;
  min-width: max-content;
  min-height: 44px;
  white-space: nowrap;
}

.home-watchdog-native .tabs button[aria-selected="true"] {
  background: var(--paper);
  color: #17191d;
}

.home-watchdog-native #services-panel,
.home-watchdog-native #tasks-panel {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.home-watchdog-native #tasks-panel[hidden],
.home-watchdog-native #services-panel[hidden] {
  display: none !important;
}

.home-watchdog-native .table-heading {
  flex-wrap: wrap;
}

.home-watchdog-native .process-manager,
.home-watchdog-native .table-panel,
.home-watchdog-native .disk-usage-pair,
.home-watchdog-native .network-pair {
  contain: inline-size;
  min-width: 0;
}

.home-watchdog-native .disk-usage-pair,
.home-watchdog-native .network-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 0;
}

.unavailable-value {
  font-size: 30px !important;
  letter-spacing: 0 !important;
}

@media (max-width: 430px) {
  .home-watchdog-native .metric-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    gap: 2px;
  }

  .home-watchdog-native .metric-title span,
  .home-watchdog-native .metric-title small {
    min-width: 0;
  }

  .home-watchdog-native .metric-title small {
    overflow-wrap: anywhere;
  }

  .home-watchdog-native .history-graph {
    height: 148px;
  }

  .home-watchdog-native .temperature-plot,
  .home-watchdog-native .disk-usage-pair,
  .home-watchdog-native .network-pair,
  .home-watchdog-native .router-connection-grid,
  .home-watchdog-native .router-wifi-summary,
  .home-watchdog-native .router-wifi-meta {
    grid-template-columns: 1fr;
  }

  .home-watchdog-native .temperature-legend {
    grid-template-columns: 1fr;
    max-height: 148px;
  }
}

@media (max-width: 900px) and (min-width: 761px) {
  .app-shell:has(.home-watchdog-native) {
    grid-template-columns: minmax(190px, 220px) minmax(0, 1fr);
  }

  .app-shell:has(.home-watchdog-native) .workspace,
  .app-shell:has(.home-watchdog-native) .content {
    max-width: 100%;
    min-width: 0;
  }
}

/* Mia V2 canvas-dominant workspace. */
.mia-selector-row,
.mia-workspace,
.mia-center,
.mia-right-rail,
.mia-canvas-stage,
.mia-simple-panel,
.mia-session-rail,
.simple-sessions,
.ticket-history,
[data-mia-composer],
[data-mia-mobile-drawer] {
  min-width: 0;
}

.mia-selector-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #11151d;
}

.mia-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 2.6fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: min(760px, calc(100vh - 210px));
}

.mia-transcript-rail,
.mia-session-rail,
.mia-right-rail {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.mia-center,
.mia-right-rail {
  display: grid;
  gap: 14px;
}

.mia-canvas-stage {
  display: grid;
  gap: 12px;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #141922, #0f131a);
  padding: 16px;
}

.mia-simple-panel .badge {
  min-width: 58px;
  white-space: nowrap;
  flex-shrink: 0;
}

.mia-session-rail h2 {
  white-space: nowrap;
}

.mia-session-rail .panel-head {
  flex-wrap: wrap;
  gap: 8px;
}

.mia-session-rail .panel-head button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.canvas-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.canvas-frame-wrap,
.canvas-code-editor {
  min-height: 360px;
}

.canvas-frame-wrap iframe,
.canvas-code-editor textarea {
  display: block;
  width: 100%;
  height: min(58vh, 560px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #070a0f;
}

.canvas-code-editor textarea {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  white-space: pre;
}

[data-mia-composer] {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(17, 21, 29, .96);
  padding: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.simple-sessions ol,
.ticket-history ol,
.mia-session-list,
.canvas-version-list {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.simple-sessions li,
.ticket-history li,
.mia-session-card,
.canvas-version-list li {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #10131a;
}

.mia-session-card button,
.canvas-version-list button {
  width: 100%;
  text-align: left;
}

.mia-session-card strong,
.session-project {
  display: block;
}

.session-project {
  color: var(--muted);
  font-size: 12px;
}

.canvas-version-list li.active,
.light-profile-card {
  background: #f5f0e7;
  color: #172019;
  border-color: #e1d8ca;
}

.canvas-fallback {
  min-height: 260px;
  display: grid;
  place-content: center;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 20px;
  background: #0b0f15;
}

[data-mia-mobile-drawer] {
  display: none;
}

.mia-command-surface{display:grid;gap:12px}.mia-head{margin:0;padding:0;align-items:end}.mia-head h1{margin:2px 0 4px}.mia-head p{margin-bottom:0}.mia-service-strip{display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;padding:8px 12px}.mia-service-strip span{font-size:12px}.mia-history-menu>summary{cursor:pointer;font-weight:700}.mia-history-menu>div{display:grid;gap:14px;margin-top:14px}.mia-workspace{min-height:calc(100vh - 340px)}.mia-canvas-stage{min-height:620px}

.mia-workspace {
  --mia-left-rail-width: 288px;
  --mia-right-rail-width: 340px;
  grid-template-columns: var(--mia-left-rail-width) minmax(0, 1fr) var(--mia-right-rail-width);
  height: calc(100dvh - 210px);
  min-height: 620px;
  overflow: hidden;
}

.mia-route-lock[data-left-rail-state="compact"] .mia-workspace,
.mia-workspace[data-left-rail-state="compact"] {
  --mia-left-rail-width: 64px;
}

.mia-route-lock[data-left-rail-state="closed"] .mia-workspace,
.mia-workspace[data-left-rail-state="closed"] {
  --mia-left-rail-width: 0px;
}

.mia-workspace[data-right-rail-open="false"] {
  --mia-right-rail-width: 0px;
}

.mia-sessions-pane,
.mia-chat-pane {
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  transition: inline-size .24s ease, opacity .24s ease;
  resize: none;
}

.mia-sessions-pane.is-closed {
  inline-size: 64px;
  opacity: .9;
}

.mia-sessions-pane.is-compact {
  inline-size: clamp(120px, 14vw, 180px);
}

.mia-sessions-pane.is-closed .panel:not(:first-child),
.mia-sessions-pane.is-compact .context-pack-sources,
.mia-sessions-pane.is-closed .mia-session-list,
.mia-sessions-pane.is-closed .mia-knowledge-rail {
  display: none;
}

.rail-state-controls {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #e7bd67;
  box-shadow: 0 0 0 3px rgba(231,189,103,.14);
}

.status-dot.ok {
  background: #75d895;
  box-shadow: 0 0 0 3px rgba(117,216,149,.14);
}

.mia-center,
.mia-canvas-stage {
  min-height: 0;
  overflow: hidden;
}

.canvas-frame-wrap iframe,
.canvas-code-editor textarea {
  height: clamp(360px, 52dvh, 620px);
  resize: none;
}

.mia-file-dock {
  display: grid;
  gap: 6px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .mia-sessions-pane,
  .mia-chat-pane {
    transition: none;
  }
}

.templates-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.template-header,
.template-toolbar,
.template-catalog,
.template-editor,
.template-preview,
.template-lineage,
.template-receipt {
  box-shadow: 0 18px 45px rgba(0, 0, 0, .22);
}

.template-toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, .7fr)) auto;
  min-width: 0;
}

.checkbox-row {
  align-items: center;
  display: flex !important;
  gap: 10px !important;
  min-height: 42px;
}

.checkbox-row input {
  width: auto;
}

.templates-layout {
  display: grid;
  grid-template-columns: minmax(220px, .62fr) minmax(520px, 1.7fr) minmax(280px, .82fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.template-catalog,
.template-editor,
.template-preview,
.template-inputs,
.template-input-grid,
.template-form,
.template-form label {
  min-width: 0;
}

.template-toolbar input,
.template-toolbar select,
.template-form input,
.template-form select,
.template-form textarea,
.template-inputs input,
.template-inputs select,
.template-inputs textarea {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.template-list,
.template-form {
  display: grid;
  gap: 12px;
}

.template-card {
  display: grid;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: var(--field-bg);
  color: var(--ink);
}

.template-card.selected,
.template-summary {
  border-color: rgba(225, 216, 202, .62);
  background: linear-gradient(135deg, rgba(245, 240, 231, .14), rgba(18, 23, 34, .94));
}

.template-card.selected { background: var(--field-bg); }

.template-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.template-card-meta {
  color: var(--muted);
  font-size: 12px;
}

.template-summary,
.template-empty {
  margin-bottom: 14px;
}

.template-lineage,
.template-inputs {
  border: 1px solid rgba(225, 216, 202, .14);
  border-radius: 16px;
  margin-bottom: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, .025);
}

.panel-title.compact {
  gap: 8px;
  margin-bottom: 10px;
}

.panel-title.compact h3 {
  margin: 0;
}

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

.template-lineage-grid section {
  min-width: 0;
}

.template-lineage-grid h4 {
  margin: 0 0 8px;
}

.template-timeline {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.template-timeline li {
  display: grid;
  gap: 3px;
  border-left: 2px solid rgba(225, 216, 202, .24);
  padding-left: 10px;
}

.template-timeline small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.template-canvas {
  display: grid;
  gap: 12px;
}

.template-canvas-bar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.template-language-control {
  display: grid;
  gap: 6px;
  min-width: min(220px, 100%);
}

.template-canvas-bar .template-language-control {
  justify-items: end;
  margin-left: auto;
  text-align: right;
}

.template-language-control span {
  color: var(--muted);
  font-size: 12px;
}

.template-validation-summary {
  display: grid;
  gap: 8px;
  margin: 0;
}

.template-validation-summary ul {
  margin: 0;
  padding-left: 18px;
}

.template-readonly {
  display: grid;
  gap: 14px;
}

.template-readonly .template-summary,
.template-readonly .template-lineage {
  margin-bottom: 0;
}

.template-form textarea {
  min-height: 340px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  resize: vertical;
}

.template-actions {
  flex-wrap: wrap;
}

.template-preview {
  position: sticky;
  top: 88px;
}

.template-preview iframe {
  width: 100%;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f4ed;
}

.template-error,
.template-receipt {
  margin: 0;
}

.mono {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

.template-workspace-shell {
  display: grid;
  grid-template-columns: minmax(220px, .72fr) minmax(0, 2.55fr) minmax(280px, .9fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 210px);
  min-width: 0;
}

.template-workspace-shell > * {
  min-width: 0;
}

.template-sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.template-sidebar-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.template-sidebar-head > button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.template-sidebar-head h2,
.template-sidebar h3 {
  margin: 0;
}

.template-document-stage.template-preview {
  position: relative;
  top: auto;
  min-width: 0;
}

.template-document-stage .panel-title {
  align-items: start;
}

.template-status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.template-document-list,
.template-version-list,
.template-evidence-panel {
  display: grid;
  gap: 10px;
}

.template-user-subject { display: grid; gap: 6px; min-width: 0; }
.template-user-subject select { width: 100%; min-width: 0; }
.template-global-documents { border-top: 1px solid var(--line); padding-top: 12px; min-width: 0; }
.template-global-documents .template-document-card { overflow-wrap: anywhere; }

.template-document-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--field-bg);
  color: var(--ink);
  text-align: left;
}

.template-document-card.selected {
  border-color: rgba(225, 216, 202, .62);
  background: var(--field-bg);
}

/* One selected look for catalogue and document cards; the whole card is the click target. */
.template-card, .template-document-card { cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease; }
.template-card:hover, .template-document-card:hover { border-color: color-mix(in srgb, var(--accent), transparent 55%); }
.template-card.selected, .template-document-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.template-card select, .template-document-card select { cursor: default; }
.template-card-controls { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.template-card-controls .template-version-control select:disabled { opacity: .7; }
.template-family-card .template-family-control select { max-width: 190px; min-width: 96px; }
.template-family-card > button { font-weight: 650; }
.template-document-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; min-width: 0; }

.template-version-list {
  margin: 0;
  padding-left: 20px;
}

.template-version-list li {
  min-width: 0;
}

.template-evidence-panel {
  border: 1px solid rgba(225, 216, 202, .14);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, .025);
}

.template-evidence-panel label {
  display: grid;
  gap: 6px;
}

.template-evidence-panel input,
.template-evidence-panel textarea {
  max-width: 100%;
  min-width: 0;
  width: 100%;
}

.template-evidence-status,
.template-approval-evidence {
  display: grid;
  gap: 6px;
}

.template-approval-evidence p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.is-catalogue-collapsed {
  grid-template-columns: minmax(58px, 58px) minmax(0, 2.7fr) minmax(280px, .9fr);
}

.is-documents-collapsed {
  grid-template-columns: minmax(220px, .72fr) minmax(0, 2.8fr) minmax(58px, 58px);
}

.is-catalogue-collapsed.is-documents-collapsed {
  grid-template-columns: minmax(58px, 58px) minmax(0, 1fr) minmax(58px, 58px);
}

.is-catalogue-collapsed .template-sidebar--catalogue > :not(.template-sidebar-head),
.is-documents-collapsed .template-sidebar--documents > :not(.template-sidebar-head) {
  display: none;
}

.is-catalogue-collapsed .template-sidebar--catalogue,
.is-documents-collapsed .template-sidebar--documents {
  overflow: hidden;
  padding-inline: 8px;
}

.is-catalogue-collapsed .template-sidebar--catalogue h2,
.is-documents-collapsed .template-sidebar--documents h2 {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.template-workspace-shell .template-preview iframe {
  height: min(72vh, 760px);
  min-height: 540px;
}

@media (max-width: 1180px) {
  .template-workspace-shell,
  .template-workspace-shell.is-catalogue-collapsed,
  .template-workspace-shell.is-documents-collapsed,
  .template-workspace-shell.is-catalogue-collapsed.is-documents-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .template-sidebar {
    position: relative;
    top: auto;
    max-height: none;
  }

  .is-catalogue-collapsed .template-sidebar--catalogue h2,
  .is-documents-collapsed .template-sidebar--documents h2 {
    writing-mode: horizontal-tb;
    transform: none;
  }

  .template-workspace-shell .template-preview iframe {
    height: 62vh;
    min-height: 420px;
  }
}

@media (max-width: 480px) {
  .template-workspace-shell {
    gap: 12px;
  }

  .template-sidebar,
  .template-document-stage {
    padding: 12px;
  }

  .template-workspace-shell .template-preview iframe {
    height: 56vh;
    min-height: 320px;
  }
}

@media (max-width: 1450px) and (min-width: 1181px) {
  .templates-layout {
    grid-template-columns: minmax(220px, .85fr) minmax(0, 1.4fr);
  }

  .templates-layout > .template-preview {
    grid-column: 1 / -1;
    position: relative;
    top: auto;
  }

  .mia-workspace {
    grid-template-columns: minmax(220px, .62fr) minmax(0, 2.38fr);
  }

  .mia-right-rail {
    grid-column: 1 / -1;
    position: relative;
    top: auto;
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .mia-workspace,
  .mia-selector-row,
  .templates-layout,
  .template-toolbar {
    grid-template-columns: 1fr;
  }

  .mia-transcript-rail,
  .mia-session-rail,
  .mia-right-rail {
    position: relative;
    top: auto;
    max-height: none;
  }

  .template-preview {
    position: relative;
    top: auto;
  }
}

@media (max-width: 1180px) and (min-width: 769px) {
  .home-watchdog-native .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .home-watchdog-native .topbar,
  .home-watchdog-native .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  [data-agent-results] {
    grid-template-columns: minmax(0, 1fr);
  }

  .agent-card-head,
  .agent-facts {
    grid-template-columns: 1fr;
  }

  .agent-card-head {
    display: grid;
  }

  .agent-role-label {
    justify-self: start;
  }

  .home-watchdog-native,
  .home-watchdog-native .metric-card,
  .home-watchdog-native .router-wifi-card,
  .home-watchdog-native .panel,
  .mia-workspace,
  .mia-center,
  .mia-canvas-stage,
  [data-mia-composer],
  .templates-workspace,
  .template-editor,
  .template-preview {
    max-width: 100%;
    min-width: 0;
  }

  .home-watchdog-native .metric-grid,
  .home-watchdog-native .disk-usage-pair,
  .home-watchdog-native .router-wifi-card,
  .home-watchdog-native .router-wifi-summary,
  .home-watchdog-native .router-wifi-meta,
  .template-lineage-grid,
  .home-watchdog-native .network-pair {
    grid-template-columns: 1fr;
  }

  .home-watchdog-native .router-band-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home-watchdog-native .router-wifi-card {
    grid-template-columns: 1fr;
  }

  .home-watchdog-native table {
    min-width: 620px;
  }

  .mia-transcript-rail {
    max-height: 220px;
  }

  .canvas-frame-wrap iframe,
  .canvas-code-editor textarea,
  .template-preview iframe {
    height: 360px;
    min-height: 360px;
  }

  .composer-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  [data-mia-mobile-drawer] {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .template-header .actions,
  .template-actions,
  .template-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .template-header .actions button,
  .template-actions button,
  .template-toolbar button {
    width: 100%;
  }

  .template-form textarea {
    min-height: 260px;
  }

  .template-preview iframe {
    height: 320px;
    min-height: 320px;
  }
}

/* MIA-LIVE-02: v2 single-composer live workspace. */
.mia-left-rail,
.mia-right-rail,
.mia-center,
.knowledge-used,
.background-activity {
  min-width: 0;
}

.mia-workspace {
  grid-template-columns: minmax(270px, .95fr) minmax(0, 3.2fr) minmax(220px, .72fr);
  min-height: calc(100vh - 250px);
}

.mia-left-rail {
  display: grid;
  gap: 12px;
  align-content: start;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

.mia-left-rail .mia-transcript-rail,
.mia-left-rail .mia-session-rail {
  position: relative;
  top: auto;
  max-height: none;
}

.mia-center {
  display: grid;
  min-height: calc(100vh - 250px);
}

.mia-canvas-stage {
  min-height: calc(100vh - 250px);
  border-radius: 8px;
}

.canvas-frame-wrap iframe {
  height: min(70vh, 760px);
  border-radius: 8px;
}

.mia-session-card,
.canvas-version-list li,
.knowledge-used,
.background-activity,
[data-mia-composer] {
  border-radius: 8px;
}

.mia-session-card button {
  display: grid;
  gap: 4px;
}

.session-meta,
.mia-session-card time,
.background-activity small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mia-right-rail {
  display: grid;
  gap: 12px;
  align-content: start;
}

.background-activity ol {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.background-activity li {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #10131a;
}

[data-mia-composer] {
  position: sticky;
  bottom: 8px;
}

@media (max-width: 1180px) {
  .mia-workspace {
    grid-template-columns: 1fr;
  }
  .mia-left-rail,
  .mia-right-rail {
    position: relative;
    top: auto;
    max-height: none;
  }
  .mia-center,
  .mia-canvas-stage {
    min-height: 68vh;
  }
}

@media (max-width: 760px) {
  .mia-workspace {
    display: flex;
    flex-direction: column;
  }
  .mia-center {
    order: 1;
    min-height: 62vh;
  }
  .mia-left-rail {
    order: 2;
  }
  .mia-right-rail {
    order: 3;
  }
  .mia-canvas-stage {
    min-height: 62vh;
  }
  .canvas-frame-wrap iframe {
    height: 52vh;
  }
  [data-mia-mobile-drawer] {
    display: flex;
  }
}

/* MIA-ASSISTANT-05 remediation: full-section Canvas drawer workspace. */
.mia-workspace[data-mia-drawer-shell] {
  height: calc(100vh - 250px);
  min-height: 560px;
  overflow: hidden;
}

.mia-chat-pane,
.mia-sessions-pane,
.mia-canvas-pane {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.mia-chat-pane,
.mia-sessions-pane {
  position: relative;
  top: auto;
  max-height: none;
  align-content: start;
}

.mia-canvas-pane .mia-canvas-stage {
  min-height: 100%;
}

.session-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.session-actions button {
  width: 100%;
  text-align: center;
  white-space: nowrap;
}

.mia-session-disclosures {
  display: grid;
  gap: 12px;
}

.knowledge-used summary,
.background-activity summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .mia-workspace[data-mia-drawer-shell] {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .mia-chat-pane,
  .mia-sessions-pane,
  .mia-canvas-pane {
    overflow: visible;
  }
}


@media (max-width: 760px) {
  .mia-workspace[data-mia-drawer-shell] {
    display: block;
  }
  .mia-workspace[data-mia-drawer-shell] [data-mia-pane] {
    display: none;
  }
  .mia-workspace[data-mia-drawer-shell][data-active-mobile-pane="chat"] [data-mia-pane="chat"],
  .mia-workspace[data-mia-drawer-shell][data-active-mobile-pane="canvas"] [data-mia-pane="canvas"],
  .mia-workspace[data-mia-drawer-shell][data-active-mobile-pane="sessions"] [data-mia-pane="sessions"] {
    display: block;
  }
  [data-mia-mobile-drawer] button[aria-pressed="true"] {
    border-color: var(--accent);
    background: rgba(106, 157, 255, .16);
  }
}

@media (max-width: 360px) {
  .session-actions {
    grid-template-columns: 1fr;
  }
}

/* HOME_CRM_AGENTS_VISUAL_THEMES_20260915: semantic theme + fixed desktop shell override layer. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --color-canvas: #07080d;
  --color-sidebar: #0f1118;
  --color-surface: #14171f;
  --color-surface-elevated: #1c2029;
  --color-foreground: #f8f8fb;
  --color-muted-foreground: #a8aab3;
  --color-border: rgba(255, 255, 255, .14);
  --color-input: #11151d;
  --color-hover: rgba(255, 255, 255, .08);
  --color-selected: rgba(215, 211, 202, .16);
  --color-focus: #f3dfaf;
  --color-inverse-foreground: #17191d;
  --status-good: #a9cfb5;
  --status-warn: #e3c78d;
  --status-bad: #ff9f96;
  --status-info: #9bc7ef;
  --shadow-elevated: 0 18px 45px rgba(0, 0, 0, .32);
  --bg: #07080d;
  --panel: #14171f;
  --panel2: #1c2029;
  --surface-card: #14171f;
  --surface-raised: #1c2029;
  --surface-soft: #10131a;
  --field-bg: #11151d;
  --paper: #d7d3ca;
  --ink: #f8f8fb;
  --muted: #a8aab3;
  --line: rgba(255, 255, 255, .14);
  --good: #a9cfb5;
  --warn: #e3c78d;
  --accent: #d7d3ca;
  --accent-ink: #17191d;
  --focus-ring: #f3dfaf;
  --shadow-card: 0 18px 45px rgba(0, 0, 0, .32);
}

:root[data-theme="light"] {
  color-scheme: light;
  --color-canvas: #f7f2ea;
  --color-sidebar: #ebe1d2;
  --color-surface: #fffdf8;
  --color-surface-elevated: #f1e8dc;
  --color-foreground: #17191d;
  --color-muted-foreground: #5c6170;
  --color-border: rgba(55, 43, 31, .2);
  --color-input: #fffaf3;
  --color-hover: rgba(92, 64, 39, .08);
  --color-selected: rgba(92, 64, 39, .14);
  --color-focus: #6b4f32;
  --color-inverse-foreground: #fffaf3;
  --status-good: #2f6f44;
  --status-warn: #8a5b13;
  --status-bad: #9e2f2b;
  --status-info: #1d5f8f;
  --shadow-elevated: 0 18px 45px rgba(83, 66, 44, .14);
  --bg: #f7f2ea;
  --panel: #fffaf3;
  --panel2: #efe7da;
  --surface-card: #fffdf8;
  --surface-raised: #f1e8dc;
  --surface-soft: #f9f4ec;
  --field-bg: #fffaf3;
  --paper: #3b3024;
  --ink: #17191d;
  --muted: #5c6170;
  --line: rgba(55, 43, 31, .2);
  --good: #2f6f44;
  --warn: #8a5b13;
  --accent: #5c4027;
  --accent-ink: #fffaf3;
  --focus-ring: #6b4f32;
  --shadow-card: 0 18px 45px rgba(83, 66, 44, .14);
}

:root[data-theme] {
  background: var(--bg);
  color: var(--ink);
}

:root[data-theme] body {
  background: var(--bg);
  color: var(--ink);
}

:root[data-theme] :focus-visible {
  outline-color: var(--focus-ring);
}

@media (min-width: 761px) {
  :root[data-theme] .app-shell {
    display: grid;
    grid-template-columns: minmax(220px, 248px) minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  :root[data-theme] .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  :root[data-theme] .workspace {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  :root[data-theme] .content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: visible;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }
}

:root[data-theme] .sidebar,
:root[data-theme] dialog.drawer,
:root[data-theme] .card,
:root[data-theme] .panel,
:root[data-theme] .paper,
:root[data-theme] .mia-head,
:root[data-theme] .mia-view-panel,
:root[data-theme] .agents-live-card,
:root[data-theme] .agents-activity-card,
:root[data-theme] .agents-owner-banner,
:root[data-theme] .template-header,
:root[data-theme] .template-toolbar,
:root[data-theme] .template-catalog,
:root[data-theme] .template-editor,
:root[data-theme] .template-preview,
:root[data-theme] .template-lineage,
:root[data-theme] .template-receipt,
:root[data-theme] .home-watchdog-native .health-popover,
:root[data-theme] .home-watchdog-native .metric-card,
:root[data-theme] .home-watchdog-native .chart-card,
:root[data-theme] .home-watchdog-native .watchdog-live-card,
:root[data-theme] .home-watchdog-native .health-dot-button,
:root[data-theme] .mia-session-card,
:root[data-theme] .canvas-version-list li,
:root[data-theme] .knowledge-used,
:root[data-theme] .background-activity,
:root[data-theme] [data-mia-composer] {
  background: var(--surface-card);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

:root[data-theme] dialog.drawer .dialog-head,
:root[data-theme] dialog.drawer .profile-detail-section {
  border-color: var(--line);
  color: var(--ink);
}

:root[data-theme] dialog.drawer .profile-detail-section {
  background: var(--surface-card);
}

:root[data-theme] .light-profile-card {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--ink);
}

:root[data-theme] .light-profile-card h3,
:root[data-theme] .light-profile-card p,
:root[data-theme] .light-profile-card small,
:root[data-theme] dialog.drawer h2,
:root[data-theme] dialog.drawer h3,
:root[data-theme] dialog.drawer dd,
:root[data-theme] dialog.drawer strong,
:root[data-theme] .agent-facts dd,
:root[data-theme] .agents-activity-card h3,
:root[data-theme] .agents-activity-card p {
  color: var(--ink);
}

:root[data-theme] .agent-role-label,
:root[data-theme] .agent-facts div,
:root[data-theme] .compact-definition-list div,
:root[data-theme] .knowledge-tree-branch,
:root[data-theme] .metadata-entry-list li,
:root[data-theme] .tag-list li {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--ink);
}

:root[data-theme] .agent-facts dt,
:root[data-theme] .compact-definition-list dt,
:root[data-theme] .summary-list dt,
:root[data-theme] .muted,
:root[data-theme] .agent-source-note,
:root[data-theme] .session-project,
:root[data-theme] .brand small,
:root[data-theme] .home-watchdog-native .metric-truth,
:root[data-theme] .home-watchdog-native .metric-unit,
:root[data-theme] .home-watchdog-native .health-detail-list dt {
  color: var(--muted) !important;
}

:root[data-theme] button,
:root[data-theme] .button,
:root[data-theme] input,
:root[data-theme] select,
:root[data-theme] textarea {
  background: var(--field-bg);
  border-color: var(--line);
  color: var(--ink);
}

:root[data-theme] .primary,
:root[data-theme] .button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.theme-toggle {
  width: 100%;
  min-height: 40px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

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

.profile-detail-section {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.profile-detail-section h3,
.knowledge-tree-branch h4 {
  margin: 0;
}

.compact-definition-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 0;
}

.compact-definition-list div,
.knowledge-tree-branch,
.metadata-entry-list li,
.tag-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.compact-definition-list dt {
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.compact-definition-list dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
}

.tag-list,
.metadata-entry-list,
.phase-rail ol,
.model-matrix ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 0;
  list-style: none;
}

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

.phase-rail li,
.model-matrix li {
  display: grid;
  gap: 8px;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: 0 10px 10px 0;
}

.phase-focus {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.markdown-catalogue details {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-soft);
}

.markdown-catalogue summary {
  cursor: pointer;
  font-weight: 850;
}

@media (max-width: 760px) {


}

/* MIA-ASSISTANT-05: full-section Canvas drawer shell and visible Context Pack. */
.mia-workspace[data-mia-drawer-shell] {
  grid-template-columns: minmax(220px, var(--mia-left-width, 250px)) minmax(0, 1fr) minmax(220px, var(--mia-right-width, 260px));
  width: 100%;
  max-width: 100%;
  gap: 12px;
}

.mia-workspace[data-left-collapsed="true"] {
  grid-template-columns: minmax(56px, 64px) minmax(0, 1fr) minmax(220px, var(--mia-right-width, 260px));
}

.mia-workspace[data-right-collapsed="true"] {
  grid-template-columns: minmax(220px, var(--mia-left-width, 250px)) minmax(0, 1fr) minmax(56px, 64px);
}

.mia-workspace[data-left-collapsed="true"][data-right-collapsed="true"] {
  grid-template-columns: minmax(56px, 64px) minmax(0, 1fr) minmax(56px, 64px);
}

.mia-workspace[data-mia-drawer-shell] .mia-right-rail {
  grid-column: auto;
  grid-template-columns: 1fr;
}

.mia-drawer {
  resize: none;
  overflow: auto;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(16, 19, 26, .72);
}

.mia-drawer.collapsed {
  resize: none;
}

.mia-drawer.collapsed > :not(.drawer-bar) {
  display: none;
}

.mia-drawer.collapsed .drawer-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mia-drawer.collapsed .drawer-bar {
  justify-content: center;
}

.drawer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.drawer-bar button {
  white-space: nowrap;
}

.mia-context-briefing,
.context-source-list {
  min-width: 0;
}

.context-source-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
  overflow-wrap: anywhere;
}

.context-source-list li {
  display: grid;
  gap: 3px;
}

.context-source-list li.omitted {
  color: var(--muted);
}

@media (max-width: 760px) {
  .mia-workspace[data-mia-drawer-shell],
  .mia-workspace[data-left-collapsed="true"],
  .mia-workspace[data-right-collapsed="true"],
  .mia-workspace[data-left-collapsed="true"][data-right-collapsed="true"] {
    grid-template-columns: 1fr;
  }
  .mia-drawer {
    resize: none;
  }
}

@media (max-width: 760px) {
  .mia-workspace[data-mia-drawer-shell] {
    display: block;
  }

  .mia-drawer {
    border-radius: 10px;
  }

  .mia-drawer.collapsed > :not(.drawer-bar) {
    display: none;
  }
}


body.agents-active {
  height: 100dvh;
  overflow-x: visible;
  overflow-y: hidden;
}

body.agents-active .app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.agents-active .workspace {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.agents-active .content {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-height: 0;
  overflow: hidden;
  padding: 16px 18px 18px;
}

.agents-v3-workspace {
  --ops-bg: #080b12;
  --ops-surface: #10141d;
  --ops-surface-raised: #151a24;
  --ops-text: #f7f8fb;
  --ops-muted: #b8bdc9;
  --ops-border: rgba(226, 231, 241, .18);
  --ops-chip: rgba(247, 248, 251, .075);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  height: 100dvh;
  max-height: calc(100dvh - 96px);
  min-height: 0;
  color: var(--ops-text);
}

.agents-v3-head {
  display: flex;
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  background: var(--ops-bg);
  padding: 10px 12px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 0;
}

.agents-v3-head h1,
.agents-v3-head p {
  margin-bottom: 0;
}

.agents-v3-workspace .workflow-browser {
  min-height: 0;
  max-height: 180px;
  overflow: auto;
}

.agents-v3-workspace h1,
.agents-v3-workspace h2,
.agents-v3-workspace h3,
.agents-v3-workspace label,
.agents-v3-workspace .agent-legend,
.agents-v3-workspace .badge,
.agents-v3-workspace .notice,
.agents-v3-workspace .agents-live-card,
.agents-v3-workspace .agents-owner-banner {
  color: var(--ops-text);
}

.agents-v3-workspace p,
.agents-v3-workspace small,
.agents-v3-workspace .muted,
.agents-v3-workspace label span,
.agents-v3-workspace .agents-map-status,
.agents-v3-workspace .agents-live-card p,
.agents-v3-workspace .agents-owner-banner {
  color: var(--ops-muted) !important;
}

.agents-v3-workspace .eyebrow,
.agents-v3-workspace .badge,
.agents-v3-workspace .agent-legend,
.agents-v3-workspace .notice {
  border-color: var(--ops-border);
}

:root[data-theme] .agents-v3-workspace .agents-live-card,
:root[data-theme] .agents-v3-workspace .agents-owner-banner,
:root[data-theme] .agents-v3-workspace .toolbar {
  background: var(--ops-surface-raised);
  border-color: var(--ops-border);
  color: var(--ops-text);
  box-shadow: none;
}

.agents-v3-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, .92fr);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.agents-map-pane,
.agents-roster-pane {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  background: var(--ops-surface);
}

.agents-map-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.agents-map-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--ops-border);
}

.agents-map-topbar h2,
.agents-map-topbar p {
  margin-bottom: 0;
}

.agents-map-status {
  font-size: 12px;
}

.agents-map-controls,
.agents-map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.agents-map-controls button {
  min-width: 44px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
}

.agents-map-stage {
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(0deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 42px 42px;
}

.agents-map-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.agents-map-summary span {
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
}

.template-search input {
  width: 100%;
}

.agents-map-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
}

.agents-map-legend {
  padding: 10px 14px;
  border-top: 1px solid var(--ops-border);
}

.agent-legend {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--ops-border);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.agent-legend--ceo { color: #c18421; }
.agent-legend--assistant { color: #b898ff; }
.agent-legend--project { color: #62a7ff; }
.agent-legend--worker { color: #79d8a4; }

.agent-edge {
  stroke: rgba(215, 211, 202, .64);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.agent-edge--configured {
  stroke-dasharray: 8 7;
  opacity: .62;
}

.agent-edge--observed {
  stroke: #85d8ff;
  stroke-width: 2.8;
}

.agent-edge-label {
  fill: var(--ops-text);
  paint-order: stroke;
  stroke: rgba(16, 19, 26, .9);
  stroke-width: 4px;
  text-anchor: middle;
  font-size: 12px;
  font-weight: 850;
}

.agent-node {
  cursor: pointer;
}

.agent-node-ring,
.agent-node-core {
  vector-effect: non-scaling-stroke;
}

.agent-node-ring {
  fill: transparent;
  stroke-width: 4;
}

.agent-node-core {
  stroke: rgba(255, 255, 255, .48);
  stroke-width: 1.5;
}

.agent-node-dot {
  fill: #a8acb8;
  stroke: #10131a;
  stroke-width: 2;
}

.agent-node--ceo .agent-node-core { fill: #7c5416; }
.agent-node--assistant .agent-node-core { fill: #55418d; }
.agent-node--project .agent-node-core { fill: #1f5f9e; }
.agent-node--worker .agent-node-core { fill: #23724d; }
.agent-node--ceo .agent-node-ring { stroke: #e1a43a; }
.agent-node--assistant .agent-node-ring { stroke: #b898ff; }
.agent-node--project .agent-node-ring { stroke: #62a7ff; }
.agent-node--worker .agent-node-ring { stroke: #79d8a4; }
.agent-node-state--active .agent-node-dot { fill: #9ad6a9; }
.agent-node-state--stale .agent-node-dot { fill: #f0cd80; }
.agent-node-state--unavailable .agent-node-dot { fill: #ef9b9b; }
.agent-node-state--unknown .agent-node-dot { fill: #a8acb8; }

.agent-node-label,
.agent-node-state-label {
  fill: #fff;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, .62);
  stroke-width: 3px;
  font-weight: 850;
}

.agent-node-label {
  font-size: 12px;
}

.agent-node-state-label {
  font-size: 10px;
  text-transform: uppercase;
}

.agents-roster-pane {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 12px;
}

.agents-roster-pane .toolbar {
  margin-bottom: 0;
}

.agents-roster-pane [data-agent-results] {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

:root[data-theme] .agents-roster-pane .light-profile-card {
  background: #fffdf8;
  border-color: rgba(22, 25, 32, .16);
  color: #17191d;
  box-shadow: none;
}

:root[data-theme] .agents-roster-pane .light-profile-card h3,
:root[data-theme] .agents-roster-pane .light-profile-card p,
:root[data-theme] .agents-roster-pane .light-profile-card small {
  color: #17191d !important;
}

:root[data-theme] .agents-roster-pane .light-profile-card .agent-mission {
  color: #515766 !important;
}

.agent-card--compact {
  display: grid;
  gap: 7px;
  padding: 9px !important;
}

.agent-card--compact .agent-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.agent-card--compact h3 {
  margin: 0 0 3px;
}

.agent-card--compact .agent-role-label {
  align-self: start;
  padding: 3px 6px;
  font-size: 10px;
  line-height: 1.2;
}

.agent-card--compact .agent-mission {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.agent-card--compact button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12px;
}

.agent-status-line {
  margin: 0;
  border: 1px solid rgba(22, 25, 32, .12);
  border-radius: 7px;
  background: #f5efe6;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.agents-live-card {
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  padding: 12px;
  background: var(--ops-surface-raised);
}

.agents-mobile-tabs {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .agent-edge,
  .agent-node {
    transition: none;
    animation: none;
  }
}

/* MIA-WORKSTATION-06 remediation: route-local locked Canvas workstation. */
.content:has(.mia-route-lock) {
  overflow: hidden !important;
  padding: 0 !important;
}

.mia-route-lock {
  --mia-left-rail-width: 288px;
  --mia-right-rail-width: 320px;
  position: relative;
  height: calc(100dvh - 74px);
  min-height: 0;
  overflow: hidden;
  display: block;
}

.mia-route-lock[data-left-rail-state="compact"] {
  --mia-left-rail-width: 64px;
}

.mia-route-lock[data-left-rail-state="closed"] {
  --mia-left-rail-width: 0px;
}

.mia-route-lock .mia-workspace[data-mia-drawer-shell] {
  display: grid;
  grid-template-columns: var(--mia-left-rail-width) minmax(0, 1fr) var(--mia-right-rail-width);
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: grid-template-columns .22s ease;
}

.mia-edge-handle {
  position: absolute;
  z-index: 30;
  top: 50%;
  width: 44px;
  height: 72px;
  min-width: 44px;
  min-height: 44px;
  transform: translateY(-50%);
  display: grid;
  place-content: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-raised) 86%, transparent);
  color: var(--paper);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 0 0 1px var(--line);
  cursor: ew-resize;
  touch-action: pan-y;
}

.mia-edge-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mia-edge-handle--left {
  left: calc(var(--mia-left-rail-width) - 22px);
}

.mia-edge-handle--right {
  right: calc(var(--mia-right-rail-width) - 22px);
}

.mia-edge-handle--right {
  cursor: pointer;
}

.mia-edge-handle::before {
  content: '';
  position: absolute;
  inset: 8px 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.04));
}

.mia-edge-handle--left::after,
.mia-edge-handle--right::after {
  content: '';
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11 2.5 5.5 8 11 13.5M2.5 2.5v11' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M11 2.5 5.5 8 11 13.5M2.5 2.5v11' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}

.mia-edge-handle--right::after { transform: rotate(180deg); }

.mia-edge-notch {
  position: relative;
  z-index: 1;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: .72;
}

.mia-route-lock .mia-service-strip-compact {
  position: absolute;
  z-index: 8;
  top: 8px;
  right: 10px;
  max-width: min(720px, calc(100% - 24px));
  padding: 6px;
  font-size: 11px;
  pointer-events: none;
  opacity: .9;
}

.mia-route-lock .mia-left-rail,
.mia-route-lock .mia-right-rail,
.mia-route-lock .mia-canvas-pane,
.mia-route-lock .mia-canvas-stage {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.mia-route-lock .mia-left-rail,
.mia-route-lock .mia-right-rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
}

.rail-state-controls {
  display: none !important;
}

.mia-left-view-title {
  width: 100%;
  min-height: 44px;
  justify-content: space-between;
  text-align: left;
}

.mia-left-view-title::after {
  content: '↔';
  margin-left: auto;
  opacity: .7;
}

.mia-route-lock .mia-left-rail > :not(.drawer-bar),
.mia-route-lock .mia-right-rail > :not(.drawer-bar) {
  overflow: auto;
  min-height: 0;
}

.mia-route-lock[data-left-rail-state="closed"] .mia-left-rail {
  border: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.mia-route-lock[data-left-rail-state="compact"] .mia-left-rail > :not(.drawer-bar),
.mia-route-lock[data-left-rail-state="compact"] .drawer-title,
.mia-route-lock[data-left-rail-state="compact"] .mia-context-briefing,
.mia-route-lock[data-left-rail-state="compact"] .mia-session-disclosures,
.mia-route-lock[data-left-rail-state="compact"] .session-card-main strong,
.mia-route-lock[data-left-rail-state="compact"] .session-meta,
.mia-route-lock[data-left-rail-state="compact"] .session-project,
.mia-route-lock[data-left-rail-state="compact"] .mia-session-card time,
.mia-route-lock[data-left-rail-state="compact"] .session-actions button:not([data-action="mia-session-select"]) {
  display: none;
}

.mia-route-lock[data-left-rail-state="compact"] .mia-left-view-title {
  width: 44px;
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
}

.mia-route-lock[data-left-rail-state="compact"] .mia-left-view-title::after {
  content: '◖';
  text-indent: 0;
  margin: auto;
}

.mia-route-lock[data-left-rail-state="compact"] .mia-session-list,
.mia-route-lock[data-left-rail-state="compact"] .mia-session-card,
.mia-route-lock[data-left-rail-state="compact"] .session-actions {
  display: grid;
  place-items: center;
  padding: 0;
}

.mia-route-lock[data-left-rail-state="compact"] [data-action="mia-session-select"] {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-indent: 0;
}

.mia-session-state-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: none;
}

.mia-session-state-dot[data-run-state="queued"] { background: var(--warn); }
.mia-session-state-dot[data-run-state="running"],
.mia-session-state-dot[data-run-state="accepted"],
.mia-session-state-dot[data-run-state="artifact_ready"] { background: var(--accent); }
.mia-session-state-dot[data-run-state="succeeded"],
.mia-session-state-dot[data-run-state="completed"] { background: #71d6a4; }
.mia-session-state-dot[data-run-state="failed"],
.mia-session-state-dot[data-run-state="cancelled"] { background: #e58f8f; }
.mia-session-state-dot[data-run-state="status_uncertain"],
.mia-session-state-dot[data-run-state="cancel_requested"],
.mia-session-state-dot[data-run-state="awaiting_input"] { background: var(--warn); }

.mia-route-lock[data-left-rail-state="compact"] [data-action="mia-session-select"][aria-current="true"] .mia-session-state-dot {
  transform: scale(1.18);
}

.mia-route-lock .mia-canvas-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100%;
  gap: 10px;
  padding: 12px;
}

.mia-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mia-canvas-mode-pill {
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
}

.mia-route-lock .canvas-frame-wrap {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.mia-route-lock .canvas-frame-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.mia-route-lock .canvas-version-shell {
  max-height: 74px;
  overflow: auto;
}

.mia-bottom-dock {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
}

.mia-bottom-dock .mia-selector-row,
.mia-bottom-dock .composer-actions,
.mia-attachment-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.mia-bottom-dock .mia-composer {
  position: static;
  display: grid;
  gap: 8px;
  box-shadow: none;
  border: 0;
  padding: 0;
}

.mia-bottom-dock textarea {
  min-height: 56px;
}

.mia-attachment-chips {
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (prefers-reduced-motion: reduce) {
  .mia-route-lock .mia-workspace[data-mia-drawer-shell] {
    transition: none;
  }
}

@media (max-width: 760px) {

  body.agents-active .content {
    padding: 10px 12px;
  }

  .agents-v3-workspace {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 64px);
    gap: 8px;
  }

  .agents-v3-workspace .agents-v3-head {
    flex: 0 0 auto;
  }

  .agents-v3-head {
    align-items: flex-start;
  }

  .agents-v3-head h1 {
    font-size: 24px;
  }

  .agents-v3-head p {
    display: none;
  }

  .agents-v3-workspace .workflow-browser {
    flex: 0 0 120px;
    max-height: 120px;
  }

  .agents-mobile-tabs {
    display: grid;
    flex: 0 0 38px;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .agents-mobile-tabs button {
    min-height: 38px;
    border-radius: 8px;
  }

  .agents-mobile-tabs button[aria-selected="true"] {
    background: var(--paper);
    color: #17191d;
  }

  .agents-v3-layout {
    display: block;
    flex: 1 1 0;
    position: relative;
  }

  .agents-v3-layout > .agents-map-pane,
  .agents-v3-layout > .agents-roster-pane {
    position: absolute;
    inset: 0;
  }

  .agents-v3-layout[data-agent-mobile-pane="profiles"] > .agents-map-pane,
  .agents-v3-layout:not([data-agent-mobile-pane="profiles"]) > .agents-roster-pane {
    visibility: hidden;
    pointer-events: none;
  }

  .agents-map-topbar {
    display: grid;
  }

  .agents-map-svg {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .mia-route-lock {
    height: calc(100dvh - 58px);
  }

  .mia-route-lock .mia-workspace[data-mia-drawer-shell] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .mia-route-lock .mia-canvas-pane {
    display: block !important;
  }

  .mia-route-lock .mia-left-rail,
  .mia-route-lock .mia-right-rail {
    position: absolute;
    z-index: 12;
    inset: 8px;
    max-height: calc(100% - 16px);
    background: var(--surface-card);
    box-shadow: var(--shadow-elevated);
    transform: translateY(0);
  }

  .mia-route-lock .mia-workspace:not([data-active-mobile-pane="sessions"]) .mia-left-rail,
  .mia-route-lock .mia-workspace:not([data-active-mobile-pane="chat"]) .mia-right-rail {
    display: none;
  }

  .mia-mobile-drawer {
    position: absolute;
    z-index: 120;
    left: 12px;
    right: 12px;
    bottom: 70px;
  }
}

/* Geometry fence: Mia owns the viewport, not the ordinary HOME document shell. */
html:has(.mia-route-lock), body:has(.mia-route-lock) { height: 100dvh; overflow-y: hidden; overflow-x: auto; }
:root[data-theme] .app-shell:has(.mia-route-lock) { height: 100dvh; min-height: 0; width: 100%; grid-template-columns: minmax(0, 1fr); }
.app-shell:has(.mia-route-lock) > .sidebar{ display: none; }
:root[data-theme] .workspace:has(.mia-route-lock) { height: 100dvh; min-height: 0; width: 100%; display: grid; grid-template-rows: minmax(0, 1fr); }
:root[data-theme] .content:has(.mia-route-lock) { display: block; width: 100%; scrollbar-gutter: auto; }
.workspace:has(.mia-route-lock) .mobile-menu { display: inline-flex; }
.mia-route-lock { height: 100%; --mia-right-rail-width: 280px; }
.mia-route-lock .mia-workspace[data-mia-drawer-shell] { gap: 0; width: 100%; --mia-left-rail-width: inherit; --mia-right-rail-width: inherit; }
.mia-route-lock .mia-service-strip-compact { display: none; }
.mia-route-lock .mia-left-rail, .mia-route-lock .mia-right-rail { width: auto; max-width: none; height: 100%; padding: 8px; gap: 8px; }
.mia-route-lock .mia-left-rail > .mia-rail-body, .mia-route-lock .mia-right-rail > .mia-rail-body { display: block; align-self: stretch; height: 100%; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.mia-route-lock .mia-rail-body .mia-transcript { max-height: none; overflow: visible; }
.mia-route-lock .drawer-bar { display: flex; flex-wrap: wrap; touch-action: none; }
.mia-route-lock .rail-state-controls { display: flex; gap: 4px; }
.mia-route-lock .rail-state-controls button { padding: 4px 6px; }
.mia-route-lock[data-left-rail-state="closed"] .mia-left-rail { width: 0; padding: 0; border: 0; }
.mia-route-lock[data-left-rail-state="compact"] .mia-left-rail .drawer-bar { min-width: 0; padding: 0; }
.mia-route-lock[data-left-rail-state="compact"] .mia-left-rail .drawer-bar::after { content: '↔'; }
.mia-route-lock[data-left-rail-state="compact"] .rail-state-controls,
.mia-route-lock[data-left-rail-state="compact"] .session-card-main,
.mia-route-lock[data-left-rail-state="compact"] .mia-session-rail > .panel-head { display: none; }
.mia-route-lock[data-left-rail-state="compact"] .mia-session-rail { padding: 0; border: 0; }
.mia-route-lock[data-left-rail-state="compact"] .mia-left-rail > .mia-rail-body { display: block; }
.mia-route-lock[data-left-rail-state="compact"] [data-action="mia-session-select"] { width: 28px; height: 28px; background: transparent; }
.mia-route-lock[data-right-rail-open="false"] { --mia-right-rail-width: 0px; }
.mia-route-lock[data-right-rail-open="false"] .mia-right-rail { width: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.mia-route-lock .mia-canvas-pane { padding: 0; display: block; height: 100%; }
.mia-route-lock .mia-canvas-stage { grid-template-rows: 44px minmax(0, 1fr) 24px auto; gap: 6px; padding: 8px; }
.mia-canvas-toolbar h2 { min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mia-route-lock .canvas-version-shell { max-height: 24px; display: flex; gap: 8px; overflow: hidden; }
.mia-route-lock .canvas-version-shell h3 { display: none; }
.mia-route-lock .canvas-version-list { display: flex; margin: 0; padding: 0; gap: 8px; font-size: 11px; }
.mia-route-lock .canvas-version-list button { padding: 2px 8px; min-height: 0; }
.mia-route-lock .mia-bottom-dock { padding: 6px; gap: 4px; }
.mia-route-lock .mia-bottom-dock .mia-composer { margin: 0; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 0; }
.mia-route-lock .mia-dock-controls, .mia-route-lock .mia-dock-chat { margin: 0; padding: 0; }
.mia-route-lock .mia-dock-controls .mia-selector-row { padding: 0; border: 0; min-height: 0; }
.mia-dock-controls, .mia-dock-chat { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mia-dock-chat textarea { flex: 1; min-width: 0; }
.mia-route-lock .mia-bottom-dock textarea { min-height: 36px; height: 36px; padding: 6px 8px; resize: none; }
.mia-dock-controls .mia-selector-row { display: flex; flex: 1; gap: 4px; margin: 0; min-width: 0; }
.mia-dock-controls .mia-selector-row label { display: block; min-width: 0; }
.mia-dock-controls .mia-selector-row label > span { display: none; }
.mia-dock-controls .mia-selector-row label:last-child { flex: 1; }
.mia-dock-controls select { width: 100%; min-width: 0; max-width: 180px; height: 32px; padding: 3px; font-size: 12px; }


.mia-dock-controls button, .mia-dock-chat button { min-height: 32px; padding: 4px 8px; }
.mia-dock-controls .mia-file-dock { position: relative; display: flex; align-items: center; flex: none; height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; overflow: hidden; }
.mia-file-dock input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.mia-file-dock:focus-within { outline: 2px solid var(--accent); }
.mia-dock-status { display: flex; gap: 8px; font-size: 10px; min-height: 12px; line-height: 12px; }
.mia-dock-status span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mia-route-lock .mia-attachment-chips:empty { display: none; }
.mia-route-lock .mia-attachment-chips { font-size: 11px; flex-wrap: nowrap; overflow: hidden; }
.mia-attachment-chips li { display: flex; min-width: 0; gap: 4px; }
.mia-attachment-chips li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mia-attachment-chips button { padding: 0 4px; min-height: 20px; }
.mia-drawer-backdrop { display: none; }
.transcript-save-failed { color: var(--warn); }
@media (min-width: 761px) and (max-width: 1100px) {
  .mia-route-lock { --mia-left-rail-width: 240px; --mia-right-rail-width: 240px; }
}
@media (max-width: 760px) {
  .mia-route-lock .mia-workspace[data-mia-drawer-shell] { padding-bottom: 48px; }
  .mia-route-lock .mia-left-rail, .mia-route-lock .mia-right-rail { inset: 8px 24px 56px 8px; width: auto; height: auto; opacity: 1 !important; pointer-events: auto !important; background: var(--surface, #17202c); }
  .mia-route-lock .mia-edge-handle { top: 44%; height: 64px; }
  .mia-route-lock .mia-edge-handle--left { left: max(0px, env(safe-area-inset-left)); }
  .mia-route-lock .mia-edge-handle--right { right: max(0px, env(safe-area-inset-right)); }
  .mia-route-lock .mia-mobile-drawer { z-index: 13; bottom: env(safe-area-inset-bottom, 0px); height: 48px; display: flex; padding: 2px; }
  .mia-mobile-drawer button { flex: 1; min-height: 44px; }
  .mia-route-lock .mia-canvas-stage { padding: 4px; }
  .mia-dock-controls { flex-wrap: wrap; gap: 4px; }
  .mia-dock-controls .mia-selector-row { flex: 1; }

  .mia-dock-controls button, .mia-dock-chat button, .mia-dock-controls .mia-file-dock, .mia-dock-controls select { min-height: 44px; }

  .mia-route-lock .mia-dock-chat textarea { height: 44px; }
  .mia-drawer-backdrop:not([hidden]) { display: block; position: absolute; inset: 0 0 48px; z-index: 11; background: #0008; border: 0; border-radius: 0; }
}


/* CEO tickets clients projects release */
.command-section { display: grid; gap: 18px; min-width: 0; }
.section-hero.compact { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.section-hero.compact h1 { margin: 0 0 6px; font-size: clamp(1.8rem, 3vw, 2.8rem); letter-spacing: 0; }
.section-hero.compact p { max-width: 820px; }
.toolbar.workstation-toolbar, .workflow-badge-row, .button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.workstation-shadow-selector { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(420px, 1.15fr); gap: 18px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.workstation-shadow-copy { display: grid; gap: 5px; }
.workstation-shadow-copy h2, .workstation-shadow-copy p { margin: 0; }
.workstation-shadow-copy small { color: var(--muted); line-height: 1.45; }
.workstation-shadow-controls { display: grid; grid-template-columns: repeat(3, minmax(132px, 1fr)); gap: 8px; align-items: stretch; }
.workstation-shadow-option { display: grid; justify-items: start; gap: 4px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel2); color: var(--text); text-align: left; cursor: pointer; }
.workstation-shadow-option:hover, .workstation-shadow-option:focus-visible { border-color: var(--accent); transform: translateY(-1px); }
.workstation-shadow-option.selected { border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); background: rgba(113, 214, 164, .08); }
.workstation-shadow-option small { color: var(--muted); }
.workstation-shadow-controls > .badge { justify-self: start; }
.workflow-badge-row .badge.ok, .workflow-version-card.active .badge { border-color: rgba(113, 214, 164, .48); color: var(--ok); }
.workstation-ticket-form { display: grid; gap: 12px; padding: 16px; overflow-x: hidden; }
.workstation-ticket-grid { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(140px, .5fr) minmax(140px, .5fr); gap: 10px; }
.workstation-ticket-form textarea { resize: vertical; min-height: 96px; }
.workstation-version-tree { display: grid; gap: 12px; padding: 16px; overflow-x: hidden; }
.version-tree-scope-list, .version-tree-node-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.version-tree-scope { border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); padding: 10px; min-width: 0; }
.version-tree-scope summary { display: flex; gap: 8px; justify-content: space-between; align-items: center; cursor: pointer; }
.version-tree-node-list { margin-top: 10px; padding-left: 12px; border-left: 1px solid var(--line); }
.version-tree-node { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px 0; min-width: 0; }
.version-tree-connector { color: var(--muted); opacity: .7; }
.version-tree-node-main { display: grid; gap: 4px; min-width: 0; }
.version-tree-node-main b, .version-tree-node-main small { overflow-wrap: anywhere; }
.owner-internal-profile-card { display: grid; gap: 4px; border: 1px solid rgba(113, 214, 164, .36); border-radius: 10px; background: rgba(113, 214, 164, .06); padding: 10px; }
.owner-internal-profile-card h3 { margin: 0; font-size: .98rem; }
.workstation-board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; align-items: stretch; min-height: 56vh; overflow: auto; }
.workstation-lane { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 12px; display: grid; align-content: start; gap: 10px; }
.workstation-lane > header { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.workstation-lane h2, .command-list h2, .project-command-center h2, .users-page h2 { margin: 0; font-size: 1rem; letter-spacing: 0; }
.ticket-card, .mini-card, .access-state-card, .workflow-version-card, .portal-card, .project-totals article { border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); padding: 12px; min-width: 0; }
.ticket-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.ticket-card h3, .workflow-version-card h3, .portal-card h3 { margin: 0 0 6px; font-size: 1rem; letter-spacing: 0; }
.ticket-timeline ol { margin: 8px 0 0; padding-left: 18px; }
.ticket-timeline li { margin: 5px 0; color: var(--muted); }
.command-grid.three { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(200px, .8fr) minmax(0, 1.6fr); gap: 14px; align-items: start; }
.command-list { display: grid; gap: 8px; align-content: start; }
.command-list button { justify-content: flex-start; text-align: left; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 10px; }
.command-list button.selected { border-color: var(--accent); background: rgba(255,255,255,.08); }
.portal-preview { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); color: #151713; }
.portal-preview.empty { background: var(--panel); color: var(--text); padding: 12px; }
.preview-banner { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; background: #171c1b; color: #f7f2ea; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.portal-shell header, .portal-tabs { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid rgba(20, 23, 19, .14); }
.portal-tabs { justify-content: flex-start; overflow: auto; }
.portal-tab { border: 1px solid rgba(20, 23, 19, .14); border-radius: 8px; padding: 7px 9px; white-space: nowrap; }
.portal-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
.project-totals { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; }
.project-totals span, .project-totals small { display: block; color: var(--muted); font-size: .78rem; }
.project-totals strong { display: block; margin-top: 4px; font-size: 1.2rem; letter-spacing: 0; }
.access-state-grid, .workflow-version-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.workflow-browser { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 14px; display: grid; gap: 12px; }
.compact-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin: 0; }
.compact-definition-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; }
.compact-definition-list dt { color: var(--muted); }
.compact-field { max-width: 360px; }
.users-workspace-shell { display: grid; gap: 16px; min-width: 0; }
.user-workspace-tabs { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 8px; }
.user-workspace-tabs button { flex: 1 1 150px; justify-content: center; min-height: 42px; }
.user-workspace-tabs button.selected { border-color: var(--accent); background: rgba(255,255,255,.09); }
.user-workspace-section { display: grid; gap: 14px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 14px; }
.users-access-preview { display: grid; gap: 14px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 14px; }
.user-workspace-projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.user-workspace-project-card { display: grid; gap: 8px; align-content: start; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); color: var(--text); padding: 12px; }
.user-workspace-project-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent), transparent 45%); }
.user-workspace-project-title { font-weight: 700; }
.selected-user-project { display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 14px; }
.user-project-pane-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.user-project-pane-tabs button { min-height: 40px; }
.user-project-pane-tabs button.selected { border-color: var(--accent); background: rgba(255,255,255,.09); }
.user-project-planning-hub { display: grid; min-width: 0; gap: 12px; }
.user-project-planning-hub iframe { display: block; width: 100%; min-height: 760px; height: min(86vh, 1100px); border: 1px solid var(--line); border-radius: 12px; background: #101010; }
.environment-access-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.environment-access-row { display: grid; grid-template-columns: minmax(44px, .25fr) minmax(84px, .35fr) minmax(0, 1fr); gap: 8px; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.035); padding: 8px; }
.environment-access-row a, .environment-access-muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.environment-access-main { display: grid; gap: 2px; min-width: 0; }
.environment-access-name { font-weight: 850; letter-spacing: 0; }
.environment-access-meta { font-size: .72rem; }
.environment-access-row.configured { border-color: rgba(113, 214, 164, .45); }
.environment-access-row.not-configured { border-color: rgba(244, 183, 64, .28); }
.user-workspace-vault { display: grid; gap: 12px; min-width: 0; }
.vault-summary-row { display: flex; flex-wrap: wrap; gap: 8px; }
.vault-project-groups, .vault-project-group, .vault-category-group { display: grid; gap: 10px; min-width: 0; }
.vault-project-group { border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); padding: 12px; }
.vault-project-group h3 { margin: 0; }
.vault-item-row { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(96px, .5fr) auto minmax(120px, .9fr); gap: 8px; align-items: center; min-width: 0; border-top: 1px solid var(--line); padding-top: 8px; }
.vault-item-row > a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.vault-item-label { font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.vault-item-hint { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.vault-field-row { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; min-width: 0; }
.vault-field-control { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.vault-field-control code { max-width: min(420px, 80vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 4px 6px; }
@media (max-width: 1100px) { .workstation-board { grid-template-columns: repeat(2, minmax(240px, 1fr)); } .workstation-shadow-selector { grid-template-columns: 1fr; } .project-totals { grid-template-columns: repeat(3, minmax(120px, 1fr)); } .command-grid.three { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .section-hero.compact, .compact-head { display: grid; } .workstation-board, .portal-main, .project-totals, .access-state-grid, .workflow-version-grid, .environment-access-inline, .environment-access-row, .vault-item-row, .workstation-shadow-controls, .workstation-ticket-grid { grid-template-columns: 1fr; } .workstation-version-tree, .workstation-ticket-form { padding: 12px; } }

/* Selected-version topology: layout containment belongs to the application grid. */
body.agents-active .workspace { height:100%; }
body.agents-active .agents-v3-workspace { height:100%; max-height:none; grid-template-rows:auto minmax(0,1fr); overflow:hidden; }
body.agents-active .agents-v3-head { align-items:center; padding:6px 10px; }
body.agents-active .agents-v3-head > div > p { display:none; }
body.agents-active .agents-v3-head h1 { font-size:20px; margin:0; }
body.agents-active .agents-v3-head > .badge { max-width:60%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
body.agents-active .agents-v3-layout { min-height:0; grid-template-columns:minmax(0,2fr) minmax(250px,.8fr); }
body.agents-active .agents-map-pane { grid-template-rows:auto minmax(0,1fr) auto; min-height:0; }
body.agents-active .agents-map-stage { position:relative; min-height:0; background:#070A10; }
body.agents-active .agents-map-svg { display:block; width:100%; height:100%; min-height:0; touch-action:none; }
body.agents-active .agents-map-topbar { padding:8px; gap:8px; flex-wrap:wrap; max-height:30dvh; overflow:auto; }
body.agents-active .agents-map-topbar h2 { font-size:14px; margin:0; }
body.agents-active .agents-map-status { max-width:440px; font-size:11px; margin:2px 0; }
body.agents-active .agents-map-controls { gap:4px; min-width:0; flex-wrap:wrap; flex:1 1 350px; justify-content:flex-end; }
body.agents-active .agents-map-controls button { min-height:44px; padding:6px 8px; }
body.agents-active .agents-version-field { display:grid; gap:2px; flex:1 1 160px; min-width:0; }
body.agents-active .agents-version-field span { font-size:11px; }
body.agents-active .agents-version-field select { width:100%; min-width:0; min-height:44px; max-width:100%; padding:4px; color:#f7f8fb; background:#151a24; }
body.agents-active .agents-map-legend { font-size:10px; padding:5px 8px; }
.agent-policy { font-size:11px; max-width:480px; }
.agent-policy p { padding:6px; }
.agent-client-box { fill:#101722; stroke:#8EA5BC; stroke-opacity:.5; stroke-width:1.5; vector-effect:non-scaling-stroke; }
.agent-client-title { fill:#CBD6E6; font-size:16px; font-weight:600; }
.agent-client-divider { fill:none; stroke:#344457; stroke-width:1; }
.agent-edge { fill:none; opacity:.42; stroke:#90A4BF; }
.agent-edge--active { opacity:1; stroke:#9BC7DE; stroke-width:2.6; }
.agent-edge--stale { stroke-dasharray:4 6; opacity:.35; }
.agent-edge--dormant { stroke-dasharray:2 7; }
.agent-node .agent-node-core { stroke:#ffffff48; stroke-width:1.2; }
.agent-node--ceo .agent-node-core { fill:url(#agent-depth-ceo); }
.agent-node--mia .agent-node-core { fill:url(#agent-depth-mia); }
.agent-node--project .agent-node-core { fill:url(#agent-depth-project); }
.agent-node--worker .agent-node-core { fill:url(#agent-depth-worker); }
.agent-node { color:#9FAFC4; outline:none; }
.agent-node--ceo { color:#E1A43A; }
.agent-node--mia { color:#B898FF; }
.agent-node--project { color:#62A7FF; }
.agent-node--worker { color:#79D8A4; }
.agent-state-ring { fill:none; stroke:currentColor; stroke-width:1.5; opacity:.45; vector-effect:non-scaling-stroke; }
.agent-state-glyph { fill:#10141d; stroke:currentColor; stroke-width:1.5; }
.agent-node-state--active .agent-state-glyph circle { fill:currentColor; }
.agent-node-state--active .agent-state-ring { opacity:1; stroke-width:2; }
.agent-node-state--dormant [data-agent-particle] { opacity:.68; }
.agent-node-state--stale [data-agent-particle] { opacity:.48; }
.agent-node-state--stale .agent-state-ring { stroke-dasharray:4 5; }
.agent-node-state--blocked .agent-state-ring { stroke-dasharray:8 3; stroke-width:3; }
.agent-node-state--unavailable [data-agent-particle] { opacity:.42; }
.agent-focus-ring { fill:none; stroke:transparent; stroke-width:3; vector-effect:non-scaling-stroke; pointer-events:none; }
.agent-node:focus-visible .agent-focus-ring { stroke:#E9F1FF; }
[data-agent-ticket-count] { fill:#FFF4D8; font-weight:700; stroke:none; }
[data-agent-topology-details] { position:absolute; z-index:6; width:min(320px,calc(100% - 8px)); max-height:calc(100% - 8px); display:flex; flex-direction:column; border:1px solid #70839A; border-radius:10px; background:#111823; color:#F2F5FA; box-shadow:0 8px 24px #0008; padding:10px; overflow:hidden; }
[data-agent-topology-details][hidden] { display:none; }
[data-agent-topology-details] header { display:flex; align-items:center; justify-content:space-between; gap:8px; flex:0 0 auto; }
[data-agent-topology-details] button { min-height:44px; }
.agent-details-body { min-height:0; overflow:auto; overscroll-behavior:contain; font-size:12px; }
.agent-details-body dl { margin:8px 0; }
.agent-details-body dt { color:#A9B6C9; }
.agent-details-body dd { margin:0 0 8px; overflow-wrap:anywhere; }
.agent-entity-list { border:1px solid #455163; padding:8px; border-radius:8px; }
.agent-entity-list summary { min-height:44px; display:flex; align-items:center; cursor:pointer; }
.agent-entity-list button { display:block; min-height:44px; width:100%; text-align:left; margin-top:4px; }
@media (max-width:760px) {
  body.agents-active .content { padding:6px; }
  body.agents-active .agents-v3-workspace { grid-template-rows:auto auto minmax(0,1fr); gap:4px; }
  body.agents-active .agents-v3-layout { grid-template-columns:1fr; min-height:0; }
  body.agents-active .agents-map-topbar { display:grid; grid-template-columns:1fr; max-height:32dvh; padding:5px; }
  body.agents-active .agents-map-topbar h2 { display:none; }
  body.agents-active .agents-map-controls { display:grid; grid-template-columns:minmax(90px,1fr) repeat(5,auto); gap:3px; }
  body.agents-active .agents-map-controls [data-agent-map-scale] { display:none; }
  body.agents-active .agents-version-field { grid-column:1/-1; }
  body.agents-active .agents-map-controls button { min-width:44px; }
  body.agents-active .agents-map-legend { font-size:9px; }
}
@media (max-height:500px) {
  body.agents-active .agents-v3-head { display:none; }
  body.agents-active .agents-v3-workspace { grid-template-rows:minmax(0,1fr); }
  body.agents-active .agents-map-topbar { max-height:130px; }
  body.agents-active .agent-policy,body.agents-active .agents-map-status { display:none; }
}
@media (max-height:500px) and (max-width:760px) {
  body.agents-active .agents-v3-workspace { grid-template-rows:auto minmax(0,1fr); }
}
@media (prefers-reduced-motion:reduce) { .agents-map-svg * { animation:none !important; transition:none !important; } }

/* Project Plan v4: HOME-native selected Project document shell. */
.project-plan {
  --plan-radius: 20px;
  --plan-inner-radius: 14px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.project-plan-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--plan-radius);
  background: color-mix(in srgb, var(--surface-card) 88%, var(--bg));
  box-shadow: var(--shadow-card);
}
.project-plan-heading {
  min-width: 0;
}
.project-plan-head h1 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.04;
}
.project-plan-head p {
  max-width: 74ch;
  margin: 0;
  color: var(--muted);
}
.project-plan-version-row {
  margin-top: 12px;
}
.project-plan-workspace-tools {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.project-plan-tool-button,
.project-plan-print-popover button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}
.project-plan-tool-button {
  padding: 9px 13px;
}
.button-icon,
.button-icon .icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.button-icon .icon {
  stroke: currentColor;
  fill: none;
}
.project-plan-print-menu {
  position: relative;
}
.project-plan-print-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  gap: 6px;
  min-width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--plan-inner-radius);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}
.project-plan-print-popover button {
  justify-content: flex-start;
  width: 100%;
  padding: 9px 11px;
  border-radius: 12px;
}
.project-plan-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.project-plan-toolbar button {
  min-height: 40px;
  border-radius: 999px;
}
.project-plan-shell {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}
.project-plan-shell.has-access {
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(240px, 300px);
}
.project-plan-rail-wrap {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.project-plan-rail,
.plan-control-group,
.project-plan-access {
  border: 1px solid var(--line);
  border-radius: var(--plan-inner-radius);
  background: color-mix(in srgb, var(--surface-card) 92%, transparent);
  box-shadow: var(--shadow-card);
}
.project-plan-rail {
  display: grid;
  gap: 7px;
  padding: 8px;
}
.project-plan-rail button {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  width: 100%;
  min-height: 54px;
  padding: 10px 11px;
  text-align: left;
  border-radius: 12px;
  background: transparent;
}
.project-plan-rail button.selected {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 4px 0 0 var(--accent);
}
.project-plan-rail small {
  color: var(--muted);
  font-size: 12px;
}
.project-plan-canvas {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.project-plan-page {
  min-width: 0;
  display: none;
  gap: 15px;
  padding: clamp(16px, 2.4vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--plan-radius);
  background: color-mix(in srgb, var(--surface-card) 94%, var(--bg));
  box-shadow: var(--shadow-card);
}
.project-plan-page.selected {
  display: grid;
}
.project-plan-page-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(22px, 3vw, 31px);
  line-height: 1.1;
}
.plan-node {
  display: grid;
  gap: 11px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--plan-inner-radius);
  background: color-mix(in srgb, var(--surface-raised) 72%, transparent);
}
.plan-node-depth-0 {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.plan-node h2,
.plan-node h3,
.plan-node h4 {
  margin: 0;
  color: var(--ink);
}
.plan-node h2 {
  font-size: 22px;
}
.plan-node h3 {
  font-size: 18px;
}
.plan-node h4 {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}
.plan-node-list,
.plan-node-field {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.plan-node-value,
.plan-node p,
.plan-node dd {
  overflow-wrap: anywhere;
}
.plan-control-group,
.project-plan-access {
  display: grid;
  gap: 10px;
  padding: 12px;
}
.plan-control-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; }
.plan-node-grants { display: grid; gap: 8px; }
.plan-node-grant-group { display: grid; gap: 6px; }
.plan-node-grant-children { display: grid; gap: 6px; margin-left: 18px; padding-left: 12px; border-left: 1px solid var(--line); }
.plan-tree-node { margin-left: calc(var(--plan-depth, 0) * 14px); }
.ticket-phase-summary,
.template-upgrade-result { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-card); }
.ticket-phase-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.template-upgrade { display: grid; gap: 14px; }
.template-upgrade-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 900px) {
  .project-plan-head { grid-template-columns: minmax(0, 1fr); }
  .project-plan-workspace-tools { justify-content: flex-start; }
  .project-plan-shell,
  .project-plan-shell.has-access { grid-template-columns: 1fr; }
  .project-plan-rail-wrap { position: static; }
  .project-plan-rail { grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); overflow-x: auto; scrollbar-width: none; }
  .project-plan-rail::-webkit-scrollbar { display: none; }
}

@media (max-width: 430px) {
  .project-plan-head,
  .project-plan-page { padding: 14px; }
  .project-plan-workspace-tools,
  .project-plan-tool-button { width: 100%; }
  .project-plan-print-menu { width: 100%; }
  .project-plan-print-popover {
    left: 0;
    right: auto;
    width: min(100%, 260px);
  }
}

@media print {
  html[data-plan-print-mode] body * {
    visibility: hidden !important;
  }
  html[data-plan-print-mode] .project-plan,
  html[data-plan-print-mode] .project-plan * {
    visibility: visible !important;
  }
  html[data-plan-print-mode] .project-plan {
    position: static !important;
    display: block !important;
    color: #111 !important;
    background: #fff !important;
  }
  html[data-plan-print-mode] .app-shell,
  html[data-plan-print-mode] .workspace,
  html[data-plan-print-mode] .content,
  html[data-plan-print-mode] .users-page,
  html[data-plan-print-mode] .user-workspace-section,
  html[data-plan-print-mode] .selected-user-project {
    display: block !important;
    width: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }
  html[data-plan-print-mode] .sidebar,
  html[data-plan-print-mode] .users-page > :not(.user-workspace-section),
  html[data-plan-print-mode] .user-workspace-section > :not(.selected-user-project),
  html[data-plan-print-mode] .selected-user-project > :not(.project-plan) {
    display: none !important;
  }
  html[data-plan-print-mode] .project-plan-workspace-tools,
  html[data-plan-print-mode] .project-plan-toolbar,
  html[data-plan-print-mode] .project-plan-rail-wrap,
  html[data-plan-print-mode] .project-plan-access,
  html[data-plan-print-mode] .projection-banner {
    display: none !important;
  }
  html[data-plan-print-mode] .project-plan-head,
  html[data-plan-print-mode] .project-plan-shell,
  html[data-plan-print-mode] .project-plan-canvas {
    display: block !important;
    border: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  html[data-plan-print-mode] .project-plan-page {
    display: block !important;
    break-after: page;
    margin: 0 0 18px !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    background: #fff !important;
  }
  html[data-plan-print-mode="current"] .project-plan-page:not([data-plan-print-current="true"]) {
    display: none !important;
  }
  html[data-plan-print-mode] .project-plan-page:last-child {
    break-after: auto;
  }
}


/* Rails 07 Mia/Templates route locks keep the HOME CRM shell visible on desktop. */
html:has(.mia-route-lock),
body:has(.mia-route-lock),
html:has(.templates-route-lock),
body:has(.templates-route-lock) {
  height: 100dvh;
  overflow-y: hidden;
  overflow-x: auto;
}

:root[data-theme] .app-shell:has(.mia-route-lock),
:root[data-theme] .app-shell:has(.templates-route-lock) {
  display: grid;
  grid-template-columns: minmax(220px, 248px) minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  width: 100%;
}

.app-shell:has(.mia-route-lock) > .sidebar,
.app-shell:has(.templates-route-lock) > .sidebar {
  display: block;
}

:root[data-theme] .workspace:has(.mia-route-lock),
:root[data-theme] .workspace:has(.templates-route-lock) {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  width: 100%;
}

:root[data-theme] .content:has(.mia-route-lock),
:root[data-theme] .content:has(.templates-route-lock) {
  display: block;
  min-height: 0;
  overflow: hidden !important;
  padding: 0 !important;
  scrollbar-gutter: auto;
  width: 100%;
}

.mia-route-lock {
  height: 100%;
}

.mia-route-lock[data-right-rail-state="compact"] {
  --mia-right-rail-width: 64px;
}

.mia-route-lock[data-right-rail-state="closed"] {
  --mia-right-rail-width: 0px;
}

.mia-route-lock[data-left-rail-state="closed"] .mia-edge-handle--left {
  left: 0;
}

.mia-route-lock[data-right-rail-state="closed"] .mia-edge-handle--right {
  right: 0;
}

.mia-route-lock[data-right-rail-state="closed"] .mia-right-rail {
  width: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .rail-state-label,
.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .mia-transcript-rail h2,
.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .mia-transcript {
  display: none;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .drawer-bar {
  justify-content: center;
  padding: 0;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .drawer-title {
  display: block;
  max-width: 44px;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail .mia-rail-body {
  display: grid;
  place-items: center;
  padding: 0;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail [data-action="mia-retry-saves"] {
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
}

.mia-route-lock[data-right-rail-state="compact"] .mia-right-rail [data-action="mia-retry-saves"]::after {
  content: 'R';
  display: grid;
  place-items: center;
  text-indent: 0;
}

.templates-route-lock {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.templates-route-lock .template-workspace-shell {
  --template-catalogue-width: minmax(220px, .72fr);
  --template-documents-width: minmax(280px, .9fr);
  position: relative;
  display: grid;
  grid-template-columns: var(--template-catalogue-width) minmax(0, 2.8fr) var(--template-documents-width);
  align-items: stretch;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.templates-route-lock .template-workspace-shell > * {
  min-width: 0;
  min-height: 0;
}

.templates-route-lock .template-sidebar {
  position: relative;
  top: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 10px;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 12px;
}

.template-rail-handle {
  position: absolute;
  top: 50%;
  z-index: 40;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  transform: translateY(-50%);
  touch-action: none;
  cursor: ew-resize;
}

.template-rail-handle--catalogue {
  right: -22px;
}

.template-rail-handle--documents {
  left: -22px;
}

.template-rail-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.templates-route-lock .template-document-stage.template-preview {
  position: relative;
  top: auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}

.templates-route-lock .template-document-stage.template-preview:has(iframe[data-template-canvas-frame="readonly"]) {
  grid-template-rows: auto minmax(0, 1fr);
}
.templates-route-lock .template-document-stage.template-preview > iframe { grid-row: -2 / -1; overflow: auto; }
.template-version-control { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; white-space: nowrap; }
.template-version-control select { max-width: 68px; min-width: 58px; padding: 3px; }
.template-card-top > button, .template-document-card button { text-align: left; overflow-wrap: anywhere; }
:root[data-theme] .template-card-top > button,
:root[data-theme] .template-document-card > button {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.template-signed-upload { position: relative; }
.template-signed-upload > button { width: 100%; }
.template-signed-upload > input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.templates-route-lock .template-document-stage.template-preview > iframe,
.templates-route-lock .template-workspace-shell .template-preview iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
}

.templates-route-lock .is-catalogue-collapsed {
  --template-catalogue-width: minmax(48px, 48px);
  grid-template-columns: var(--template-catalogue-width) minmax(0, 1fr) var(--template-documents-width);
}

.templates-route-lock .is-documents-collapsed {
  --template-documents-width: minmax(48px, 48px);
  grid-template-columns: var(--template-catalogue-width) minmax(0, 1fr) var(--template-documents-width);
}

.templates-route-lock .is-catalogue-collapsed.is-documents-collapsed {
  --template-catalogue-width: minmax(48px, 48px);
  --template-documents-width: minmax(48px, 48px);
  grid-template-columns: var(--template-catalogue-width) minmax(0, 1fr) var(--template-documents-width);
}

@media (min-width: 761px) {
.is-catalogue-collapsed .template-sidebar--catalogue .template-rail-body,
.is-documents-collapsed .template-sidebar--documents .template-rail-body {
  display: none;
}

.is-catalogue-collapsed .template-sidebar--catalogue,
.is-documents-collapsed .template-sidebar--documents {
  padding-inline: 6px;
}

.is-catalogue-collapsed .template-sidebar--catalogue .template-sidebar-head,
.is-documents-collapsed .template-sidebar--documents .template-sidebar-head {
  display: grid;
  justify-items: center;
}

.is-catalogue-collapsed .template-sidebar--catalogue h2,
.is-documents-collapsed .template-sidebar--documents h2 {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 13px;
}
}

.template-mobile-only { display: none; }

.template-fullscreen[open] {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--surface-card);
  color: var(--ink);
}
.template-fullscreen-header,
.template-fullscreen-stepper:not([hidden]) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
}
.template-fullscreen-header { padding-top: max(6px, env(safe-area-inset-top)); }
.template-fullscreen-header h2 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.template-fullscreen-header p { margin: 0; }
.template-fullscreen-header a { display: flex; align-items: center; }
.template-fullscreen-stepper:not([hidden]) { padding-bottom: max(6px, env(safe-area-inset-bottom)); text-align: center; }
.template-fullscreen :is(button, a) { min-width: 44px; min-height: 44px; }
.template-fullscreen iframe { width: 100%; height: 100%; border: 0; background: white; }

@media (min-width: 761px) and (max-width: 1100px) {
  :root[data-theme] .app-shell:has(.mia-route-lock),
  :root[data-theme] .app-shell:has(.templates-route-lock) {
    grid-template-columns: minmax(190px, 220px) minmax(0, 1fr);
  }

  /* Keep both Template rails usable on tablets without squeezing or covering
     the document iframe. Each rail becomes an independently scrollable row. */
  .templates-route-lock .template-workspace-shell,
  .templates-route-lock .template-workspace-shell.is-catalogue-collapsed,
  .templates-route-lock .template-workspace-shell.is-documents-collapsed,
  .templates-route-lock .template-workspace-shell.is-catalogue-collapsed.is-documents-collapsed {
    --template-catalogue-row: minmax(150px, 180px);
    --template-documents-row: minmax(140px, 170px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--template-catalogue-row) minmax(0, 1fr) var(--template-documents-row);
  }

  .templates-route-lock .template-workspace-shell.is-catalogue-collapsed {
    --template-catalogue-row: minmax(48px, 48px);
  }

  .templates-route-lock .template-workspace-shell.is-documents-collapsed {
    --template-documents-row: minmax(48px, 48px);
  }

  .templates-route-lock .template-sidebar--catalogue { grid-row: 1; }
  .templates-route-lock .template-document-stage { grid-row: 2; }
  .templates-route-lock .template-sidebar--documents { grid-row: 3; }
}

@media (max-width: 760px) {
  :root[data-theme] .app-shell:has(.mia-route-lock),
  :root[data-theme] .app-shell:has(.templates-route-lock) {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-shell:has(.mia-route-lock) > .sidebar,
  .app-shell:has(.templates-route-lock) > .sidebar {
    display: none;
  }

  .mia-route-lock .mia-edge-handle {
    top: 50%;
  }

  .templates-route-lock {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  }
  .workspace:has(> .desktop-controls) .templates-route-lock { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .templates-route-lock .template-mobile-only:not([hidden]) { display: block; }
  .templates-route-lock .template-mobile-nav { padding-inline-end: 54px; }
  .template-mobile-segment { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .template-mobile-nav button { min-height: 44px; }
  .template-mobile-segment [aria-pressed="true"] { border-color: var(--accent); font-weight: 700; }
  .templates-route-lock .template-workspace-shell {
    display: block;
    flex: 1;
    height: auto;
  }
  .templates-route-lock .template-sidebar { inset: auto; width: auto; max-width: none; transform: none; }
  .templates-route-lock .template-rail-handle,
  .templates-route-lock .template-desktop-only,
  .templates-route-lock [data-template-search-miss],
  .templates-route-lock:not([data-template-mobile-detail]) :is(.template-document-stage, .template-upgrade, [data-action="template-mobile-back"]),
  .templates-route-lock[data-template-mobile-detail] :is(.template-sidebar, .template-mobile-segment),
  .templates-route-lock[data-template-mobile-list="documents"] .template-sidebar--catalogue,
  .templates-route-lock[data-template-mobile-list="catalogue"] .template-sidebar--documents { display: none; }
  .templates-route-lock .template-upgrade { max-height: 25dvh; overflow: auto; }
  .templates-route-lock .template-document-stage.template-preview {
    display: flex;
    flex-direction: column;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .templates-route-lock .template-document-stage.template-preview[hidden],
  .templates-route-lock:not([data-template-mobile-detail]) .template-document-stage.template-preview { display: none; }
  .templates-route-lock .template-document-stage.template-preview > iframe { flex: 1 0 155px; }
  .templates-route-lock .template-mobile-document-controls:not([hidden]) {
    display: grid;
    order: -1;
    justify-items: start;
    gap: 8px;
  }
  .template-mobile-document-controls h2 { margin: 0; overflow-wrap: anywhere; }
  .template-mobile-document-options { display: flex; flex-wrap: wrap; gap: 8px; }
  .template-mobile-document-options label { display: grid; gap: 4px; }
  .template-mobile-approval:not([hidden]) { display: grid; gap: 4px; width: 100%; }
  .template-mobile-approval textarea { width: 100%; }
}

/* GO occupies its own bounded row so the composer cannot cover approval. */
.mia-route-lock .mia-canvas-stage:has(.mia-canvas-handoffs) { grid-template-rows: 44px minmax(0, 1fr) minmax(72px, 132px) 24px auto; }
.mia-route-lock .mia-canvas-handoffs { min-height: 0; overflow: auto; margin: 0; padding: 8px; scroll-padding: 8px; }
.mia-canvas-handoffs .panel-head { margin-bottom: 4px; }
.mia-canvas-handoffs h3 { font-size: 14px; }
.ticket-review-controls { display: grid; gap: 8px; }
.ticket-review-controls label { display: grid; gap: 4px; min-width: 0; }
.ticket-review-controls textarea { width: 100%; min-width: 0; box-sizing: border-box; }
.ticket-lifecycle p { overflow-wrap: anywhere; }

.ticket-feedback-content { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }

/* Native Users → Projects → Project Space; limited to this route. */
:root[data-theme] .content:has(> .users-space) {
  box-sizing: border-box; width: 100%; max-width: none; min-width: 0; margin-inline: 0;
}
:root[data-theme] .users-space {
  --space-paper: var(--surface-card);
  --space-rail: var(--color-sidebar);
  --space-ink: var(--ink);
  --space-subtle: var(--muted);
  --space-stroke: var(--line);
  --space-active: var(--color-selected);
  color: var(--space-ink);
  width: 100%; min-width: 0;
}
:root[data-theme] .users-space .section-hero { margin-bottom: 16px; }
:root[data-theme] .users-space-layout {
  display: grid; grid-template-columns: clamp(210px, 23vw, 290px) minmax(0, 1fr);
  gap: 16px; align-items: start; min-width: 0;
}
:root[data-theme] .users-space-rail, :root[data-theme] .users-space-main {
  box-sizing: border-box; min-width: 0; border: 1px solid var(--space-stroke);
  border-radius: 14px; padding: clamp(14px, 2vw, 24px);
}
:root[data-theme] .users-space-rail { background: var(--space-rail); display: grid; gap: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
:root[data-theme] .users-space-main { background: var(--space-paper); overflow-wrap: anywhere; }

:root[data-theme] .users-space-list, :root[data-theme] .users-space-tree { display: grid; gap: 5px; min-width: 0; }
:root[data-theme] .users-space-rail button, :root[data-theme] .users-space-main button {
  cursor: pointer; font: inherit; color: var(--space-ink); background: var(--space-paper);
  border: 1px solid var(--space-stroke); border-radius: 9px; padding: 9px 11px;
}
:root[data-theme] .users-space-rail button { width: 100%; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
:root[data-theme] .users-space button:hover, :root[data-theme] .users-space button[aria-current] { background: var(--space-active); }
:root[data-theme] .users-space button:disabled { cursor: not-allowed; opacity: .55; }
:root[data-theme] .users-space-rail .users-space-leaf { padding-left: 24px; font-size: .92em; border-left: 3px solid var(--space-stroke); }
:root[data-theme] .users-space-crumbs { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--space-subtle); border-bottom: 1px solid var(--space-stroke); padding-bottom: 12px; margin-bottom: 18px; font-size: .87em; }
:root[data-theme] .users-space-crumbs > *:not(:last-child)::after { content: ' /'; }
:root[data-theme] .users-space-crumbs strong { color: var(--space-ink); }
:root[data-theme] .users-space .space-panel, :root[data-theme] .users-space .space-new-project,
:root[data-theme] .users-space .space-plan-settings { display: grid; gap: 12px; min-width: 0; }
:root[data-theme] .users-space .space-panel h2, :root[data-theme] .users-space .space-panel h3 { margin: 0; }
:root[data-theme] .users-space .space-panel p { margin-block: 0; }
:root[data-theme] .users-space .space-overview-links { display: flex; flex-wrap: wrap; gap: 7px; }
:root[data-theme] .users-space .space-records, :root[data-theme] .users-space .space-history { padding-left: 20px; margin: 0; }
:root[data-theme] .users-space .space-record { padding: 9px 0; border-bottom: 1px solid var(--space-stroke); }
:root[data-theme] .users-space .space-record span { margin-left: 10px; }
:root[data-theme] .users-space .field { display: grid; gap: 5px; min-width: 0; }
:root[data-theme] .users-space input:not([type="checkbox"]), :root[data-theme] .users-space textarea,
:root[data-theme] .users-space select { box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid var(--space-stroke); border-radius: 8px; padding: 9px 10px; background: var(--field-bg); color: var(--space-ink); font: inherit; }
:root[data-theme] .users-space textarea { resize: vertical; line-height: 1.5; }
:root[data-theme] .users-space .space-settings-table-wrap { width: 100%; overflow-x: auto; }
:root[data-theme] .users-space .space-settings-table { width: 100%; min-width: 510px; border-collapse: collapse; }
:root[data-theme] .users-space .space-settings-table th, :root[data-theme] .users-space .space-settings-table td { border-bottom: 1px solid var(--space-stroke); padding: 9px; text-align: left; }
:root[data-theme] .users-space .space-settings-table tr:nth-child(even) { background: var(--color-hover); }
:root[data-theme] .users-space [data-plan-node] { scroll-margin-top: 20px; }
:root[data-theme="dark"] .users-space { --space-rail: #10131a; --space-paper: #14171f; --space-active: rgba(215,211,202,.19); }
:root[data-theme="dark"] .users-space .space-panel, :root[data-theme="dark"] .users-space .plan-node { color: #f8f8fb; }
:root[data-theme="light"] .users-space { --space-rail: #ebe1d2; --space-paper: #fffdf8; --space-active: rgba(92,64,39,.14); }
@media (max-width: 700px) {
  :root[data-theme] .users-space-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  :root[data-theme] .users-space-rail { position: static; max-height: none; overflow: visible; padding: 12px; }
  :root[data-theme] .users-space-list, :root[data-theme] .users-space-tree { max-height: 220px; overflow-y: auto; }
  :root[data-theme] .users-space-main { padding: 14px; }
}
@media (max-width: 390px) {
  :root[data-theme] .users-space-rail, :root[data-theme] .users-space-main { padding: 10px; border-radius: 10px; }
  :root[data-theme] .users-space-crumbs { font-size: .78em; }
  :root[data-theme] .users-space .space-overview-links button { width: 100%; }
}

/* Canonical Pagen Space only; the embedded projection owns its internal navigation. */


/* structured Documents: repeatable rows, edit, archive */
.sd-editor { display: grid; gap: .75rem; padding: .75rem 0; }
.sd-editor h3 { margin: 0; font-size: 1rem; }
.sd-repeat { border: 1px solid var(--line, rgba(127,127,127,.35)); border-radius: 10px; padding: .6rem .75rem; display: grid; gap: .6rem; min-width: 0; }
.sd-repeat .sd-repeat { margin-left: .5rem; }
.sd-repeat.invalid, .sd-field.invalid input, .sd-field.invalid textarea, .sd-field.invalid select { outline: 2px solid #ff857a; }
.sd-row { display: grid; gap: .5rem; padding: .5rem; border-radius: 8px; background: rgba(127,127,127,.07); }
.sd-row-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.sd-row-bar > b, .sd-row-bar > h3 { margin-right: auto; }
.sd-field { display: grid; gap: .2rem; min-width: 0; }
.sd-field > span { font-size: .8rem; opacity: .8; }
.sd-field input, .sd-field textarea, .sd-field select { width: 100%; box-sizing: border-box; }
.sd-actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
@media (min-width: 900px) { .sd-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } .sd-row > .sd-row-bar, .sd-row > .sd-repeat { grid-column: 1 / -1; } }

/* workstation-v5: phase semantics, same surfaces and responsive grid. */
.workstation-page { min-width: 0; }
.workstation-page .workstation-toolbar { display: flex; flex-wrap: wrap; gap: 12px; }
.workstation-page .workstation-toolbar label { min-width: 0; max-width: 100%; }
.workstation-page .workstation-toolbar input, .workstation-page .workstation-toolbar select { max-width: 100%; }
.workstation-page .ticket-project { margin: 0; overflow-wrap: anywhere; }
.workstation-page .ticket-card-phase { flex-wrap: wrap; }
.workstation-page .ticket-card-phase strong { white-space: normal; overflow-wrap: anywhere; }
.workstation-page .ticket-phase-goal { margin: 0; font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* Ticket29 light cards: menu stays separate from the keyboard-open target. */
.ticket-card-compact { position: relative; padding-right: 48px; }
.ticket-card-compact > h3 { margin: 0; overflow-wrap: anywhere; }
.ticket-card-menu { position: absolute; top: 8px; right: 8px; z-index: 1; }
.ticket-menu-toggle { cursor: pointer; list-style: none; padding: 4px 10px; min-height: 32px; }
.ticket-menu-toggle::-webkit-details-marker { display: none; }
.ticket-card-menu[open] { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.ticket-card-menu button { display: block; margin: 4px; }
.ticket-details > summary { cursor: pointer; font-weight: 600; padding: 12px 0; }
.ticket-details[open] { display: block; }
.ticket-technical-details { display: grid; gap: 14px; }
.ticket-archive-controls { border-top: 1px solid var(--line); padding-top: 12px; }
/* ceo-tickets-02: compact Ticket cards, details drawer, Watchdog worktree */
.ticket-card-compact { display: grid; gap: 8px; cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.ticket-card-compact:hover { border-color: var(--accent); }
.ticket-card-compact:focus-visible { outline: 2px solid var(--focus-ring, var(--accent)); outline-offset: 2px; }
.ticket-card-compact.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ticket-card-context { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ticket-card-phase { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.ticket-card-phase strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-phase-leds { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.ticket-phase-leds.empty { color: var(--muted); font-size: .78rem; }
.phase-led { width: 11px; height: 11px; border-radius: 50%; background: transparent; border: 1.5px solid var(--muted); flex: none; display: inline-block; }
.phase-led.state-active, .phase-led.state-in_progress { background: var(--status-info, #9bc7ef); border-color: var(--status-info, #9bc7ef); box-shadow: 0 0 6px var(--status-info, #9bc7ef); animation: phase-led-pulse 1.8s ease-in-out infinite; }
.phase-led.state-review { background: var(--warn); border-color: var(--warn); }
.phase-led.state-blocked { background: var(--status-bad, #ff9f96); border-color: var(--status-bad, #ff9f96); }
.phase-led.state-done { background: var(--good); border-color: var(--good); }
.phase-led.state-skipped { background: transparent; border-style: dashed; opacity: .6; }
@keyframes phase-led-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .phase-led { animation: none !important; } }
.ticket-card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .76rem; color: var(--muted); }
.ticket-agents { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ticket-agents.idle { opacity: .75; }
.agent-chip { border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--ink); background: var(--surface-soft, var(--panel)); }
.workstation-page.drawer-open { padding-right: min(440px, 42vw); }
.ticket-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 40; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow-elevated, 0 18px 45px rgba(0,0,0,.32)); }
.ticket-drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 16px; border-bottom: 1px solid var(--line); }
.ticket-drawer-head h2 { margin: 2px 0 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.ticket-drawer-body { overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }
.ticket-drawer-section h3 { margin: 0 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ticket-drawer-section p { margin: 0 0 4px; }
.ticket-drawer-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; }
.ticket-phase-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.ticket-phase-list li { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: start; }
.ticket-phase-list li .phase-led { margin-top: 4px; }
.ticket-phase-list small { display: block; color: var(--muted); }
.ticket-phase-list p { margin: 2px 0 0; font-size: .85rem; }
@media (max-width: 900px) { .workstation-page.drawer-open { padding-right: 0; } .ticket-drawer { width: 100vw; } }
.watchdog-worktree-slot { margin-top: 18px; }
.watchdog-worktree { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 14px 16px; display: grid; gap: 10px; }
.watchdog-worktree-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.watchdog-worktree-head h2 { margin: 2px 0 0; font-size: 1rem; }
.worktree-graph { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.worktree-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; min-height: 28px; font-size: .82rem; }
.worktree-row:hover { background: var(--surface-soft, rgba(127,127,127,.06)); }
.worktree-rail { display: block; flex: none; }
.worktree-lane { stroke-width: 2; stroke: currentColor; }
.worktree-dot { stroke: var(--panel); stroke-width: 2; fill: currentColor; }
.worktree-dot.state-failed { fill: var(--status-bad, #ff9f96); }
.worktree-dot.state-working { fill: var(--panel); stroke: currentColor; }
.worktree-msg { display: flex; gap: 8px; align-items: baseline; min-width: 0; overflow: hidden; white-space: nowrap; }
.worktree-msg b { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.worktree-msg small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.worktree-ref { border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; font-size: .72rem; flex: none; }
.worktree-when { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.lane-0 { color: #7fb2e5; } .lane-1 { color: #a9cfb5; } .lane-2 { color: #e3c78d; } .lane-3 { color: #d59be0; }
.lane-4 { color: #ff9f96; } .lane-5 { color: #8fd6d0; } .lane-6 { color: #c9b8ff; } .lane-7 { color: #d7d3ca; }

/* ceo-tickets-03: Hermes full-screen chat */
body.hermes-active .content { padding: 0; display: flex; flex-direction: column; }
.hermes-workspace { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
.hermes-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.hermes-bar-title { display: grid; flex: 1 1 260px; min-width: 0; }
.hermes-bar-title small { color: var(--muted); font-size: .78rem; }
.hermes-profile { display: inline-flex; gap: 8px; align-items: center; font-size: .85rem; }
.hermes-frame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #0b0d12; }
.server-screen-workspace .hermes-bar .button { flex: 0 0 auto; }
@media (max-width: 700px) {
  .server-screen-workspace .hermes-bar { padding: 6px 8px; gap: 6px; }
  .server-screen-workspace .hermes-bar-title { flex: 1 1 100%; }
  .server-screen-workspace .hermes-bar-title small { display: none; }
  .server-screen-workspace .hermes-bar .button { padding: 4px 10px; font-size: .8rem; min-height: 32px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .server-screen-workspace .hermes-bar-title { display: none; }
  .server-screen-workspace .hermes-bar { padding: 4px 8px; }
}

/* Project Space · latest Pagen layout (Milestone document, one Plan group). */
:root[data-theme] .users-space .pagen-space-nav { gap: 4px; }
:root[data-theme] .users-space .pagen-space-kicker,
:root[data-theme] .users-space .pagen-space-group-label,
:root[data-theme] .users-space .pagen-leaf-head .eyebrow { margin: 0 0 6px; color: var(--space-subtle); font: 12px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
:root[data-theme] .users-space .pagen-space-group { display: grid; gap: 4px; margin: 8px 0; padding-top: 8px; border-top: 1px solid var(--space-stroke); }
:root[data-theme] .users-space .pagen-space-group .users-space-leaf { padding-left: 20px; }
:root[data-theme] .users-space .pagen-leaf { max-width: none; width: 100%; margin: 0; display: grid; gap: 14px; min-width: 0; }
:root[data-theme] .users-space .pagen-leaf-head h2 { margin: 0; font-size: clamp(22px, 3vw, 34px); line-height: 1.08; letter-spacing: -.035em; }
:root[data-theme] .users-space .pagen-leaf-sub, :root[data-theme] .users-space .pagen-leaf-meta { margin: 0; color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-milestone-frame { display: block; width: 100%; min-height: 70vh; border: 1px solid var(--space-stroke); border-radius: 14px; background: #fffdf8; }
:root[data-theme] .users-space .pagen-ticket-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
:root[data-theme] .users-space .pagen-ticket { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; width: 100%; text-align: left; border: 1px solid var(--space-stroke); border-radius: 12px; padding: 12px 14px; }
:root[data-theme] .users-space .pagen-ticket small { grid-column: 2 / -1; color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-ticket-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--space-subtle); }
/* Project Space · Architecture (database explorer + project files), Pagen leaf styling */
:root[data-theme] .users-space .pagen-arch { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
:root[data-theme] .users-space .pagen-arch-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--space-stroke); border-radius: 12px; width: max-content; max-width: 100%; background: var(--space-rail); }
:root[data-theme] .users-space .pagen-arch-tab { border: 0; border-radius: 9px; padding: 6px 14px; background: transparent; color: var(--space-subtle); font-weight: 600; font-size: 13px; line-height: 1.2; font-family: inherit; cursor: pointer; }
:root[data-theme] .users-space .pagen-arch-tab.selected { background: var(--space-paper); color: inherit; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
:root[data-theme] .users-space .pagen-arch-studio { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); min-height: 60vh; border: 1px solid var(--space-stroke); border-radius: 14px; overflow: hidden; background: var(--space-paper); }
:root[data-theme] .users-space .pagen-arch-sidebar { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 8px; padding: 10px; border-right: 1px solid var(--space-stroke); background: var(--space-rail); max-height: 75vh; min-width: 0; }
:root[data-theme] .users-space .pagen-arch-schema, :root[data-theme] .users-space .pagen-arch-search { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--space-stroke); border-radius: 8px; background: var(--space-paper); color: inherit; font-size: 13px; line-height: 1.3; font-family: inherit; }
:root[data-theme] .users-space .pagen-arch-tables { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; align-content: start; gap: 1px; }
:root[data-theme] .users-space .pagen-arch-table-item { display: flex; gap: 8px; align-items: center; width: 100%; padding: 5px 8px; border: 0; border-radius: 7px; background: transparent; color: inherit; text-align: left; font: 13px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; }
:root[data-theme] .users-space .pagen-arch-table-item:hover { background: var(--space-paper); }
:root[data-theme] .users-space .pagen-arch-table-item.selected { background: var(--space-active); font-weight: 600; }
:root[data-theme] .users-space .pagen-arch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
:root[data-theme] .users-space .pagen-arch-ico { color: var(--space-subtle); flex: none; }
:root[data-theme] .users-space .pagen-arch-detail { display: grid; align-content: start; gap: 12px; padding: 14px 16px; min-width: 0; overflow: auto; max-height: 75vh; }
:root[data-theme] .users-space .pagen-arch-detail-head h3 { margin: 0 0 6px; font: 600 18px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
:root[data-theme] .users-space .pagen-arch-muted, :root[data-theme] .users-space .pagen-arch-null { color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-arch-null { font: italic 12px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:root[data-theme] .users-space .pagen-arch-badges { display: flex; flex-wrap: wrap; gap: 6px; }
:root[data-theme] .users-space .pagen-arch-badge { display: inline-flex; align-items: center; padding: 2px 8px; border: 1px solid var(--space-stroke); border-radius: 999px; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--space-subtle); white-space: nowrap; }
:root[data-theme] .users-space .pagen-arch-badge.key { color: var(--status-warn, #a16207); border-color: currentColor; }
:root[data-theme] .users-space .pagen-arch-badge.good { color: var(--status-good, #15803d); border-color: currentColor; }
:root[data-theme] .users-space .pagen-arch-badge.warn { color: var(--status-bad, #b91c1c); border-color: currentColor; }
:root[data-theme] .users-space .pagen-arch-columns { width: 100%; border-collapse: collapse; font-size: 13px; }
:root[data-theme] .users-space .pagen-arch-columns th, :root[data-theme] .users-space .pagen-arch-columns td { padding: 6px 10px; border-bottom: 1px solid var(--space-stroke); text-align: left; vertical-align: top; }
:root[data-theme] .users-space .pagen-arch-columns thead th { color: var(--space-subtle); font: 600 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; position: sticky; top: 0; background: var(--space-paper); }
:root[data-theme] .users-space .pagen-arch-columns code { overflow-wrap: anywhere; }
:root[data-theme] .users-space .pagen-arch-keys { display: flex; flex-wrap: wrap; gap: 4px; }
:root[data-theme] .users-space .pagen-arch-ref { border: 0; padding: 0; background: none; color: var(--color-link, var(--accent, inherit)); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
:root[data-theme] .users-space span.pagen-arch-ref { cursor: default; text-decoration: none; color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-arch-relations ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
:root[data-theme] .users-space .pagen-arch-relations li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
:root[data-theme] .users-space .pagen-arch-tree-wrap { border: 1px solid var(--space-stroke); border-radius: 14px; padding: 10px 12px; background: var(--space-paper); max-height: 75vh; overflow: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:root[data-theme] .users-space .pagen-arch-root { margin: 0 0 6px; color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-arch-tree { list-style: none; margin: 0; padding: 0; }
:root[data-theme] .users-space .pagen-arch-tree .pagen-arch-tree { padding-left: 16px; border-left: 1px dashed var(--space-stroke); margin-left: 6px; }
:root[data-theme] .users-space .pagen-arch-dir > summary { list-style: none; display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 1px 4px; border-radius: 6px; }
:root[data-theme] .users-space .pagen-arch-dir > summary::-webkit-details-marker { display: none; }
:root[data-theme] .users-space .pagen-arch-dir > summary:hover { background: var(--space-rail); }
:root[data-theme] .users-space .pagen-arch-dir[open] > summary .pagen-arch-ico { transform: rotate(90deg); }
:root[data-theme] .users-space .pagen-arch-dir > summary .pagen-arch-name { font-weight: 600; }
:root[data-theme] .users-space .pagen-arch-file { display: flex; gap: 6px; align-items: center; padding: 1px 4px 1px 18px; }
:root[data-theme] .users-space .pagen-arch-file.excluded { color: var(--space-subtle); }
:root[data-theme] .users-space .pagen-arch-tree small, :root[data-theme] .users-space .pagen-arch-dir small { margin-left: auto; color: var(--space-subtle); font-size: 11px; padding-left: 12px; }
@media (max-width: 760px) {
  :root[data-theme] .users-space .pagen-arch-studio { grid-template-columns: minmax(0, 1fr); }
  :root[data-theme] .users-space .pagen-arch-sidebar { border-right: 0; border-bottom: 1px solid var(--space-stroke); max-height: 40vh; }
}

/* Project Space · Overview (read-only links + latest updates); full-width Space */
:root[data-theme] .users-space .space-overview-envs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; }
:root[data-theme] .users-space .space-overview-env { display: grid; gap: 6px; min-width: 0; padding: 14px 16px; border: 1px solid var(--space-stroke); border-radius: 12px; background: var(--space-paper); }
:root[data-theme] .users-space .space-overview-env header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
:root[data-theme] .users-space .space-overview-env a { overflow-wrap: anywhere; font-weight: 600; }
:root[data-theme] .users-space .space-overview-env.not-configured { border-style: dashed; }
:root[data-theme] .users-space .space-overview-badge { padding: 2px 8px; border: 1px solid var(--space-stroke); border-radius: 999px; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--space-subtle); }
:root[data-theme] .users-space .space-overview-muted { margin: 0; color: var(--space-subtle); overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-overview-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
:root[data-theme] .users-space .space-overview-facts dt { color: var(--space-subtle); }
:root[data-theme] .users-space .space-overview-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-overview h3 { margin: 6px 0 0; }
:root[data-theme] .users-space .space-overview-updates { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
:root[data-theme] .users-space .space-overview-updates > li { display: grid; grid-template-columns: minmax(130px, max-content) 90px minmax(0, 1fr); gap: 4px 12px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--space-stroke); border-radius: 10px; }
:root[data-theme] .users-space .space-overview-updates time { color: var(--space-subtle); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:root[data-theme] .users-space .space-overview-kind { font-size: 12px; font-weight: 600; color: var(--space-subtle); text-transform: uppercase; letter-spacing: .06em; }
:root[data-theme] .users-space .space-overview-title { display: grid; min-width: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space .users-space-main { min-width: 0; max-width: none; }
@media (max-width: 700px) {
  :root[data-theme] .users-space .space-overview-updates > li { grid-template-columns: minmax(0, 1fr); }
}

/* Ticket31 A1: owner reader only; no global shell, Workstation or Document styles. */
:root[data-theme] .users-space .space-project-card { display: grid; gap: 16px; padding: 20px; border: 1px solid var(--space-stroke); border-radius: 14px; background: var(--space-paper); min-width: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-project-card > header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; }
:root[data-theme] .users-space .space-project-summary { font-size: 17px; line-height: 1.6; margin: 0; max-width: 80ch; }
:root[data-theme] .users-space .space-project-focus-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
:root[data-theme] .users-space .space-project-focus-grid h4 { margin: 0 0 8px; }
:root[data-theme] .users-space .space-project-focus-grid ul { padding: 0; margin: 0; list-style: none; display: grid; gap: 10px; }
:root[data-theme] .users-space .space-project-focus-grid li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
:root[data-theme] .users-space .space-delivered-list { list-style: none; padding: 0; display: grid; gap: 12px; }
:root[data-theme] .users-space .space-delivered-list > li { padding: 16px; border: 1px solid var(--space-stroke); border-radius: 10px; min-width: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-delivered-list h4 { margin: 0; }
:root[data-theme] .users-space .space-overview summary { padding: 12px 0; cursor: pointer; min-height: 44px; }
:root[data-theme] .users-space .space-overview button { min-height: 44px; }
:root[data-theme] .users-space .space-overview :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
:root[data-theme] .users-space .space-overview-title details { min-width: 0; }
:root[data-theme] .users-space .space-overview-title details li { display: list-item; margin: 6px 0; }
:root[data-theme] .users-space .pagen-ticket-list .pagen-ticket { grid-template-columns: minmax(0, 1fr) auto; overflow-wrap: anywhere; }
:root[data-theme] .users-space .pagen-ticket-list .pagen-ticket small { grid-column: 1 / -1; }
@media (max-width: 700px) {
  :root[data-theme] .users-space .space-project-card { padding: 16px; }
  :root[data-theme] .users-space .space-project-focus-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Ticket Chat (plan §16.2 / §16.18): attributed thread, Project Plan update and coloured impact. */
.ticket-drawer { width: min(560px, 100vw); }
.ticket-chat { display: grid; gap: 10px; }
.ticket-chat-view { display: grid; gap: 10px; }
.ticket-next-action { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft, var(--panel2)); }
.ticket-next-action.kind-decide { border-color: var(--status-warn, var(--warn)); }
.ticket-next-action.kind-blocked { border-color: var(--status-bad, #c0392b); }
.ticket-plan-update { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.ticket-delivery { display: grid; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.ticket-delivery h3, .ticket-delivery p { margin: 0; }
.ticket-delivery-files { margin: 0; padding-left: 18px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.ticket-delivery.delivery-conflict, .ticket-delivery.delivery-refused, .ticket-delivery.delivery-failed,
.ticket-delivery.delivery-recovery_required, .ticket-delivery.delivery-rolling_back { border-color: var(--bad, #c0392b); }
.ticket-delivery.delivery-applied { border-color: var(--good, #2e7d32); }
.ticket-plan-update header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticket-plan-update h4, .ticket-plan-update h5 { margin: 0; }
.ticket-plan-update h5 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 4px; }
.ticket-plan-update p, .ticket-plan-update ul { margin: 0; }
.ticket-impact-counts { font-variant-numeric: tabular-nums; color: var(--muted); }
.ticket-impact-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.ticket-impact-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 3px 6px; border-bottom: 1px solid var(--line); }
.ticket-impact-table td { padding: 3px 6px; vertical-align: top; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); }
.ticket-impact-table .impact-sign { width: 2em; text-align: center; font-weight: 700; }
.ticket-impact-table th:nth-child(2) { width: 52%; }
.ticket-impact-table tr.impact-positive { background: color-mix(in srgb, var(--status-good, #2f6f44) 16%, transparent); }
.ticket-impact-table tr.impact-positive .impact-sign { color: var(--status-good, #2f6f44); }
.ticket-impact-table tr.impact-negative { background: color-mix(in srgb, var(--status-bad, #c0392b) 16%, transparent); }
.ticket-impact-table tr.impact-negative .impact-sign { color: var(--status-bad, #c0392b); }
.ticket-impact-table tr.impact-negative code { text-decoration: line-through; }
.ticket-impact-table tr.impact-changed { background: color-mix(in srgb, var(--status-warn, #8a5b13) 10%, transparent); }
.ticket-impact-table tr.impact-changed .impact-sign { color: var(--status-warn, #8a5b13); }
.ticket-chat-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; }
.ticket-chat-msg { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.ticket-chat-msg.from-owner { border-color: var(--accent); }
.ticket-chat-msg.kind-correction { border-left: 3px solid var(--status-warn, var(--warn)); }
.ticket-chat-msg header { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: .8rem; }
.ticket-chat-msg header time, .ticket-chat-event time { margin-left: auto; color: var(--muted); font-size: .75rem; }
.ticket-chat-msg p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ticket-chat-ceo { color: var(--muted); }
.ticket-chat-ceo.failed { color: var(--status-bad, #c0392b); }
.ticket-chat-event { display: flex; gap: 8px; font-size: .78rem; color: var(--muted); padding: 0 9px; }
.ticket-chat-composer textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.ticket-chat-decisions { display: grid; gap: 6px; }
.ticket-chat-decisions .notice.warn, .ticket-plan-update .notice.warn { color: var(--status-warn, var(--warn)); }
.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; }

.templates-route-lock .template-document-stage.template-preview:has(iframe[data-template-canvas-frame="inline"]) {
  grid-template-rows: auto minmax(0, 1fr);
}
.template-document-stage .sd-actions .error { color: var(--danger, #b91c1c); font-size: 12px; max-width: 320px; }

/* Mailbox (plan §16.11 amendment 2): full-screen canvas + overlay picker */
body.mailbox-active .content { padding: 0; display: flex; flex-direction: column; min-height: 0; }
.mailbox-workspace { display: flex; flex-direction: column; flex: 1; min-height: calc(100vh - 64px); }
.mailbox-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.mailbox-bar-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-picker-toggle { display: inline-flex; align-items: center; gap: 6px; }
.mailbox-workspace > .notice, .mailbox-workspace > .error { margin: 8px 16px 0; }
.mailbox-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.mailbox-canvas { flex: 1; overflow: auto; padding: 24px clamp(16px, 4vw, 56px); }
.mailbox-overlay { position: absolute; inset: 0; z-index: 20; display: flex; }
.mailbox-scrim { position: absolute; inset: 0; border: 0; border-radius: 0; background: rgba(0, 0, 0, .35); cursor: default; }
.mailbox-picker { position: relative; width: min(420px, 92vw); height: 100%; display: flex; flex-direction: column; background: var(--surface-card); border-right: 1px solid var(--line); box-shadow: 8px 0 24px rgba(0, 0, 0, .25); }
.mailbox-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.mailbox-tabs button { padding: 4px 8px; font-size: .85rem; display: inline-flex; gap: 4px; align-items: center; }
.mailbox-tabs button.active { background: var(--accent); color: var(--accent-ink); }
.mailbox-count { opacity: .75; font-variant-numeric: tabular-nums; }
.mailbox-list { flex: 1; overflow: auto; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.mailbox-row { display: flex; flex-direction: column; align-items: stretch; gap: 3px; text-align: left; padding: 8px 10px; width: 100%; background: transparent; border: 1px solid transparent; }
.mailbox-row:hover, .mailbox-row.selected { background: var(--surface-raised); border-color: var(--line); }
.mailbox-row.archived { opacity: .6; }
.mailbox-row-head { display: flex; align-items: center; gap: 6px; }
.mailbox-row-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mailbox-row.unread .mailbox-row-head b { font-weight: 700; }
.mailbox-row-head small, .mailbox-row-sub { color: var(--muted); font-size: .8rem; }
.mailbox-row-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-row-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.mailbox-dot { width: 8px; height: 8px; border-radius: 50%; background: #5b8def; display: inline-block; flex: none; }
.mailbox-chip { font-size: .72rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.mailbox-chip.warn { border-color: #c98a1b; color: #c98a1b; }
.mailbox-chip.info { border-color: #5b8def; color: #5b8def; }
.mailbox-chip.ok { border-color: #3c9a62; color: #3c9a62; }
.mailbox-chip.bad { border-color: #d0533f; color: #d0533f; }
.mailbox-archived-toggle { padding: 8px 12px; border-top: 1px solid var(--line); font-size: .85rem; }
.mailbox-doc { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.mailbox-doc h2 { margin: 4px 0 8px; }
.mailbox-doc section { border-top: 1px solid var(--line); padding-top: 12px; }
.mailbox-text, .mailbox-task-form textarea, .mailbox-task-form input { width: 100%; box-sizing: border-box; }
.mailbox-task-form label { display: flex; flex-direction: column; gap: 4px; }
.mailbox-thread ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.mailbox-thread li { padding: 8px 10px; border-radius: 8px; background: var(--surface-soft); }
.mailbox-thread li.mailbox-thread-event { background: transparent; padding: 2px 10px; font-size: .85rem; color: var(--muted); }
.mailbox-thread li p { margin: 2px 0 0; white-space: pre-wrap; }
.mailbox-thread small { color: var(--muted); }
.mailbox-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.mailbox-table-wrap { overflow-x: auto; }
.mailbox-table-wrap table { border-collapse: collapse; }
.mailbox-table-wrap th, .mailbox-table-wrap td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.mailbox-report-section.blocked h3 { color: #d0533f; }
.mailbox-report-section.needs_review h3 { color: #c98a1b; }
.mailbox-marks { max-width: 900px; margin: 24px auto 0; }
.mailbox-empty { max-width: 560px; margin: 12vh auto; text-align: center; }
@media (max-width: 720px) { .mailbox-bar { flex-wrap: wrap; } .mailbox-canvas { padding: 14px; } }

/* Project Space: subsection cards, with the selected record beneath. */
:root[data-theme] .users-space .space-card { display: grid; gap: 6px; align-content: start; width: 100%; min-width: 0; text-align: left; border: 1px solid var(--space-stroke); background: var(--space-paper); color: var(--space-ink); border-radius: 16px; padding: 14px 16px; font: inherit; cursor: pointer; }
:root[data-theme] .users-space .space-card:hover { border-color: var(--accent); }
:root[data-theme] .users-space .space-card.selected { background: var(--space-active); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
:root[data-theme] .users-space .space-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root[data-theme] .users-space .space-card-index { color: #49a99c; font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; }
:root[data-theme] .users-space .space-card strong { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-card small { color: var(--space-subtle); overflow-wrap: anywhere; }
:root[data-theme] .users-space .space-cards { display: grid; gap: 14px; min-width: 0; }
:root[data-theme] .users-space .space-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; min-width: 0; }
:root[data-theme] .users-space .space-card-detail { border: 1px solid var(--space-stroke); background: var(--space-paper); border-radius: 18px; padding: 18px 20px; min-width: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space fieldset.space-plan-settings { border: 0; margin: 0; padding: 0; }
:root[data-theme] .users-space .space-mockup { display: grid; gap: 18px; min-width: 0; }
:root[data-theme] .users-space .space-subhead h3 { margin: 0 0 4px; }
:root[data-theme] .users-space .space-prototype { display: grid; gap: 10px; min-width: 0; }
:root[data-theme] .users-space .space-prototype-frame { display: block; width: 100%; height: min(860px, calc(100vh - 160px)); min-height: 560px; border: 1px solid var(--space-stroke); border-radius: 18px; background: var(--space-paper); }
:root[data-theme] .users-space .space-mockup-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
:root[data-theme] .users-space .space-mockup-card { cursor: default; }
:root[data-theme] .users-space .space-mockup-card img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--space-stroke); }
:root[data-theme] .users-space .space-mockup-placeholder { display: grid; place-items: center; min-height: 96px; border: 1px dashed var(--space-stroke); border-radius: 10px; color: var(--space-subtle); font-size: 13px; }
:root[data-theme] .users-space .space-mockup-ticket { justify-self: start; border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; text-align: left; }
:root[data-theme] .users-space .space-plan-record > summary { cursor: pointer; color: var(--space-subtle); }
/* Imported workstation content inside the Project Space (cards, detail, records). */
:root[data-theme] .users-space .ws-structured { display: grid; gap: 14px; min-width: 0; }
:root[data-theme] .users-space .ws-lead p { margin: 0 0 4px; }
:root[data-theme] .users-space .ws-kicker { color: #49a99c; font: 700 11px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase; margin: 0; }
:root[data-theme] .users-space .ws-detail { display: grid; gap: 10px; }
:root[data-theme] .users-space .ws-detail-title { margin: 0; font-size: 16px; }
:root[data-theme] .users-space .ws-note { color: var(--space-subtle); font-size: 13px; }
:root[data-theme] .users-space .ws-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
:root[data-theme] .users-space .ws-table-wrap { overflow-x: auto; max-width: 100%; }
:root[data-theme] .users-space .ws-table { width: 100%; border-collapse: collapse; font-size: 13px; }
:root[data-theme] .users-space .ws-table caption { text-align: left; color: var(--space-subtle); padding: 0 0 6px; }
:root[data-theme] .users-space .ws-table th, :root[data-theme] .users-space .ws-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--space-stroke); min-width: 160px; word-break: normal; overflow-wrap: normal; hyphens: none; }
:root[data-theme] .users-space .ws-fields { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 4px 14px; margin: 0; }
:root[data-theme] .users-space .ws-fields dt { color: var(--space-subtle); font-size: 13px; }
:root[data-theme] .users-space .ws-fields dd { margin: 0; overflow-wrap: anywhere; }
:root[data-theme] .users-space .ws-values { margin: 0; padding-left: 18px; }
:root[data-theme] .users-space .ws-block-card, :root[data-theme] .users-space .ws-record { border: 1px solid var(--space-stroke); background: var(--space-paper); border-radius: 14px; padding: 14px 16px; display: grid; gap: 8px; min-width: 0; }
:root[data-theme] .users-space .ws-block-card.subtle { background: transparent; }
:root[data-theme] .users-space .ws-block-card h4, :root[data-theme] .users-space .ws-record h4 { margin: 0; }
:root[data-theme] .users-space .ws-record-head { display: grid; gap: 4px; justify-items: start; }
:root[data-theme] .users-space .ws-records { display: grid; gap: 10px; }
:root[data-theme] .users-space .ws-records > summary { cursor: pointer; font-weight: 600; }
:root[data-theme] .users-space .ws-records[open] > summary { margin-bottom: 10px; }
@media (max-width: 640px) { :root[data-theme] .users-space .ws-fields { grid-template-columns: 1fr; } }
@media (max-width: 640px) { :root[data-theme] .users-space .space-section-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } :root[data-theme] .users-space .space-prototype-frame { min-height: 520px; } }
@media print { .users-space .space-section-cards, .users-space .space-prototype-frame { display: none !important; } }

/* VAT preparation (UStVA figures, manual ELSTER entry) */
.accounting-vat-prep { padding-bottom: 12px; }
.accounting-vat-settings { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #314039; }
.accounting-vat-settings label { display: grid; gap: 3px; font-size: 12px; }
.accounting-vat-settings label span { color: #8fa097; }
.accounting-vat-settings .accounting-vat-check { display: flex; align-items: center; gap: 6px; }
.accounting-vat-settings small { flex-basis: 100%; color: #8fa097; overflow-wrap: anywhere; }
.accounting-vat-quarters { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; padding: 10px 14px; }
.accounting-vat-quarter { border: 1px solid #314039; border-radius: 10px; padding: 10px 12px; }
.accounting-vat-quarter.tone-warn { border-color: #8a6d2c; }
.accounting-vat-quarter.tone-ok { border-color: #2f7a52; }
.accounting-vat-quarter header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.accounting-vat-quarter h4 { margin: 0; font-size: 14px; }
.accounting-vat-status { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #22302a; white-space: nowrap; }
.accounting-vat-status.tone-warn { background: #4a3b16; color: #f3d48a; }
.accounting-vat-status.tone-ok { background: #173d2a; color: #9be3b9; }
.accounting-vat-boxes { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.accounting-vat-boxes th, .accounting-vat-boxes td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #29352f; vertical-align: top; }
.accounting-vat-boxes td:first-child { font-weight: 700; white-space: nowrap; }
.accounting-vat-boxes td:last-child { white-space: nowrap; text-align: right; }
.accounting-vat-result td { font-weight: 700; border-top: 2px solid #3d5247; }
.accounting-vat-flags, .accounting-vat-scenarios { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.accounting-vat-flags li { color: #e8c877; }
.accounting-vat-howto { margin: 0 14px; font-size: 12px; }
.accounting-vat-subhead { margin: 12px 14px 4px; font-size: 13px; }
.accounting-vat-rows { width: 100%; border-collapse: collapse; font-size: 12px; }
.accounting-vat-rows th, .accounting-vat-rows td { text-align: left; padding: 6px; border-bottom: 1px solid #29352f; vertical-align: top; }
.accounting-vat-rows select, .accounting-vat-rows input { max-width: 100%; font-size: 12px; }
.accounting-vat-rows .accounting-vat-extra { display: grid; gap: 2px; margin-top: 4px; }
.accounting-vat-rows .accounting-vat-extra span { color: #8fa097; font-size: 11px; }
.accounting-vat-rows .accounting-vat-note { margin-top: 4px; width: 100%; }
.accounting-vat-amount { white-space: nowrap; text-align: right; }
.accounting-vat-docs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.accounting-vat-unreviewed td:first-child { box-shadow: inset 3px 0 0 #b8902f; }
.accounting-vat-annual { margin: 12px 14px 0; border: 1px solid #314039; border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.accounting-vat-annual h4 { margin: 0 0 6px; }
.accounting-vat-annual dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.accounting-vat-annual dd { margin: 0; font-weight: 700; }

.template-version-control select[data-document-revision-choice] { max-width: 112px; }

/* Ticket 16: global navigation belongs only to the sidebar. Floating phone controls do not form a header. */
:root[data-theme] .app-shell > .sidebar {
  display: flex; flex-direction: column; padding: 16px 14px; gap: 16px;
  min-width: 0; height: 100vh; height: 100dvh;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.brand-row .brand { min-width: 0; font-size: 15px; gap: 7px; }
.brand-row .brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
.sidebar-nav-area { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.sidebar-foot { flex: 0 0 auto; margin-top: 0; }
.sidebar .identity { margin: 0; padding-top: 12px; gap: 8px; }
.sidebar .identity > div { min-width: 0; flex: 1; }
.live-status-trigger, .live-status-trigger:hover, :root[data-theme] .live-status-trigger {
  background: transparent; border: 0; padding: 0; width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  box-shadow: none; gap: 0;
}
.live-status-dot { flex-shrink: 0; }
.live-status-panel { inset: 0; margin: auto; width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 16px; }
.live-status-panel td, .live-status-panel th { padding: 8px; overflow-wrap: anywhere; }
.live-status-panel table { table-layout: fixed; }
.live-status-panel .microcopy { overflow-wrap: anywhere; }
.theme-slider { display: inline-flex; justify-content: center; align-items: center; flex: 0 0 44px; width: 44px; min-width: 44px; height: 60px; padding: 0; border: 0; background: transparent; }
.theme-slider:hover { background: transparent; }
.theme-track { display: block; position: relative; width: 28px; height: 54px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 30px; }
.theme-knob { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--paper); color: var(--bg); display: grid; place-items: center; }
.theme-knob svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.theme-moon { opacity: 0; transform: scale(.5); transform-origin: center; }
.theme-slider[data-theme="dark"] .theme-knob { transform: translateY(26px); }
.theme-slider[data-theme="dark"] .theme-sun, .theme-slider[data-theme="dark"] .theme-rays { opacity: 0; transform: scale(.5) rotate(45deg); transform-origin: center; }
.theme-slider[data-theme="dark"] .theme-moon { opacity: 1; transform: scale(1); }
.navigation-close, .navigation-close:hover, .mobile-menu, .mobile-menu:hover {
  padding: 0; border: 0; background: transparent; box-shadow: none; width: 44px; height: 44px; min-height: 44px; color: var(--ink);
}
.navigation-close .icon, .mobile-menu .icon { stroke: currentColor; width: 24px; height: 24px; }
.navigation-close { align-self: flex-end; flex-shrink: 0; }
.navigation-backdrop { position: fixed; inset: 0; z-index: 100; background: #03050baa; }
:root[data-theme] .workspace { min-width: 0; }
:root[data-theme] .content { width: 100%; max-width: 100%; min-width: 0; }
:root[data-theme] .workspace:has(.mia-route-lock), :root[data-theme] .workspace:has(.templates-route-lock) { grid-template-rows: minmax(0, 1fr); }
:root[data-theme] .mia-route-lock, :root[data-theme] .templates-route-lock { height: 100%; }
body.hermes-active .app-shell, body.mailbox-active .app-shell, body.workstation-active .app-shell { height: 100vh; height: 100dvh; min-height: 0; }
body.hermes-active .workspace, body.mailbox-active .workspace, body.workstation-active .workspace { height: 100vh; height: 100dvh; display: flex; flex-direction: column; min-height: 0; }
body.hermes-active .content { flex: 1; padding: 0; margin: 0; overflow: hidden; }
.mailbox-workspace { min-height: 0; flex: 1; }
@media (max-width: 760px) {
  :root[data-theme] .app-shell { display: block; min-height: 100vh; min-height: 100dvh; width: 100%; }
  :root[data-theme] .app-shell > .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, calc(100vw - 52px)); max-height: 100vh; max-height: 100dvh; z-index: 101;
    transform: translateX(-105%); visibility: hidden; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  :root[data-theme] .app-shell > .sidebar.is-open { transform: translateX(0); visibility: visible; }
  .shell-floating { position: fixed; top: calc(4px + env(safe-area-inset-top)); left: calc(8px + env(safe-area-inset-left)); display: flex; align-items: center; gap: 2px; z-index: 90; }
  .mobile-menu { position: fixed; top: calc(4px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); display: inline-flex; z-index: 90; }
  /* Keep the shell controls reachable above Ticket details, not over Close. */
  .ticket-drawer { top: calc(56px + env(safe-area-inset-top)); }
  .ticket-drawer-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .ticket-drawer-head > div { min-width: 0; overflow-wrap: anywhere; }
  .ticket-drawer-close { white-space: nowrap; }
  .theme-slider { width: 60px; height: 44px; flex-basis: 60px; }
  .theme-track { width: 54px; height: 28px; }
  .theme-slider[data-theme="dark"] .theme-knob { transform: translateX(26px); }
  :root[data-theme] .app-shell .content { padding: 12px 12px 24px; margin: 0; }
  :root[data-theme] .app-shell > .workspace { padding-top: calc(56px + env(safe-area-inset-top)); min-height: 100vh; min-height: 100dvh; }
  :root[data-theme] .app-shell > .workspace:has(.mia-route-lock), :root[data-theme] .app-shell > .workspace:has(.templates-route-lock) { height: 100vh; height: 100dvh; }
  body.hermes-active .app-shell .content, body.mailbox-active .app-shell .content { padding: 0; }
  body.workstation-active .app-shell { display: block; }
  body.workstation-active .workspace { overflow: hidden; }
  body.workstation-active .app-shell .content { flex: 1; min-height: 0; }
  body.hermes-active .content { overflow: hidden; }
  :root[data-theme] .mia-route-lock, :root[data-theme] .templates-route-lock { height: 100%; }
  .live-status-panel { max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px); }
  #toast { bottom: max(16px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  .theme-knob { transition: transform .22s ease; }
  .theme-knob svg > * { transition: opacity .22s ease, transform .22s ease; }
  .app-shell > .sidebar { transition: transform .2s ease; }
}
:root[data-theme] .content:has(.mia-route-lock), :root[data-theme] .content:has(.templates-route-lock) { height: 100%; margin: 0; }
body.mailbox-active .content { flex: 1; }
@media (max-width: 760px) {
  .hermes-bar { gap: 4px 8px; padding: 6px 8px; }
  .hermes-bar-title { flex: 1 1 auto; }
  .hermes-bar-title small { display: none; }
  .hermes-profile { font-size: 12px; gap: 4px; }
  .hermes-profile select { width: auto; max-width: 145px; padding: 6px; }
  .hermes-bar .button { padding: 4px 8px; font-size: 12px; }
}
@media (max-width: 760px) and (max-height: 500px) {
  .server-screen-workspace .hermes-bar-title { display: none; }
}
/* Route-locked content must not inherit general phone-card padding. */
@media (max-width: 760px) {
  :root[data-theme] body.hermes-active .app-shell .content,
  :root[data-theme] body.mailbox-active .app-shell .content,
  :root[data-theme] .app-shell .content:has(.mia-route-lock),
  :root[data-theme] .app-shell .content:has(.templates-route-lock) { padding: 0; }
}
@media (max-width: 760px) and (max-height: 500px) {
  .server-screen-workspace .hermes-bar { padding-block: 2px; }
}
@media (max-width: 760px) {
  /* Reclaim the 12px extra floating-control clearance from gaps, not fields/actions. */
  .mia-route-lock .mia-canvas-stage { gap: 2px; }
  .templates-route-lock .template-document-stage.template-preview { padding-block: 4px; }
}

/* Fixed pool desktop controls overlay the viewer rather than reserving header space. */
.server-screen-workspace { position:relative; overflow:hidden; width:100%; }
.desktop-stage { flex:1 1 auto; display:flex; min-height:0; width:100%; height:100%; }
.desktop-stage .notice { align-self:center; margin:auto; max-width:32rem; }
.desktop-controls { position:fixed; right:max(12px,env(safe-area-inset-right)); bottom:max(12px,env(safe-area-inset-bottom)); z-index:48; display:flex; gap:6px; align-items:center; }
.server-screen-workspace > .desktop-controls { position:absolute; }
.desktop-controls > button { min-width:44px; min-height:44px; padding:8px 12px; border:1px solid var(--line); border-radius:12px; background:var(--panel,#141821); color:var(--ink,#e7e9ed); cursor:pointer; font:inherit; font-size:13px; font-weight:600; box-shadow:0 3px 12px rgb(0 0 0 / .16); }
.desktop-controls button:focus-visible,.desktop-controls a:focus-visible { outline:3px solid var(--accent,#61a6ef); outline-offset:2px; }
.desktop-menu { position:absolute; bottom:calc(100% + 8px); right:0; width:280px; max-width:calc(100vw - 24px); max-height:calc(100dvh - 92px - env(safe-area-inset-bottom)); overflow:auto; border:1px solid var(--line); border-radius:12px; background:var(--panel,#141821); color:var(--ink,#e7e9ed); padding:12px; box-shadow:0 6px 24px rgb(0 0 0 / .2); }
.desktop-menu[hidden] { display:none; }
.desktop-menu button,.desktop-menu a { display:flex; align-items:center; min-height:44px; width:100%; padding:8px; border-radius:6px; }
.desktop-menu p { font-size:12px; line-height:1.5; color:var(--muted); margin:0 0 8px; }
.server-screen-workspace:fullscreen { width:100%; height:100%; background:#0b0d12; }
.desktop-standalone #app,.desktop-standalone #content { height:100dvh; width:100%; padding:0; overflow:hidden; }
@media(max-width:760px) { .desktop-controls { bottom:max(12px,env(safe-area-inset-bottom)); } }

/* The owner Vault expands with its content; the page owns vertical scrolling. */
.project-vault{--pv-border:var(--border,#d9d2c8);font-size:12px;min-width:0;max-width:100%;padding:12px!important}
.project-vault:not(.pv-recipient){box-sizing:border-box;max-height:none;overflow:visible}
.project-vault:not(.pv-recipient) .pv-scroll,.project-vault:not(.pv-recipient) .pv-editor{max-height:none;overflow:visible}
.project-vault:has([data-pv-editor-slot]>*) .pv-scroll{display:none}
.pv-recipient [data-project-vault]{max-height:none;overflow:visible}
.project-vault h2{font-size:18px;margin:0}.pv-toolbar,.pv-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.project-vault button,.project-vault input,.project-vault select,.project-vault textarea{font:inherit;min-height:32px;max-width:100%;border:1px solid var(--pv-border);border-radius:6px;padding:5px 8px}
.project-vault button{cursor:pointer}.project-vault button:disabled{cursor:not-allowed;opacity:.5}.project-vault button:focus-visible,.project-vault a:focus-visible{outline:2px solid #308c87;outline-offset:2px}
.project-vault button[aria-pressed=true],.pv-key.selected{border-color:#998d7e}.pv-muted,.pv-meta{color:var(--muted,#5c6170)}.pv-meta{font-size:10px;display:block;margin-top:6px}
.pv-feedback{font-size:11px;margin:8px 0;overflow-wrap:anywhere;min-height:16px}.pv-feedback.error{color:var(--danger,#b13c38)}.pv-coverage{display:flex;gap:5px;flex-wrap:wrap;margin-bottom:8px}.pv-coverage button{font-size:11px;min-height:30px}
.pv-scroll{max-height:220px;overflow:auto;overscroll-behavior:contain}.pv-key{border:1px solid var(--pv-border);border-radius:8px;padding:8px;margin-bottom:6px}.pv-key-head{font-weight:600;text-align:left;width:100%}.pv-fields{margin:5px 0}
.pv-field{display:grid;grid-template-columns:minmax(90px,1fr) minmax(80px,2fr) auto auto;gap:7px;align-items:center;padding:3px 0}.pv-field-value{white-space:pre-wrap;overflow-wrap:anywhere;min-width:0}.pv-field-name{overflow-wrap:anywhere}.pv-link{margin-left:auto;overflow-wrap:anywhere}
.pv-editor{margin-top:8px;border:1px solid var(--pv-border);border-radius:8px;padding:10px;max-height:260px;overflow:auto}.pv-editor h3{font-size:14px;margin:0 0 7px}.pv-editor label{display:flex;flex-direction:column;gap:4px;font-size:11px}.pv-editor-top{display:grid;grid-template-columns:2fr 1fr;gap:8px;margin-bottom:7px}.pv-edit-row{display:grid;grid-template-columns:minmax(95px,1fr) 90px minmax(100px,2fr) auto;gap:6px;align-items:start;border-bottom:1px solid var(--pv-border);padding:6px 0}.pv-row-actions{display:flex;gap:3px;flex-wrap:wrap}.pv-edit-row textarea{resize:vertical;min-height:34px}.pv-secret-input{-webkit-text-security:disc}.pv-editor small{font-size:10px}.pv-editor .pv-check{display:flex;flex-direction:row;align-items:center;gap:5px}.pv-check input{min-height:0}.pv-grants{margin-top:6px}.pv-grant{padding:5px 0;border-bottom:1px solid var(--pv-border);overflow-wrap:anywhere}.pv-grant button{margin-left:8px}.pv-recipient{max-width:900px;margin:20px auto}.pv-recipient .pv-scroll{max-height:60vh}.pv-recipient .pv-editor{max-height:none}.pv-request-fields{display:grid;gap:10px;margin:10px 0}.pv-request-fields textarea{min-height:48px}.pv-login{display:grid;gap:10px;max-width:400px}.pv-login input{width:100%}
html[data-theme=light] .project-vault{background:#fffdf8;color:#272b36;--pv-border:#ded7cd}html[data-theme=light] .project-vault input,html[data-theme=light] .project-vault select,html[data-theme=light] .project-vault textarea,html[data-theme=light] .project-vault button{background:#fffaf3;color:inherit}
@media(max-width:650px){.pv-field{grid-template-columns:minmax(70px,1fr) minmax(65px,1.5fr) auto auto}.pv-edit-row{grid-template-columns:1fr 100px}.pv-edit-row>label:nth-child(3){grid-column:1/-1}.pv-scroll{max-height:40vh}.pv-editor{max-height:min(260px,55vh)}.pv-toolbar .pv-muted{width:100%}.pv-recipient{margin:8px auto}}
/* Keep Vault actions above the fixed mobile navigation, including safe-area devices. */
@media(max-width:650px){.content:has(.project-vault){padding-bottom:calc(190px + env(safe-area-inset-bottom,0px))}}

[data-people-documents] select { max-width: 100%; min-width: 0; }

/* ===== Owner People view (Clients + Collaborators) — scoped .portal-people-* ===== */
.portal-people-page { display: grid; gap: 16px; min-width: 0; }
.portal-people-hint { margin: 0; color: var(--muted); font-size: .88rem; }
.portal-people-group { display: grid; gap: 10px; min-width: 0; }
.portal-people-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.portal-people-group-head h2, .portal-people-group-head h4 { margin: 0; }
.portal-people-group-head .field { display: grid; gap: 4px; min-width: min(220px, 100%); }
.portal-people-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 12px; }
.portal-people-card { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); padding: 14px; min-width: 0; }
.portal-people-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.portal-people-ident { display: grid; gap: 2px; min-width: 0; }
.portal-people-ident strong, .portal-people-email { overflow-wrap: anywhere; }
.portal-people-email, .portal-people-meta, .portal-people-mini, .portal-people-none { color: var(--muted); font-size: .85rem; margin: 0; }
.portal-people-admissions { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.portal-people-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-soft); font-size: .82rem; max-width: 100%; }
.portal-people-chip button { min-height: 26px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; }
.portal-people-chip--client { border-color: color-mix(in srgb, var(--status-good) 45%, transparent); }
.portal-people-chip--collaborator { border-color: color-mix(in srgb, var(--status-info) 45%, transparent); }
.portal-people-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 8px; align-items: end; min-width: 0; }
.portal-people-form .field { display: grid; gap: 4px; min-width: 0; }
.portal-people-form select, .portal-people-form input { width: 100%; min-width: 0; }
.portal-people-form .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-people-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-people-danger { color: var(--status-bad); }
.portal-people-shares, .portal-people-vault, .portal-people-reset { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); min-width: 0; }
.portal-people-empty { margin: 0; padding: 16px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }
.portal-people-reset input, .portal-people-reset code { width: 100%; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

/* ===== #159 People (Clients + Collaborators): list + detail ===== */
.people-page { gap: 14px; }
.people-list-controls { display: grid; gap: 10px; min-width: 0; }
.people-list-controls .portal-people-hero { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 8px; }
.people-page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.people-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }
.people-segment, .people-role-switch { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); min-width: 0; }
.people-segment button, .people-role-switch button { min-height: 32px; padding: 4px 10px; border: 0; border-radius: 7px; background: transparent; }
.people-segment button.selected, .people-role-switch button.selected { background: var(--paper); color: var(--bg); font-weight: 600; }
.people-count { margin-left: 5px; font-size: .78em; opacity: .8; }
.people-filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); flex: 1 1 300px; gap: 8px; min-width: 0; }
.people-filters > * { min-width: 0; width: 100%; }
.people-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.people-list-pane, .people-detail-pane { min-width: 0; }
.people-list-groups { display: grid; gap: 6px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.people-list-count, .people-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; }
.people-list-count span { color: var(--muted); font-size: .76rem; }
.people-group { min-width: 0; }
.people-group-head { border-block-start: 1px solid var(--line); }
.people-group-head h2 { margin: 0; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; }
.people-rows { display: grid; min-width: 0; }
.people-row { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, auto); gap: 8px; align-items: center; width: 100%; min-width: 0; padding: 8px 10px; text-align: left; border: 0; border-block-start: 1px solid var(--line); border-radius: 0; background: transparent; color: inherit; }
.people-row:hover, .people-row[aria-current="true"] { background: var(--panel2); }
.people-row[aria-current="true"] { box-shadow: inset 3px 0 var(--paper); }
.people-row-main { display: grid; gap: 2px; min-width: 0; }
.people-row-name { font-weight: 600; overflow-wrap: anywhere; }
.people-row-sub { color: var(--muted); font-size: .79rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-row-status { display: grid; justify-items: end; gap: 3px; max-width: 105px; text-align: right; }
.people-row-status .badge { max-width: 100%; font-size: .71rem; white-space: normal; }
.people-activity { color: var(--muted); font-size: .71rem; line-height: 1.25; }
.people-row-arrow { display: none; color: var(--muted); }
.people-disabled-toggle { margin: 0 8px 8px; text-align: left; }
.people-row-badges { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.people-avatar { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; }
.people-avatar--large { width: 48px; height: 48px; font-size: 1rem; }
.people-role-badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: .74rem; font-weight: 600; }
.people-role-badge--client { border-color: color-mix(in srgb, var(--status-good) 55%, transparent); color: var(--status-good); }
.people-role-badge--collaborator { border-color: color-mix(in srgb, var(--status-info) 55%, transparent); color: var(--status-info); }
.people-role-badge--pending { color: var(--muted); }
.people-detail { gap: 12px; }
.people-detail-nav { display: none; }
.people-detail-head { display: grid; gap: 10px; min-width: 0; }
.people-detail-ident { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.people-detail-ident > div { display: grid; gap: 4px; min-width: 0; }
.people-detail-ident h2 { margin: 0; overflow-wrap: anywhere; }
.people-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; min-width: 0; }
.people-facts dt { color: var(--muted); font-size: .82rem; }
.people-facts dd { margin: 0; overflow-wrap: anywhere; }
.people-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.people-summary > div { min-width: 0; padding: 9px; background: var(--panel2); border-inline-end: 1px solid var(--line); }
.people-summary > div:last-child { border-inline-end: 0; }
.people-summary dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.people-summary dd { margin: 3px 0 0; font-size: .85rem; overflow-wrap: anywhere; }
.people-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.people-more { position: relative; }
.people-more summary { cursor: pointer; list-style: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; }
.people-more-menu { display: grid; gap: 6px; margin-top: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.people-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); min-width: 0; }
.people-tabs [role="tab"] { min-height: 32px; padding: 4px 10px; border: 0; border-radius: 8px; background: transparent; }
.people-tabs [role="tab"].selected { background: var(--panel); box-shadow: inset 0 -2px 0 var(--accent, var(--status-info)); font-weight: 600; }
.people-tab-body { display: grid; gap: 10px; min-width: 0; }
.people-tab-body h3 { margin: 0; font-size: 1rem; }
.people-plain-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.people-table-wrap { overflow-x: auto; max-width: 100%; }
.people-rights { width: 100%; border-collapse: collapse; font-size: .86rem; }
.people-rights th, .people-rights td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
@media (max-width: 900px) {
  .people-layout { grid-template-columns: minmax(0, 1fr); }
  .people-layout[data-people-view="detail"] .people-list-pane { display: none; }
  .people-page:has(.people-layout[data-people-view="detail"]) .people-list-controls { display: none; }
  .people-layout[data-people-view="list"] .people-detail-pane { display: none; }
  .people-page { gap: 8px; }
  .people-list-controls .portal-people-hero { padding: 0 0 8px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; align-items: center; }
  .people-page-intro :is(.eyebrow,.people-page-description), .people-list-count, .people-activity { display: none; }
  .people-page-intro h1 { font-size: 1.2rem; }
  .people-page-actions > * { font-size: .75rem; padding: 5px 7px; }
  .people-row-arrow { display: inline; }
  .people-detail-nav { display: flex; align-items: center; gap: 9px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .people-detail-nav > div { min-width: 0; display: grid; overflow-wrap: anywhere; }
  .people-detail-nav span { color: var(--muted); font-size: .78rem; }
  .people-back { flex: none; min-height: 34px; line-height: 1; padding: 4px 10px; font-size: 1.4rem; }
  .people-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .people-summary > div:nth-child(even) { border-inline-end: 0; }
  .people-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .people-detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .people-detail-actions [data-people-action="portal"] { grid-column: 2; grid-row: 1; }
  .people-detail-actions .people-more summary { text-align: center; min-height: 36px; }
  .people-toolbar > * { flex: 1 1 100%; }
  .people-segment button { flex: 1 1 0; }
}

/* Ticket 67: native CRM pressure + full process census, no embedded standalone UI. */
.home-watchdog-native .crm-pressure-panel,
.home-watchdog-native .crm-process-census { min-width: 0; padding: 18px; margin-block: 18px; overflow-wrap: anywhere; }
.home-watchdog-native .pressure-status { border-left: 4px solid var(--text-muted, #9aa0ae); padding-left: 12px; }
.home-watchdog-native .pressure-status[data-severity="critical"] { border-color: #e24f62; }
.home-watchdog-native .pressure-status[data-severity="warning"] { border-color: #b67b13; }
.home-watchdog-native .pressure-status[data-severity="ok"] { border-color: #28824b; }
.home-watchdog-native .pressure-status h2 { font-size: 1.2rem; line-height: 1.5; margin-block: 6px; }
.home-watchdog-native .pressure-summary { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-block: 16px; }
.home-watchdog-native .pressure-sparks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; margin-block: 16px; }
.home-watchdog-native .pressure-spark { margin: 0; min-width: 0; padding: 10px; border: 1px solid var(--line, #7776); border-radius: 8px; }
.home-watchdog-native .pressure-spark svg { display: block; width: 100%; height: 60px; }
.home-watchdog-native .pressure-spark polyline { fill: none; stroke: currentColor; stroke-width: 1.5; }
.home-watchdog-native .pressure-spark circle { fill: currentColor; }
.home-watchdog-native .pressure-rating[data-severity="critical"] { font-weight: 800; text-decoration: underline; }
.home-watchdog-native .pressure-rating[data-severity="warning"] { font-weight: 700; }
.home-watchdog-native .pressure-explanation { min-width: 220px; white-space: normal; }
.home-watchdog-native .crm-pressure-panel details > summary,
.home-watchdog-native .process-group > summary { cursor: pointer; padding: 12px 4px; white-space: normal; overflow-wrap: anywhere; }
.home-watchdog-native .process-group { border-top: 1px solid var(--line, #7776); min-width: 0; }
.home-watchdog-native .crm-process-census .process-command { min-width: 230px; max-width: 550px; white-space: normal; overflow-wrap: anywhere; }
.home-watchdog-native .crm-process-census .two-column { min-width: 0; }
.home-watchdog-native .crm-process-census .two-column > div { min-width: 0; }
.home-watchdog-native .crm-process-census ol { padding-left: 24px; }
.home-watchdog-native .crm-pressure-panel .table-scroll,
.home-watchdog-native .crm-process-census .table-scroll { max-width: 100%; overflow-x: auto; }
@media (max-width: 600px) {
  .home-watchdog-native .crm-pressure-panel, .home-watchdog-native .crm-process-census { padding: 12px; }
  .home-watchdog-native .crm-process-census .two-column { grid-template-columns: minmax(0, 1fr); }
}

/* Stremio guard panel (t_bc9b9a2d): read-only guard status, containers + end-to-end URLs. */
.home-watchdog-native .stremio-panel { min-width: 0; overflow-wrap: anywhere; }
.home-watchdog-native .stremio-panel [data-severity="healthy"] { --health-color: #75d895; }
.home-watchdog-native .stremio-panel [data-severity="warning"] { --health-color: #f5a742; }
.home-watchdog-native .stremio-panel [data-severity="critical"] { --health-color: #ff625d; }
.home-watchdog-native .stremio-panel .panel-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.home-watchdog-native .stremio-panel .panel-title p { color: var(--muted); margin: 4px 0 0; }
.home-watchdog-native .stremio-panel .health-led { display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--health-color, #f5a742); box-shadow: 0 0 10px var(--health-color, #f5a742); }
.home-watchdog-native .stremio-overall, .home-watchdog-native .stremio-state { display: inline-flex; align-items: center; gap: 8px; color: var(--health-color, #f5a742); white-space: nowrap; }
.home-watchdog-native .stremio-state { gap: 6px; }
.home-watchdog-native .stremio-panel .table-scroll { overflow-x: auto; }
.home-watchdog-native .stremio-table { width: 100%; margin-top: 12px; border-collapse: collapse; }
.home-watchdog-native .stremio-table th, .home-watchdog-native .stremio-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
.home-watchdog-native .stremio-table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.home-watchdog-native .stremio-table td small { display: block; margin-top: 3px; color: var(--muted); font-size: .75rem; white-space: normal; }
.home-watchdog-native .stremio-table tr[data-tone="critical"] td:first-child { color: #ffb4ac; font-weight: 650; }
.home-watchdog-native .stremio-table tr[data-tone="warning"] td:first-child { color: #f5c97a; font-weight: 600; }
.home-watchdog-native .stremio-summary { margin: 10px 0 0; border-left: 4px solid var(--health-color, #f5a742); padding: 8px 12px; border-radius: 6px; background: rgba(255,255,255,.03); font-weight: 600; }
.home-watchdog-native .stremio-url { max-width: 420px; white-space: normal; overflow-wrap: anywhere; }
.home-watchdog-native .stremio-note { border-left: 4px solid var(--health-color, #f5a742); padding: 8px 12px; border-radius: 6px; background: rgba(231,189,103,.08); }
.home-watchdog-native .stremio-issues { margin: 10px 0; padding-left: 20px; }
.home-watchdog-native .stremio-issues li { margin: 4px 0; }
.home-watchdog-native .stremio-issues li[data-severity="critical"] { color: #ffb4ac; }
.home-watchdog-native .stremio-recovery { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0 6px; }
.home-watchdog-native .stremio-recovery dt { font-size: .8rem; color: var(--muted); }
.home-watchdog-native .stremio-recovery dd { margin: 4px 0; font-weight: 600; }
.home-watchdog-native .stremio-recovery [data-severity="critical"] { color: #ff625d; }
.home-watchdog-native .stremio-recovery [data-severity="warning"] { color: #f5a742; }
.home-watchdog-native .stremio-table tr[data-soft] td:first-child { color: #f5c27a; }
@media (max-width: 700px) { .home-watchdog-native .stremio-recovery { grid-template-columns: minmax(0, 1fr); } }

.mia-topics-app {
  display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 3fr) minmax(165px, 1.15fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'topics heading files' 'topics preview files' 'topics composer files';
  min-width: 0; height: max(490px, calc(100dvh - 102px));
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.mia-topics-app h1, .mia-topics-app h2, .mia-topics-app h3, .mia-topic-dialog h2 { margin: 0; overflow-wrap: anywhere; }
.mia-topic-rail, .mia-topic-files, .mia-topic-preview { min-width: 0; overflow: auto; }
.mia-topic-rail, .mia-topic-files { padding: 14px; background: var(--panel); }
.mia-topic-rail { grid-area: topics; border-inline-end: 1px solid var(--line); }
.mia-topic-files { grid-area: files; border-inline-start: 1px solid var(--line); }
.mia-topic-rail > input { width: 100%; margin: 12px 0; }
.mia-topic-results h2, .mia-topic-files h2 { margin: 8px 0; font-size: .9rem; }
.mia-topic-results button, .mia-topic-files button { display: flex; text-align: start; width: 100%; min-height: 45px; margin-block: 4px; overflow-wrap: anywhere; white-space: normal; }
.mia-topic-results button { flex-direction: column; align-items: start; gap: 2px; }
.mia-topic-files button { align-items: center; justify-content: space-between; gap: 8px; }
.mia-topic-results button[aria-current='true'], .mia-topic-files button[aria-current='true'] { border-color: var(--accent); }
.mia-topic-results small, .mia-topic-ref, .mia-preview-toolbar small, .mia-topic-dialog small { color: var(--muted); overflow-wrap: anywhere; }
.mia-file-badge { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; font-size: .75rem; }
.mia-topic-bar { grid-area: heading; padding: 12px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.mia-topic-bar h2 { font-size: 1.12rem; }
.mia-topic-preview { grid-area: preview; display: flex; flex-direction: column; }
.mia-preview-toolbar, .mia-topic-dialog header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.mia-preview-toolbar { border-bottom: 1px solid var(--line); padding: 10px 14px; }
.mia-preview-toolbar > div:last-child, .mia-version-step { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.mia-preview-toolbar h3 { font-size: 1rem; }
.mia-preview-body { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; padding: 12px; }
.mia-preview-body :is(img, video, audio) { display: block; max-width: 100%; max-height: 100%; margin-inline: auto; }
.mia-preview-body audio { width: min(100%, 420px); }
.mia-preview-body iframe { border: 0; border-radius: 6px; width: 100%; height: 100%; min-height: 220px; background: white; }
.mia-preview-body pre, .mia-version-diff, .mia-send-dialog pre { max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.mia-markdown { max-width: 74ch; margin-inline: auto; overflow-wrap: anywhere; }
.mia-preview-empty { padding: 12px; color: var(--muted); }
.mia-topic-composer { grid-area: composer; display: grid; gap: 5px; border-top: 1px solid var(--line); padding: 10px 14px; background: var(--panel); min-width: 0; }
.mia-topic-composer > div { display: flex; align-items: end; gap: 8px; }
.mia-topic-composer textarea { min-width: 0; flex: 1; max-height: 100px; resize: vertical; }
.mia-topic-composer label { font-size: .85rem; overflow-wrap: anywhere; }
.mia-composer-result:empty { display: none; }
.mia-topics-app[data-topic='false'] .mia-topic-composer, .mia-topic-segment, .mia-topics-back { display: none; }
.mia-topic-dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: min(700px, calc(100% - 24px)); max-height: 82dvh; overflow: auto; }
.mia-topic-dialog::backdrop { background: rgba(0,0,0,.66); }
.mia-topic-dialog :is(h2, ol, p) { overflow-wrap: anywhere; }
.mia-version-sheet ol { list-style: none; padding: 0; }
.mia-version-sheet li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.mia-version-sheet li > div { margin-inline-end: auto; display: flex; flex-direction: column; }
.mia-version-diff { max-height: 14rem; }
.mia-topic-fullscreen { inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border-radius: 0; padding: 0; }
.mia-topic-fullscreen-content { display: flex; flex-direction: column; height: 100%; }
.mia-topic-fullscreen-content > :is(header, .mia-version-step) { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mia-topic-fullscreen-content .mia-version-step { justify-content: center; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
@media (max-width: 720px) {
  .mia-topics-app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'heading' 'preview' 'composer'; height: calc(100dvh - 87px); min-height: 0; }
  .workspace:has(> .desktop-controls) .mia-topics-app { height: calc(100dvh - 153px - env(safe-area-inset-bottom)); }
  .mia-topics-app[data-topic='false'] { grid-template-areas: 'topics'; grid-template-rows: minmax(0, 1fr); }
  .mia-topics-app[data-topic='false'] :is(.mia-topic-bar, .mia-topic-preview, .mia-topic-files),
  .mia-topics-app[data-topic='true'] .mia-topic-rail, .mia-topics-app[data-view='preview'] .mia-topic-files,
  .mia-topics-app[data-view='files'] .mia-topic-preview { display: none; }
  .mia-topics-app[data-topic='true'][data-view='files'] { grid-template-areas: 'heading' 'files' 'composer'; }
  .mia-topic-files { border: 0; }
  .mia-topic-bar { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px; align-items: center; padding: 8px; }
  .mia-topics-back { display: inline-flex; }
  .mia-topic-segment { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; grid-column: 1 / -1; }
  .mia-topic-segment button[aria-pressed='true'] { border-color: var(--accent); }
  .mia-topic-composer { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .mia-topics-app button, .mia-topic-dialog button, .mia-topic-bar button { min-height: 40px; }
  .mia-version-sheet { inset: auto 0 0; margin: 0; width: 100%; max-width: none; border-radius: 14px 14px 0 0; }
}

/* Mia notification corner and canonical topic filters. */
.mia-topics-app { position: relative; }
.mia-topic-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.mia-topic-coverage { margin: .4rem 0; font-size: .85rem; }
.mia-notifications-toggle { position: absolute; inset-block-start: .55rem; inset-inline-end: .55rem; z-index: 4; }
.mia-topic-bar { padding-inline-end: min(45%, 13rem); }
.mia-notifications-dialog { color: var(--text); background: var(--panel); width: min(60rem, calc(100vw - 2rem)); max-height: 83dvh; overflow: auto; }
.mia-notifications-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.mia-notification-list { display: grid; gap: .3rem; padding-block: .5rem; }
.mia-notification-list button { text-align: start; white-space: normal; }
.mia-notifications-dialog .mailbox-workspace { min-height: 0; }
@media (max-width: 700px) { .mia-topic-rail h1 { padding-inline-end: 8rem; } .mia-topic-bar { padding-block-start: 2.8rem; } }
