/* Shell and base components — "Aria" (docs/09, mockup design/mockups/direzione-A-aria.html).
   Rule: every color/radius/shadow comes from tokens.css. */

* {
  margin: 0;
  box-sizing: border-box;
}

/* The hidden attribute ALWAYS wins (docs/09): any author display (flex,
   grid...) would silently beat the UA [hidden] rule — it bit twice (modal
   overlay, preview spinner) before becoming this global ratchet. */
[hidden] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

/* Accessibility: visible keyboard focus everywhere (docs/09 §6) */
:focus-visible {
  outline: 2px solid var(--iris);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--surface);
  color: var(--iris-ink);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: 8px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Shell ---------- */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font: 700 22px/1 var(--font-display);
  letter-spacing: -0.02em;
  padding: 4px 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.logo .dot {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--iris), var(--iris-2));
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-size: 14px;
}

.nav a {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.nav a svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav a.on {
  background: var(--iris-soft);
  color: var(--iris-ink);
  font-weight: 600;
}

.nav a:hover:not(.on) {
  background: var(--surface-2);
}

/* Two-level sidebar (ADR-030): group headers are labels, never links. */
.nav-group {
  display: block;
  margin: 14px 10px 4px;
  font: 700 10.5px var(--font-body);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav-group:first-child {
  margin-top: 2px;
}

/* Placeholder entries (Documenti, Aiuto…): visible, clearly inert. */
.nav a[aria-disabled="true"] {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.side .grow {
  flex: 1;
}

.ai-card {
  background: linear-gradient(160deg, var(--ai-grad-a), var(--ai-grad-b));
  border-radius: var(--r-md);
  color: var(--on-accent);
  padding: 14px;
  font-size: 13px;
}

.ai-card b {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  display: block;
  margin-bottom: 4px;
}

.ai-card span {
  opacity: 0.75;
}

/* Topbar — three zones (ADR-026): [context] [centered search] [actions].
   Hosts without a center element (the console) leave the cell empty. */
.top {
  display: grid;
  grid-template-columns: 1fr minmax(0, 520px) 1fr;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.top > .search {
  grid-column: 2;
  max-width: none;
}

.top > .studio {
  grid-column: 3;
  justify-self: end;
  margin-left: 0;
}

.search {
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--ink-3);
  font-size: 14px;
}

.search kbd {
  margin-left: auto;
  font: 500 11px var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--ink-3);
}

.studio {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--transition);
}

.theme-toggle:hover {
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .theme-icon-dark,
:root:not([data-theme="dark"]) .theme-icon-light {
  display: none;
}

.main {
  padding: 26px 28px 90px;
  max-width: 1120px;
}

/* Page titles */
.page-title {
  font: 600 clamp(24px, 3vw, 32px) / 1.15 var(--font-display);
  letter-spacing: -0.015em;
}

h2 {
  font: 600 16px var(--font-display);
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

h2 small {
  font: 500 12.5px var(--font-body);
  color: var(--ink-3);
}

/* ---------- Components ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stack {
  display: grid;
  gap: 12px;
}

/* Grid items default to min-width:auto: without this, nowrap content
   (countdown pills, lock labels) forces horizontal overflow on mobile. */
.stack > * {
  min-width: 0;
}

/* Badges */
.badge {
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

/* Riservata: institutional treatment, exclusive (docs/09 §5) */
.badge.b-res {
  background: var(--res-bg);
  color: var(--res-fg);
  box-shadow: inset 0 0 0 1px var(--res-ring);
}

.badge.b-res::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--res-dot);
}

.badge.b-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.b-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.b-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.b-neutral {
  background: var(--surface-2);
  color: var(--ink-2);
}

/* Matter number (mono is part of the identity, docs/09 §3) */
.pnum {
  font: 500 13px var(--font-mono);
  color: var(--iris-ink);
  background: var(--iris-soft);
  padding: 4px 10px;
  border-radius: 7px;
  letter-spacing: 0.02em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin: 26px 0 22px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs a {
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-3);
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tabs a.on {
  color: var(--iris-ink);
  border-color: var(--iris);
}

/* Timeline — visual signature: colored thread (docs/09 §5) */
.tl {
  position: relative;
  padding-left: 26px;
}

.tl::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2.5px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--iris), var(--iris-2) 55%, var(--line));
}

.ev {
  position: relative;
  padding: 0 0 22px;
}

.ev::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--iris);
}

.ev.ev-doc::before {
  border-color: var(--success);
}

.ev.ev-due::before {
  border-color: var(--warning);
}

.ev time {
  font: 500 12px var(--font-mono);
  color: var(--ink-3);
}

.ev p {
  font-size: 14.5px;
  margin-top: 2px;
}

.ev p b {
  font-weight: 600;
}

.ev .who {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* Deadline card: date block + countdown pill (docs/09 §5) */
.due-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px;
}

.due-card .cal {
  width: 46px;
  text-align: center;
  border-radius: 10px;
  padding: 5px 0;
  background: var(--iris-soft);
}

.due-card .cal b {
  display: block;
  font: 700 17px var(--font-display);
  color: var(--iris-ink);
}

.due-card .cal span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--iris-ink);
  text-transform: uppercase;
}

.due-card.hot .cal {
  background: var(--danger-soft);
}

.due-card.hot .cal b,
.due-card.hot .cal span {
  color: var(--danger);
}

.due-card .due-text {
  flex: 1;
  min-width: 0;
}

.due-card h3 {
  font-size: 14.5px;
  font-weight: 600;
}

.due-card h3,
.due-card .sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.due-card .sub {
  font-size: 12.5px;
  color: var(--ink-3);
}

.pill {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.pill.hot {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.ok {
  background: var(--success-soft);
  color: var(--success);
}

/* Document row */
.doc {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}

.doc:last-child {
  border: none;
}

/* File-type badge (docs/09): standalone — document lists, reading header —
   not only inside the mockup's .doc rows. Colors from tokens only. */
.ic {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--on-accent);
}

.ic.w {
  background: var(--doc-word);
}

.ic.p {
  background: var(--danger);
}

.ic.x {
  background: var(--success);
}

.ic.pp {
  background: var(--warning);
}

.ic.i {
  background: var(--iris);
}

.ic.t,
.ic.f {
  background: var(--ink-3);
}

.doc .doc-text {
  flex: 1;
  min-width: 0;
}

.doc h3 {
  font-size: 14px;
  font-weight: 600;
}

.doc h3,
.doc .sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc .sub {
  font-size: 12px;
  color: var(--ink-3);
}

.lock {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--warning);
  background: var(--warning-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.ver {
  margin-left: auto;
  font: 500 11.5px var(--font-mono);
  color: var(--ink-3);
}

/* AI surfaces: iris accent + spark (docs/09 §5) */
.askbar {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1.5px solid var(--iris);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--ink-3);
  font-size: 14px;
  background: var(--surface);
}

.askbar .spark {
  color: var(--iris);
}

.ask {
  margin-top: 14px;
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.chip {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--iris-ink);
  background: var(--iris-soft);
  border: 1px solid var(--iris-ring);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background var(--transition);
}

.chip:hover {
  background: var(--iris-ring);
}

/* Primary action */
.btn-primary {
  background: var(--iris);
  color: var(--on-accent);
  font: 600 14.5px var(--font-body);
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  cursor: pointer;
  box-shadow: var(--fab-shadow);
  transition: filter var(--transition);
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  padding: 14px 22px;
  z-index: 8;
}

/* Empty state: always designed, never a blank page (docs/09 §5) */
.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  text-align: center;
  padding: 42px 20px;
}

.empty .empty-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--iris-soft);
  color: var(--iris-ink);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.empty h3 {
  font: 600 17px var(--font-display);
}

.empty p {
  font-size: 13.5px;
  color: var(--ink-3);
  max-width: 380px;
}

/* Skeleton loaders (not spinners, docs/09 §6) */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

/* ---------- Auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  /* minmax(0, 1fr): lets the card shrink below its max-width on narrow
     viewports — an auto track would lock it at max-content and overflow. */
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-logo {
  padding: 0 0 18px;
}

.auth-title {
  font: 600 20px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.auth-intro {
  font-size: 13.5px;
  color: var(--ink-2);
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}

.field input:focus-visible {
  outline: 2px solid var(--iris);
  outline-offset: 1px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.btn-block {
  width: 100%;
}

.auth-links {
  margin-top: 14px;
  font-size: 13px;
  text-align: center;
}

.auth-links a {
  color: var(--iris-ink);
  font-weight: 600;
}

.qr {
  display: grid;
  place-items: center;
  margin: 14px 0;
}

.qr svg {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.mono-key {
  font: 500 13px var(--font-mono);
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  letter-spacing: 0.06em;
  word-break: break-all;
  text-align: center;
}

.recovery-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.recovery-codes code {
  font: 500 13px var(--font-mono);
  background: var(--surface-2);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  text-align: center;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.monogram {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--iris-soft);
  color: var(--iris-ink);
  display: grid;
  place-items: center;
  font: 700 11px var(--font-body);
  letter-spacing: 0.02em;
}

.field select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
}

.form-success {
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.field-hint.slug-ok {
  color: var(--success);
}

.field-hint.slug-ko {
  color: var(--danger);
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.check-field input {
  margin-top: 2px;
}

/* Switch (ADR-027): the toggle control for boolean filters that act
   immediately ("only mine"). Token-only; knob rides the track on :checked. */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch .switch-track {
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  border: 1px solid var(--line);
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

.switch .switch-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(23, 26, 46, 0.25);
  transition: transform var(--transition);
}

.switch input:checked + .switch-track {
  background: var(--iris);
  border-color: var(--iris);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
  background: var(--on-accent);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--iris-2);
  outline-offset: 2px;
}

.switch input:checked ~ .switch-text {
  color: var(--ink);
}

/* Icon-only action button (advanced filters toggle, recycle bin). */
.btn-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.btn-icon:hover,
.btn-icon:focus-visible {
  color: var(--iris-ink);
  border-color: var(--iris-ring);
}

.btn-icon[aria-expanded="true"] {
  color: var(--iris-ink);
  background: var(--iris-soft);
  border-color: var(--iris-ring);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-icon .filter-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--iris);
  color: var(--on-accent);
  font: 700 10px/16px var(--font-body);
  text-align: center;
}

/* Advanced filter panel (ADR-027): full-width row under the simple bar,
   labeled fields in a responsive grid. Progressive disclosure: the toggle
   button opens it; it renders open when an advanced filter is active. */
.filter-panel {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
}

.filter-panel[hidden] {
  display: none;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.filter-field > label {
  font-size: 12px;
  color: var(--ink-3);
}

.filter-panel-actions {
  justify-content: flex-end;
}

.filter-panel-actions .btn-ghost {
  align-self: flex-start;
  text-decoration: none;
}

/* Removable chips for the active advanced filters (visible with the panel
   closed: filters never hide). The whole chip is the removal link. */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--iris-soft);
  color: var(--iris-ink);
  border: 1px solid var(--iris-ring);
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  transition: border-color var(--transition);
}

.chip:hover {
  border-color: var(--iris);
}

.chip .chip-x {
  font-weight: 700;
  opacity: 0.7;
}

/* Danger variant of the icon button: destructive row actions (unlink). */
.btn-icon--danger {
  color: var(--danger);
}

.btn-icon--danger:hover,
.btn-icon--danger:focus-visible {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* Linked-party rows of the edit panels (ADR-028 UI review): name left,
   destructive action pinned right; the add row is a dropdown + icon. */
.linked-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.linked-add {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.linked-add select {
  flex: 1;
  width: auto;
  min-width: 0;
}

/* Multilingual registry rows (ADR-031): one row per entry — chevron,
   base-language name, per-language status chips, actions pinned right;
   the chevron expands the per-language editing panel. */
.reg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.reg-row--sub {
  padding-left: 8px;
}

.reg-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.reg-row--inactive .reg-name {
  color: var(--muted);
  font-weight: 500;
  text-decoration: line-through;
}

.reg-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.reg-toggle:hover,
.reg-toggle:focus-visible {
  color: var(--iris-ink);
  background: var(--iris-soft);
}

.reg-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.reg-toggle[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

.reg-langs {
  display: inline-flex;
  gap: 4px;
  flex: 0 0 auto;
}

.reg-lang {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
}

.reg-lang--on {
  color: var(--iris-ink);
  border-color: var(--iris-ring);
  background: var(--iris-soft);
}

.reg-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.reg-detail {
  padding: 10px 12px 14px 36px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.reg-detail .field {
  margin-top: 8px;
}

.reg-detail .field label {
  font-size: 12px;
}

.reg-group {
  margin: 12px 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Tenant user administration rows (ADR-030 "Utenti"): avatar, identity,
   status badges, actions pinned right. The row wraps rather than truncate
   the name: identity always gets its space, actions drop to a second line
   aligned right when the card is narrow. */
.user-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: none;
}

.user-row .user-avatar {
  cursor: default;
}

.user-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 200px;
}

.user-main b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-main small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badges {
  display: inline-flex;
  gap: 6px;
  flex: 0 0 auto;
}

.user-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

/* Assisted translation block of a registry card (ADR-032): AI surface,
   marked by the iris spark like every AI feature (docs/09 §5). */
.reg-translate {
  margin: 4px 0 16px;
  padding: 12px;
  border: 1px solid var(--iris-ring);
  border-radius: var(--r-md);
  background: var(--iris-soft);
}

.reg-translate textarea {
  width: 100%;
  resize: vertical;
}

/* Mobile-first degradation (RNF-04): the hub tabs and the registry rows
   wrap instead of forcing the layout viewport wider than the device. */
@media (max-width: 640px) {
  .tabs {
    flex-wrap: wrap;
  }

  .reg-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .reg-langs {
    margin-left: 36px;
  }

  .reg-actions {
    margin-left: auto;
  }

  .reg-detail {
    padding-left: 12px;
  }
}

/* Principal parties of a matter stand out (ADR-028 UI review): accented
   block with client and counterparty (plus her lawyers); the OTHER parties
   live in plain groups under their own subtitle. */
.party-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  background: var(--iris-soft);
  border: 1px solid var(--iris-ring);
  border-radius: var(--r-md);
}

.party-primary-item {
  min-width: 0;
}

.party-primary .lawyer-row {
  border-top-color: var(--iris-ring);
}

.party-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.party-name {
  font: 600 15px var(--font-display);
  color: var(--ink);
}

.party-subtitle {
  margin: 18px 0 4px;
  font: 600 13px var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* Matter parties: lawyers grouped under their counterparty (ADR-028).
   The involvement switch is the only control; excluded lawyers stay
   listed but visibly dimmed — the mapping lawyer → counterparty never
   gets ambiguous. */
.party-group {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.party-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 6px;
}

.lawyer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.lawyer-row .lawyer-firm {
  color: var(--ink-3);
}

.lawyer-row--excluded .lawyer-name {
  color: var(--ink-3);
}

.lawyer-row--empty {
  color: var(--ink-3);
  font-size: 13px;
  justify-content: flex-start;
}

.lawyer-row .switch .switch-text {
  font-size: 12px;
  min-width: 82px;
}

@media (max-width: 480px) {
  .lawyer-row .switch .switch-text {
    display: none;
  }
}

/* Timeline filter + pager (ADR-029): a dropdown of macro families and a
   back/forward page control under the entries. */
.tl-filter {
  margin-top: 8px;
}

.tl-filter select {
  width: auto;
  max-width: 100%;
}

.tl-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.tl-page {
  font-size: 12px;
  color: var(--ink-3);
}

/* Full-width intro line of a form section (spans the two grid columns). */
.form-section-intro {
  margin: 0 0 4px;
}

/* Actions row above a list: primary action right-aligned (ADR-027). */
.list-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
}

/* Contact card (address book lists): tappable row-card, mobile-first. */
.contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.contact-card:last-child {
  border-bottom: 0;
}

.contact-card:hover {
  background: var(--surface-2);
}

.contact-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.contact-main b {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-main small {
  color: var(--ink-3);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-side {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 8px 18px;
  font-size: 14px;
}

.detail-grid dt {
  color: var(--ink-3);
  font-weight: 600;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.duplicate-list {
  margin: 0 0 12px 18px;
  font-size: 13.5px;
}

.duplicate-list a {
  color: var(--iris-ink);
  font-weight: 600;
}

/* Matter detail header (docs/09 §4: the matter is the hub). */
.phead {
  margin-bottom: 6px;
}

.phead .pnum {
  display: inline-block;
  margin-bottom: 6px;
}

.ptitle {
  font: 600 24px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  margin: 2px 0 10px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.phead .meta {
  color: var(--ink-2);
  font-size: 13.5px;
  margin-bottom: 4px;
}

.cols {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 18px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tabs a.disabled {
  color: var(--ink-3);
  cursor: default;
  pointer-events: none;
}

/* Matter card (matter lists): mono number + subject + badges. */
.matter-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

.matter-card:last-child {
  border-bottom: 0;
}

.matter-card:hover {
  background: var(--surface-2);
}

.matter-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.matter-main b {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-main small {
  color: var(--ink-3);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matter-side {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* Tab strip reused by list pages (matches .tabs of the matter detail). */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  width: 100%;
}

.list-toolbar .search-input {
  flex: 1;
  min-width: 180px;
  width: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Trial countdown banner (ADR-015), shown on every page while on trial. */
.trial-banner {
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 22px;
  border-bottom: 1px solid var(--line);
}

/* Topbar notification bell (ADR-024). */
.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
}

.bell svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.bell-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  font: 700 10px var(--font-body);
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}

.notification-unread {
  font-weight: 600;
}

/* "Le mie notifiche": per-type switches (v1 §11). */
.pref-table {
  width: 100%;
  border-collapse: collapse;
}

.pref-table th,
.pref-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.pref-table th:not(:first-child),
.pref-table td:not(:first-child) {
  text-align: center;
  width: 80px;
}

.logout-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 12.5px var(--font-body);
  cursor: pointer;
  transition: background var(--transition);
}

.logout-btn:hover {
  background: var(--surface-2);
}

/* Required-field marker (ADR-019): one class, applied to the label. */
.field-label--required::after {
  content: " *";
  color: var(--danger);
  font-weight: 700;
}

/* Form sections of the matter form (v1 parity, 4 fieldsets). */
.form-section {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px 8px;
  margin: 0 0 16px;
}

.form-section legend {
  font: 600 12px var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0 6px;
}

/* Inline remove control inside a badge (taxonomy types). */
.badge-remove {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0 0 0 4px;
  line-height: 1;
}

.badge-remove:hover {
  color: var(--danger);
}

/* Topbar global search: the pill is a real GET form (⌘K focuses it).
   width:0 kills the input's intrinsic width so the pill can shrink on
   narrow viewports (flex still grows it to fill the pill). */
.search input {
  flex: 1;
  width: 0;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  font: inherit;
  color: var(--ink);
}

.search input::placeholder {
  color: var(--ink-3);
}

.search:focus-within {
  border-color: var(--iris);
}

/* Dashboard KPI tiles: big value + label, clickable → filtered list. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--transition);
}

a.kpi:hover {
  border-color: var(--iris);
}

.kpi b {
  font: 700 26px/1.2 var(--font-display);
  color: var(--ink);
}

.kpi span {
  font-size: 12.5px;
  color: var(--ink-2);
}

.kpi.k-iris b {
  color: var(--iris-ink);
}

.kpi.k-warning b {
  color: var(--warning);
}

.kpi.k-danger b {
  color: var(--danger);
}

.section-title {
  font: 600 13px var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin: 24px 0 10px;
}

/* Agenda: per-day groups of due cards with inline quick actions. */
.agenda-item .due-card {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.agenda-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: 8px 15px;
}

.agenda-actions input[type="date"] {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font: 500 12.5px var(--font-body);
  color: var(--ink);
}

/* ---------- Styleguide (/dev/styleguide, Development only) ---------- */

.sg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
}

.sg-grid > * {
  min-width: 0;
}

.sg-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  color: var(--ink);
}

.sg-panel-title {
  font: 500 12px var(--font-mono);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.sg-section {
  margin-bottom: 26px;
}

.sg-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sg-swatch {
  width: 108px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  font-size: 11px;
}

.sg-swatch > div {
  height: 42px;
}

.sg-swatch span {
  display: block;
  padding: 5px 7px;
  font: 500 10.5px var(--font-mono);
  color: var(--ink-2);
  background: var(--surface);
}

.sg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

@media (max-width: 880px) {
  .sg-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Mobile (<880px, RNF-04) ---------- */

.bottom {
  display: none;
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    display: none;
  }

  .main {
    padding: 20px 16px 110px;
  }

  .top {
    padding: 12px 16px;
  }

  .search kbd {
    display: none;
  }

  .bottom {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    justify-content: space-around;
    padding: 8px 4px 12px;
    z-index: 9;
  }

  .bottom a {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--ink-3);
    display: grid;
    place-items: center;
    gap: 3px;
  }

  .bottom a.on {
    color: var(--iris-ink);
  }

  .bottom svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
  }

  .fab {
    bottom: 74px;
  }
}

/* ---- Matter notes & timeline (detail right column, ADR-019) ---- */
.note-list {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.note-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.note-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.note-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.note-meta {
  color: var(--ink-3);
  display: block;
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--iris-ink);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.timeline {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tl-entry {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tl-icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--iris-soft);
  font-size: 13px;
}

.tl-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tl-text {
  overflow-wrap: anywhere;
}

.tl-meta {
  color: var(--ink-3);
}

.tl-toggle {
  font-size: 12.5px;
  color: var(--iris-ink);
}

/* ---- Documents tab (matter detail, ADR-020) ---- */
.doc-card {
  flex-wrap: wrap;
}

.doc-side {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

/* Document preview (detail page): the frame never widens the layout. */
.doc-preview {
  width: 100%;
  height: 480px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

/* Reading page (docs/09, 2026-07-14): the preview takes ALL the remaining
   viewport under the compact header — reading comes first. */
.doc-preview--page {
  height: calc(100vh - 300px);
  min-height: 420px;
}

/* Reading header: badge + identity + icon actions on one wrapping row. */
.doc-head-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.doc-head-main {
  flex: 1;
  min-width: 220px;
}

.doc-head-main .ptitle {
  font-size: 20px;
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.doc-preview-img {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* Check-out banner (ADR-021): who is editing the document and until when. */
.doc-lock-banner {
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}

.doc-lock-banner a {
  color: inherit;
  text-decoration: underline;
}

/* ---- Icon actions (document view page, 2026-07-05 UI review) ---- */
.action-icons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-btn {
  font-size: 17px;
  line-height: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.icon-btn:hover {
  background: var(--iris-soft);
  border-color: var(--iris-ink);
}

.icon-btn--danger:hover {
  border-color: var(--danger);
  background: var(--surface);
}

/* ---- User avatar + user menu (headbar review, ADR-026) ---- */

/* The avatar button: generated initials (hue from the user id via the
   --avatar-hue inline property) or the uploaded image. */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: hsl(var(--avatar-hue, 230) var(--avatar-sat) var(--avatar-l));
  color: var(--on-accent);
  font: 700 12px var(--font-body);
  letter-spacing: 0.03em;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar--lg {
  width: 72px;
  height: 72px;
  font-size: 24px;
}

/* Dropdown anchored to the avatar. */
.user-menu-wrap {
  position: relative;
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 30;
  text-align: left;
  font-weight: 400;
}

.user-menu[hidden] {
  display: none;
}

.user-menu-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  display: grid;
  gap: 2px;
}

.user-menu-header .context {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.user-menu-header .name {
  font-weight: 700;
  color: var(--ink);
}

.user-menu-header .email {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.user-menu-item,
.user-menu form button.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--surface-2);
}

.user-menu-item svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--ink-3);
  flex: none;
}

.user-menu-item--danger {
  color: var(--danger);
}

.user-menu-item--danger svg {
  color: var(--danger);
}

.user-menu-separator {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 6px 0;
}

/* Inline language switcher inside the menu. */
.user-menu-langs {
  display: flex;
  gap: 6px;
  padding: 4px 12px 8px;
}

.user-menu-langs button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 3px 10px;
  font: 600 12px var(--font-body);
  cursor: pointer;
  text-transform: uppercase;
}

.user-menu-langs button:hover {
  background: var(--surface-2);
}

.user-menu-langs button.on {
  background: var(--iris-soft);
  color: var(--iris-ink);
  border-color: var(--iris-ring);
}

/* ---- Generic form/feedback helpers shared by both hosts (ADR-026:
   promoted from the console's ops.css when the profile pages arrived) ---- */

.hint {
  color: var(--ink-3);
  font-size: 0.85em;
}

.flash {
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.inline-form label {
  color: var(--ink-2);
  font-size: 0.9em;
}

.inline-form input,
.inline-form select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font: inherit;
}

.form-narrow {
  max-width: 480px;
}

.btn-ghost {
  background: transparent;
  color: var(--iris-ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

/* Profile page identity block (avatar + name/email). */
.profile-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-name {
  font: 600 17px var(--font-display);
}

/* Modal (docs/09): overlay + card, opened by [data-modal-open] and closed by
   [data-modal-close], Escape or a backdrop click (logic in site.js). The
   --full variant is the full-page surface (document previews). On mobile
   every modal takes the whole screen. */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--backdrop);
}

/* [hidden] handled by the global ratchet at the top of this file. */

.modal {
  display: flex;
  flex-direction: column;
  width: min(540px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.modal--full {
  width: min(1100px, 100%);
  height: calc(100vh - 48px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font: 600 17px var(--font-display);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow: auto;
}

.modal--full .modal-body {
  display: flex;
  flex-direction: column;
}

.modal--full .doc-preview {
  flex: 1;
  height: auto;
  min-height: 0;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 700px) {
  .modal-overlay {
    padding: 0;
  }

  .modal,
  .modal--full {
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
  }
}

/* Dropzone (docs/09): a label wrapping a hidden file input — the click opens
   the native picker by itself; drag&drop assigns input.files via site.js. */
.dropzone {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--iris);
  background: var(--iris-soft);
  color: var(--iris-ink);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone-file {
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Spinner (docs/09): for PUNCTUAL waits inside a document surface (preview
   rendering) — skeletons remain the rule for lists and cards. */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--line);
  border-top-color: var(--iris);
  border-radius: 50%;
  animation: spinner-turn 0.8s linear infinite;
}

@keyframes spinner-turn {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2s;
  }
}

.preview-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 0;
  color: var(--ink-2);
}
