:root {
  color-scheme: light;
  --blue: #0088e8;
  --blue-dark: #0069b5;
  --blue-hover: #00558f;
  --primary-button: #0069b5;
  --primary-button-hover: #00558f;
  --on-primary-button: #ffffff;
  --blue-soft: #dcefff;
  --blue-ink: #00324f;
  --lime: #aeea00;
  --lime-soft: #e2f99a;
  --lime-ink: #1c2900;
  --ink: #17212b;
  --muted: #58656f;
  --warm-white: #fbfafb;
  --surface: #ffffff;
  --surface-muted: #f4f6f8;
  --surface-strong: #e8edf1;
  --line: #d5dde3;
  --line-strong: #7d8a94;
  --teal: #006b61;
  --teal-soft: #c2f1e8;
  --teal-ink: #003c36;
  --warning: #8a4f00;
  --warning-soft: #ffe1b7;
  --warning-ink: #542d00;
  --danger: #ba1a1a;
  --danger-soft: #ffdad6;
  --danger-ink: #65000a;
  --on-accent: #ffffff;
  --focus-ring: rgb(0 136 232 / 24%);
  --topbar: rgb(255 255 255 / 96%);
  --scrim: rgb(23 33 43 / 44%);
  --overlay: rgb(244 246 248 / 72%);
  --shadow: 0 14px 36px rgb(23 33 43 / 11%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--surface-muted);
  color: var(--ink);
  line-height: 1.45;
  text-rendering: optimizeLegibility;
}

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

input,
select,
textarea {
  accent-color: var(--blue-dark);
}

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.18;
  font-weight: 700;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.65rem;
}

h3 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  stroke-width: 2;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-5rem);
  border-radius: 6px;
  background: var(--ink);
  padding: 0.6rem 0.8rem;
  color: var(--surface);
  font-weight: 700;
  text-decoration: none;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--surface-muted);
}

.auth-panel {
  width: min(100%, 25rem);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}

.auth-panel::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--blue);
  content: "";
}

.auth-logo {
  width: 6rem;
  height: 6rem;
  align-self: center;
  margin: 0.25rem 0 0.9rem;
  object-fit: contain;
}

.auth-panel h1 {
  margin-bottom: 0.35rem;
  font-size: 1.75rem;
  text-align: center;
}

.auth-subtitle {
  margin-bottom: 1.6rem;
  color: var(--muted);
  text-align: center;
}

.form-stack {
  width: 100%;
  display: grid;
  gap: 0.9rem;
}

.field {
  min-width: 0;
  display: grid;
  gap: 0.4rem;
}

.field > span,
.workspace-picker > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.workspace-picker select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  padding: 0.7rem 0.8rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field textarea {
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.workspace-picker select:hover {
  border-color: var(--blue-dark);
}

.button {
  min-height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 750;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button-primary {
  background: var(--primary-button);
  color: var(--on-primary-button);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-button-hover);
}

.button-secondary {
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

.button-danger {
  background: var(--danger);
  color: var(--on-accent);
}

.button-danger-outline {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.button-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}

.button.is-loading {
  cursor: progress;
}

.button.is-loading svg {
  animation: pulse 700ms ease-in-out infinite alternate;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 0.25rem;
  color: var(--blue-dark);
  font-weight: 700;
}

.auth-email-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-message {
  width: 100%;
  margin-top: 1rem;
  border-radius: 6px;
  background: var(--blue-soft);
  padding: 0.75rem 0.85rem;
  color: var(--blue-ink);
  font-size: 0.88rem;
}

.inline-message.is-error {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.join-panel {
  width: min(100%, 31rem);
}

.join-panel .auth-logo {
  width: 5rem;
  height: 5rem;
  margin-bottom: 0.6rem;
}

.join-panel > .eyebrow {
  margin-bottom: 0.25rem;
  text-align: center;
}

.join-summary {
  display: grid;
  gap: 1rem;
}

.compact-list {
  border-top: 1px solid var(--line);
}

.compact-list div {
  grid-template-columns: minmax(5.5rem, 0.45fr) minmax(0, 1fr);
  padding: 0.6rem 0;
  font-size: 0.88rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

#join-email-form,
#join-auth-code-form,
#join-profile-form {
  margin-top: 1rem;
}

.join-success {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  text-align: center;
}

.join-success > svg {
  width: 3rem;
  height: 3rem;
  color: var(--teal);
}

.join-success h2,
.join-success p {
  margin: 0;
}

.join-success .button {
  width: 100%;
  margin-top: 0.4rem;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 1.15rem 0.85rem;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.35rem;
}

.brand-row div {
  min-width: 0;
  display: grid;
}

.brand-row strong {
  font-size: 1.08rem;
}

.brand-row span {
  color: var(--muted);
  font-size: 0.76rem;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 7px;
}

.workspace-picker {
  display: grid;
  gap: 0.4rem;
  padding: 0 0.35rem;
}

.workspace-picker select {
  min-width: 0;
  height: 2.55rem;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.primary-nav {
  display: grid;
  gap: 0.3rem;
}

.nav-button {
  width: 100%;
  min-height: 2.65rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.nav-button:hover {
  background: var(--surface-muted);
}

.nav-button.is-active {
  background: var(--lime-soft);
  box-shadow: inset 3px 0 0 var(--lime);
  color: var(--lime-ink);
}

.sign-out-button {
  margin-top: auto;
}

.workspace-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  max-width: 48rem;
  margin: 0;
  overflow: hidden;
  font-size: 1.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.icon-button {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.icon-button:hover {
  border-color: var(--blue-dark);
  color: var(--blue-dark);
}

.content {
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem);
}

.view-section {
  display: grid;
  gap: 1.75rem;
}

.section-heading,
.subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: var(--blue-dark);
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge,
.count-label {
  border-radius: 6px;
  background: var(--teal-soft);
  padding: 0.35rem 0.65rem;
  color: var(--teal-ink);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: capitalize;
}

.status-badge.is-parked {
  background: var(--warning-soft);
  color: var(--warning-ink);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.metric-card {
  min-height: 7.4rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.metric-card svg {
  grid-row: 1 / 3;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 7px;
  background: var(--blue-soft);
  padding: 0.55rem;
  color: var(--blue-dark);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-card strong {
  min-width: 0;
  overflow: hidden;
  font-size: 1.22rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(15rem, 0.7fr);
  gap: 2rem;
}

.plain-section {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 1.15rem;
}

.detail-list {
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(8rem, 0.5fr) minmax(0, 1fr);
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.workspace-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.field-wide {
  grid-column: span 2;
}

.field-full,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.invite-admin-section {
  display: grid;
  gap: 1.25rem;
}

.invite-admin-section .subsection-heading h3 {
  margin-bottom: 0.2rem;
}

.invite-result {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  align-items: center;
  gap: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 1.15rem;
}

.invite-qr {
  width: 12rem;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 0.55rem;
}

.invite-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}

.invite-result-copy {
  min-width: 0;
}

.invite-result-copy > .muted {
  margin-top: 0.8rem;
}

.invite-code {
  display: block;
  margin: 0.15rem 0 0.35rem;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 1.35rem;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.invite-table-wrap {
  margin-top: 0.25rem;
}

.invite-table-wrap td small {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.status-badge[data-status="failed"] {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.status-badge[data-status="unavailable"] {
  background: var(--warning-soft);
  color: var(--warning-ink);
}

.status-badge[data-status="sent"] {
  background: var(--teal-soft);
  color: var(--teal-ink);
}

.status-badge[data-status="not_requested"] {
  background: var(--surface-strong);
  color: var(--ink);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.plan-card {
  min-width: 0;
  display: grid;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1rem;
}

.plan-card.is-current {
  border-color: var(--blue-dark);
  box-shadow: inset 0 3px 0 var(--blue-dark);
}

.plan-card h4 {
  margin: 0;
  font-size: 1rem;
}

.plan-card .plan-price {
  font-size: 1.2rem;
  font-weight: 800;
}

.plan-card .plan-storage {
  color: var(--muted);
  font-size: 0.85rem;
}

.plan-card .button {
  width: 100%;
  margin-top: auto;
}

.test-access {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(15rem, 1fr) auto;
  align-items: end;
  gap: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.test-access[hidden] {
  display: none;
}

.test-access h4,
.test-access p {
  margin: 0;
}

.test-access p {
  margin-top: 0.25rem;
}

.test-access-field {
  min-width: 0;
}

.test-access .button {
  min-height: 2.75rem;
}

.tax-document-manager {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) 10rem minmax(16rem, 1.4fr) auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 0.85rem;
  border-block: 1px solid var(--line);
  padding-block: 1rem;
}

.tax-document-heading h4,
.tax-document-heading p {
  margin: 0;
}

.tax-document-heading p {
  margin-top: 0.25rem;
}

.tax-country-field,
.tax-file-field {
  min-width: 0;
}

.tax-document-manager .button {
  min-height: 2.75rem;
}

.tax-document-list {
  margin-bottom: 1rem;
}

.tax-document-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}

.tax-document-row > svg {
  width: 1.2rem;
  height: 1.2rem;
  color: var(--blue-dark);
}

.tax-document-row strong,
.tax-document-row span {
  display: block;
  overflow-wrap: anywhere;
}

.tax-document-row span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.storage-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.15rem;
}

.cleanup-list {
  display: grid;
}

.cleanup-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
}

.cleanup-item svg {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  color: var(--blue-dark);
}

.cleanup-item strong,
.cleanup-item span {
  display: block;
}

.cleanup-item span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.storage-value-row,
.storage-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.storage-value-row strong {
  font-size: 1.5rem;
}

.storage-value-row span,
.storage-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-track {
  width: 100%;
  height: 0.75rem;
  display: block;
  margin: 1rem 0 0.65rem;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--surface-strong);
}

.progress-track::-webkit-progress-bar {
  background: var(--surface-strong);
}

.progress-track::-webkit-progress-value {
  background: var(--blue);
  transition: width 180ms ease;
}

.progress-track::-moz-progress-bar {
  background: var(--blue);
}

.progress-track.is-warning::-webkit-progress-value {
  background: var(--warning);
}

.progress-track.is-warning::-moz-progress-bar {
  background: var(--warning);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.table-wrap:has(tbody:empty) {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.78rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-muted);
}

.user-cell {
  min-width: 12rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-size: 0.72rem;
  font-weight: 800;
}

.user-cell strong,
.user-cell span,
.contact-cell span {
  display: block;
}

.user-cell span,
.contact-cell span {
  color: var(--muted);
  font-size: 0.78rem;
}

.table-badge {
  display: inline-block;
  border-radius: 5px;
  background: var(--surface-strong);
  padding: 0.2rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: capitalize;
}

.table-badge.is-available,
.table-badge.is-active {
  background: var(--teal-soft);
  color: var(--teal-ink);
}

.empty-state {
  margin-top: 0.75rem;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 1.75rem;
  color: var(--muted);
  text-align: center;
}

.inline-form {
  display: flex;
  align-items: end;
  gap: 0.8rem;
}

.inline-field {
  width: min(100%, 28rem);
}

.danger-section {
  border-top-color: var(--danger);
}

.export-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 1.25rem;
}

.archive-section {
  display: grid;
  gap: 1rem;
}

.archive-controls {
  display: flex;
  align-items: end;
  gap: 0.75rem;
}

.archive-date-field {
  width: min(100%, 15rem);
}

.archive-preview {
  border-left: 3px solid var(--blue-dark);
  background: var(--blue-soft);
  padding: 0.75rem 0.9rem;
  color: var(--blue-ink);
  font-size: 0.88rem;
}

.archive-download {
  margin-left: auto;
}

.export-icon {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.export-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.export-copy h3 {
  margin-bottom: 0.4rem;
}

.compact-list div {
  grid-template-columns: 8rem 1fr;
  border-bottom: 0;
  padding: 0.15rem 0;
  font-size: 0.84rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.empty-workspaces {
  min-height: 65vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-logo {
  width: 5rem;
  height: 5rem;
  margin-bottom: 1rem;
}

.empty-workspaces p {
  color: var(--muted);
}

.empty-workspace-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-dialog form {
  display: grid;
  gap: 16px;
}

.toast-region {
  position: fixed;
  z-index: 50;
  top: 5.25rem;
  right: 1rem;
  width: min(calc(100% - 2rem), 24rem);
  display: grid;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0.8rem;
  pointer-events: auto;
}

.toast.is-error {
  border-left-color: var(--danger);
}

.confirm-dialog {
  width: min(calc(100% - 2rem), 28rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.confirm-dialog::backdrop {
  background: var(--scrim);
}

.confirm-dialog form {
  padding: 1.4rem;
}

.dialog-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-dialog h2 {
  margin: 1rem 0 0.55rem;
  font-size: 1.25rem;
}

.confirm-dialog p {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.3rem;
}

.loading-overlay {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.spinner {
  width: 2.4rem;
  height: 2.4rem;
  border: 4px solid var(--blue-soft);
  border-top-color: var(--blue-dark);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  to { opacity: 0.35; }
}

@media (max-width: 980px) {
  .portal-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 10;
    height: auto;
    gap: 0.8rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.7rem 1rem;
    overflow: visible;
  }

  .brand-row {
    display: none;
  }

  .workspace-picker {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .primary-nav {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .primary-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    width: auto;
    flex: 0 0 auto;
    padding: 0.55rem 0.7rem;
  }

  .sign-out-button {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
  }

  .workspace-picker {
    padding-right: 7.5rem;
  }

  .topbar {
    position: static;
  }

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

@media (max-width: 680px) {
  .toast-region {
    inset: auto 1rem 1rem;
    width: auto;
  }

  .toast {
    width: 100%;
  }

  .test-access {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .tax-document-manager {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .auth-shell {
    padding: 1rem;
  }

  .auth-panel {
    padding: 1.35rem;
  }

  .join-panel .auth-logo {
    width: 4.25rem;
    height: 4.25rem;
  }

  .content {
    padding: 1.25rem 1rem 2rem;
  }

  .metrics-grid,
  .overview-grid,
  .form-grid,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .field-wide,
  .field-full {
    grid-column: auto;
  }

  .metric-card {
    min-height: 6.5rem;
  }

  .inline-form,
  .export-panel,
  .archive-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form {
    display: flex;
  }

  .archive-controls {
    display: flex;
  }

  .inline-field {
    width: 100%;
  }

  .archive-date-field,
  .archive-controls .button {
    width: 100%;
  }

  .export-panel {
    display: flex;
  }

  .export-panel .button {
    width: 100%;
  }

  .invite-result {
    grid-template-columns: 1fr;
  }

  .invite-qr {
    width: min(100%, 11rem);
    justify-self: center;
  }

  .invite-actions,
  .invite-actions .button,
  .invite-admin-section .form-actions .button {
    width: 100%;
  }

  .detail-list div {
    grid-template-columns: 7rem minmax(0, 1fr);
  }

  .primary-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.15rem;
    overflow: visible;
  }

  .primary-nav .nav-button {
    width: 100%;
    min-width: 0;
    min-height: 3.25rem;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.4rem 0.1rem;
    text-align: center;
  }

  .primary-nav .nav-button span {
    width: 100%;
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
  }

  .primary-nav .nav-button.is-active {
    box-shadow: inset 0 -3px 0 var(--lime);
  }

  .table-wrap:has(.responsive-table) {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table {
    background: transparent;
  }

  .responsive-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
  }

  .responsive-table tbody {
    display: grid;
    gap: 0.7rem;
  }

  .responsive-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 0.35rem 0.75rem;
  }

  .responsive-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid var(--line);
    padding: 0.62rem 0;
    text-align: right;
  }

  .responsive-table td::before {
    flex: 0 0 auto;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
  }

  .responsive-table td:last-child {
    border-bottom: 0;
  }

  .responsive-table td[data-label=""] {
    justify-content: flex-end;
  }

  .responsive-table td[data-label=""]::before {
    display: none;
  }

  .responsive-table .user-cell {
    width: 100%;
    text-align: left;
  }

  .responsive-table tbody tr:hover td {
    background: transparent;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --blue: #69c3ff;
    --blue-dark: #76c8ff;
    --blue-hover: #9bd8ff;
    --primary-button: #147db2;
    --primary-button-hover: #0e6b99;
    --on-primary-button: #ffffff;
    --blue-soft: #15394e;
    --blue-ink: #d3edff;
    --lime: #c3ee55;
    --lime-soft: #344900;
    --lime-ink: #e0fa8a;
    --ink: #e3e9ee;
    --muted: #aeb9c1;
    --warm-white: #10171d;
    --surface: #151e25;
    --surface-muted: #10171d;
    --surface-strong: #273139;
    --line: #35434d;
    --line-strong: #81909a;
    --teal: #62d9c8;
    --teal-soft: #005047;
    --teal-ink: #9af4e5;
    --warning: #ffb86a;
    --warning-soft: #4b2f11;
    --warning-ink: #ffd9a5;
    --danger: #ff8f88;
    --danger-soft: #591f21;
    --danger-ink: #ffd6d2;
    --focus-ring: rgb(105 195 255 / 30%);
    --topbar: rgb(16 23 29 / 96%);
    --scrim: rgb(0 0 0 / 62%);
    --overlay: rgb(16 23 29 / 76%);
    --shadow: 0 18px 44px rgb(0 0 0 / 34%);
  }

  .button-secondary {
    border-color: var(--line-strong);
  }

  .button-danger {
    background: #a93336;
  }

  .metric-card,
  .plan-card,
  .storage-summary,
  .export-panel {
    background: var(--surface);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.billing-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(82px, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented-control button {
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-selected {
  background: var(--primary-button);
  color: var(--on-primary-button);
}

.responsibility-list {
  display: grid;
  gap: 16px;
}

.responsibility-profile {
  border-top: 1px solid var(--line);
  padding: 18px 0 4px;
}

.responsibility-profile:first-child {
  border-top: 0;
  padding-top: 4px;
}

.responsibility-profile-heading,
.responsibility-transfer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.responsibility-profile-heading h4,
.responsibility-profile-heading p {
  margin: 0;
}

.responsibility-profile-heading p {
  margin-top: 4px;
  color: var(--muted);
}

.category-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.category-chip {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-muted);
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.responsibility-assignments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px 18px;
  margin: 0 0 16px;
}

.responsibility-assignments div {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.responsibility-assignments dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
}

.responsibility-assignments dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.responsibility-transfer {
  justify-content: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.responsibility-transfer .field {
  min-width: min(240px, 100%);
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--muted);
}

.reporting-line-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.reporting-line {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 20px minmax(120px, 1fr);
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.reporting-line svg {
  width: 16px;
  color: var(--muted);
}
