/* The manage surface. Every colour, radius and step here comes from the
   engine's own tokens (--ui-*, --brand, --accent-dark, --s1..--s7) so the
   drawer inside /app and the page at /manage are the same room, not two
   products that happen to share a logo. Nothing new is invented; what this
   file adds is one shape the engine did not have — the ledger row. */

.mg {
  display: flex;
  flex-direction: column;
  min-height: 0;
  color: var(--ui-text);
  font-family: var(--body);
}

/* ---- docket: the section tabs, with counts ---- */
.mg-tabs {
  display: flex;
  gap: var(--s5);
  padding: 0 var(--s5);
  border-bottom: 1px solid var(--ui-bd);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.mg-tabs::-webkit-scrollbar { display: none }
.mg-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 13px 0 11px;
  margin-bottom: -1px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-tab:hover { color: var(--ui-text) }
.mg-tab[aria-selected="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.mg-tab .n {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ui-muted);
  background: color-mix(in srgb, var(--ui-muted) 13%, transparent);
  border-radius: 999px;
  min-width: 18px;
  padding: 1px 5px;
  text-align: center;
}
.mg-tab[aria-selected="true"] .n {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 11%, transparent);
}

/* ---- the section itself ---- */
.mg-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s5) var(--s5) 56px;
}
.mg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin: 0 0 var(--s3);
}
.mg-head > .ghost { flex: 0 0 auto }
.mg-head .cap {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ui-muted);
  margin: 0;
  max-width: 58ch;
  text-wrap: pretty;
}

/* ---- the ledger row: this product's signature ----
   A record is a LINE on a roster, not a card in a grid. The stable ref the
   templates actually point at is printed in the left margin, the way a firm's
   own printed roster carries a file number. */
.mg-list { border-top: 1px solid var(--ui-bd) }
.mg-row {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s4);
  padding: 11px var(--s3) 11px var(--s2);
  border-bottom: 1px solid var(--ui-bd);
  transition: background-color 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-row:hover { background: color-mix(in srgb, var(--brand) 4%, transparent) }
.mg-row.is-open { background: color-mix(in srgb, var(--brand) 5%, transparent) }
.mg-ref {
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-main { min-width: 0 }
.mg-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-meta {
  display: block;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ui-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mg-acts {
  display: flex;
  gap: var(--s1);
  opacity: 0;
  transition: opacity 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-row:hover .mg-acts,
.mg-row:focus-within .mg-acts,
.mg-row.is-open .mg-acts { opacity: 1 }
@media (hover: none) { .mg-acts { opacity: 1 } }

.mg-act {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 10px;
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: none;
  color: var(--brand);
  cursor: pointer;
  transition: background-color 120ms cubic-bezier(0.23, 1, 0.32, 1),
              transform 100ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-act:hover { background: color-mix(in srgb, var(--brand) 10%, transparent) }
.mg-act:active { transform: scale(0.97) }
.mg-act:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 22%, transparent);
}
a.mg-act { text-decoration: none; display: inline-flex; align-items: center }
.mg-act.danger { color: #9B2C24 }
.mg-act.danger:hover { background: color-mix(in srgb, #9B2C24 10%, transparent) }

/* ---- the editor, opened in place on the row it belongs to ---- */
.mg-edit {
  grid-column: 1 / -1;
  padding: var(--s3) var(--s2) var(--s2);
  margin-top: 10px;
  border-top: 1px dashed var(--ui-bd);
  animation: mg-in 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes mg-in {
  from { opacity: 0; transform: translateY(-3px) }
  to   { opacity: 1; transform: none }
}
.mg-hint {
  font-size: 11.5px;
  color: var(--ui-muted);
  line-height: 1.5;
  margin: 0 0 10px;
  text-wrap: pretty;
}

/* ---- staff repeater ---- */
.mg-staff { display: grid; gap: var(--s2) }
.mg-staffrow {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 1.3fr 0.5fr auto;
  gap: var(--s2);
  align-items: center;
}

/* ---- states ---- */
.mg-empty {
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--ui-muted);
  font-size: 13px;
  line-height: 1.6;
  text-wrap: pretty;
}
.mg-empty b { display: block; color: var(--ui-text); font-size: 14px; margin-bottom: 4px }
.mg-load { padding: var(--s6) var(--s4); color: var(--ui-muted); font-size: 12px }
.mg-err {
  margin: 0 0 var(--s4);
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, #9B2C24 34%, var(--ui-bd));
  border-radius: 7px;
  background: color-mix(in srgb, #9B2C24 6%, transparent);
  color: #7E241D;
  font-size: 12.5px;
  line-height: 1.5;
}
/* The engine's .primary carries flex:1 because it is the one action in a
   340px rail. In a wide editor that becomes a slab, so it takes its natural
   width here and the row reads as save-then-cancel rather than one banner. */
.mg-edit .btnrow { justify-content: flex-start }
.mg-edit .btnrow .primary { flex: 0 0 auto }

.mg-note {
  margin: 0 0 var(--s4);
  padding: 10px 13px;
  border: 1px solid var(--ui-bd);
  border-radius: 7px;
  background: color-mix(in srgb, var(--brand) 4%, transparent);
  color: var(--ui-muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.mg-signin {
  color: var(--brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.mg-err .mg-signin { color: #7E241D }

.mg-gate { padding: var(--s7) var(--s5); text-align: center }
.mg-gate p { font-size: 13px; line-height: 1.6; color: var(--ui-muted); margin: 0 0 var(--s4) }

/* ---- the drawer that mounts this inside /app ---- */
.mg-scrim {
  position: fixed;
  inset: 0;
  background: rgba(11, 25, 45, 0.34);
  z-index: 110;
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-scrim.on { opacity: 1 }
.mg-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100vw);
  background: var(--ui-panel);
  border-left: 1px solid var(--ui-bd);
  z-index: 111;
  display: flex;
  flex-direction: column;
  transform: translateX(14px);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.23, 1, 0.32, 1),
              opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.mg-drawer.on { transform: none; opacity: 1 }
.mg-drawer .mg { flex: 1; min-height: 0 }
.mg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: 13px var(--s5);
  border-bottom: 1px solid var(--ui-bd);
  flex-shrink: 0;
}
.mg-bar .ttl { font-size: 15px; font-weight: 600 }
.mg-bar .sub { font-size: 12px; color: var(--ui-muted); margin-left: 9px }

@media (prefers-reduced-motion: reduce) {
  .mg-drawer, .mg-scrim, .mg-row, .mg-act, .mg-tab { transition-duration: 1ms }
  .mg-edit { animation-duration: 1ms }
}

@media (max-width: 720px) {
  .mg-row { grid-template-columns: minmax(0, 1fr) auto }
  .mg-ref { grid-column: 1 / -1; order: -1; margin-bottom: 1px }
  .mg-staffrow { grid-template-columns: 1fr 1fr }
}

/* Sign-in state we cannot determine: stated, never a button, because the
   button would lead at a flow that is down for the same reason. */
.acctNote{
  font-size:12px;
  color:var(--ui-muted,#6b6355);
  border:1px solid var(--ui-line,rgba(0,0,0,.12));
  border-radius:6px;
  padding:3px 8px;
  cursor:help;
}
