/* ── Design System — Gestão de Contratos ───────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-soft: rgba(79, 70, 229, 0.12);
  --color-bg: #f1f5f9;
  --color-bg-subtle: #e2e8f0;
  --color-bg-hover: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-success: #16a34a;
  --color-success-soft: rgba(22, 163, 74, 0.12);
  --color-warning: #d97706;
  --color-warning-soft: rgba(217, 119, 6, 0.12);
  --color-danger: #dc2626;
  --color-danger-soft: rgba(220, 38, 38, 0.1);
  --color-auth-gradient-1: #eef2ff;
  --color-auth-gradient-2: #f8fafc;
  --color-auth-glow: rgba(79, 70, 229, 0.15);
  --lookup-panel-gradient: linear-gradient(135deg, #fbfbfe 0%, #f5f6fc 55%, #f8fafc 100%);
  --lookup-panel-title: #6366f1;
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --bottom-nav-height: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --color-primary: #818cf8;
  --color-primary-hover: #a5b4fc;
  --color-primary-soft: rgba(129, 140, 248, 0.16);
  --color-bg: #0b0f17;
  --color-bg-subtle: #151b28;
  --color-bg-hover: #1a2233;
  --color-surface: #121826;
  --color-surface-raised: #1a2233;
  --color-border: #243044;
  --color-border-strong: #334155;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-success-soft: rgba(34, 197, 94, 0.14);
  --color-warning-soft: rgba(245, 158, 11, 0.14);
  --color-danger: #fca5a5;
  --color-danger-soft: rgba(185, 28, 28, 0.45);
  --color-auth-gradient-1: #0f1420;
  --color-auth-gradient-2: #0b0f17;
  --color-auth-glow: rgba(129, 140, 248, 0.12);
  --lookup-panel-gradient: linear-gradient(135deg, #151929 0%, #141824 55%, #121826 100%);
  --lookup-panel-title: #9498f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);
}

html {
  color-scheme: light;
  height: 100%;
  overflow: hidden;
}
[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  height: 100%;
  overflow: hidden;
}

/* ── Layout ────────────────────────────────────────────────── */

.app {
  display: flex;
  height: 100%;
  overflow: hidden;
  max-width: 100vw;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 1.25rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--color-border);
  letter-spacing: -0.02em;
}

.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }

.sidebar-section-label {
  padding: 1rem 1.25rem .375rem;
  margin-top: .25rem;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
}

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 95;
  backdrop-filter: blur(2px);
}

.drawer-overlay.visible { display: block; }

body.drawer-active { overflow: hidden; }

.sidebar-link {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem 1.25rem;
  margin: 0 .5rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar-link:hover { background: var(--color-bg-hover); color: var(--color-text); }
.sidebar-link.active {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  font-weight: 600;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  height: 100%;
  min-height: 0;
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin var(--transition);
}

.topbar {
  position: relative;
  top: 0;
  z-index: 90;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(8px);
  transition: background var(--transition), border-color var(--transition);
  min-width: 0;
  max-width: 100%;
  flex-shrink: 0;
}

.topbar[hidden] { display: none !important; }

.topbar__start {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-width: 0;
}

.topbar__brand { font-size: 1.25rem; line-height: 1; }

.topbar__title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

.topbar__user {
  font-size: .875rem;
  color: var(--color-text-muted);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__locale { width: auto; min-width: 5.5rem; }

.topbar__logout { white-space: nowrap; }

.app-content {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.app-content:has(.content-page-header) {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}

.app-content:has(.edit-page),
.app-content:has(.contracts-page),
.app-content:has(.clients-page),
.app-content:has(.users-page),
.app-content:has(.dash-page),
.app-content:has(.app-page) {
  max-width: none;
}

.app-content > * {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Content page header ───────────────────────────────────── */

.content-page-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  flex-wrap: nowrap;
  flex-shrink: 0;
  margin: 0 0 1.25rem;
  padding: 1.125rem 2rem;
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.content-page-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
}

.content-page-header__filters {
  width: 100%;
  padding-top: .85rem;
  margin-top: .85rem;
  border-top: 1px solid var(--color-border);
}

.quick-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.quick-filter-btn {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: .42rem .9rem;
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.quick-filter-btn:hover {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.quick-filter-btn.is-active {
  box-shadow: 0 0 0 1px color-mix(in srgb, currentColor 35%, transparent);
}

.quick-filter-btn--revenue.is-active {
  background: var(--color-success-soft);
  border-color: color-mix(in srgb, var(--color-success) 35%, var(--color-border));
  color: var(--color-success);
}

.quick-filter-btn--received.is-active {
  background: var(--color-warning-soft);
  border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-border));
  color: var(--color-warning);
}

.quick-filter-btn--active.is-active {
  background: var(--color-success-soft);
  border-color: color-mix(in srgb, var(--color-success) 35%, var(--color-border));
  color: var(--color-success);
}

.quick-filter-btn--negotiation.is-active {
  background: var(--color-warning-soft);
  border-color: color-mix(in srgb, var(--color-warning) 35%, var(--color-border));
  color: var(--color-warning);
}

.quick-filter-btn--cancelled.is-active {
  background: var(--color-danger-soft);
  border-color: color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
  color: var(--color-danger);
}

.quick-filter-show-all {
  margin-left: auto;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .quick-filter-show-all {
    margin-left: 0;
    flex-basis: 100%;
    justify-content: center;
  }
}

.page-body,
.list-page-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  padding-left: 2rem;
  padding-right: 2rem;
  padding-bottom: 1.25rem;
}

.page-body {
  overflow-y: auto;
  overflow-x: hidden;
}

.list-page-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edit-page > :not(.content-page-header):not(.edit-page-footer) {
  margin-left: 2rem;
  margin-right: 2rem;
  min-width: 0;
}

.content-page-header__main {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.content-page-header__text { min-width: 0; }

.content-page-header__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.content-page-header__subtitle {
  margin: .25rem 0 0;
  font-size: .9375rem;
  color: var(--color-text-muted);
}

.content-page-header__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.content-page-header__actions .input[type="search"] {
  min-width: 10rem;
  width: 14rem;
  max-width: 100%;
}

.content-page-header--with-back { align-items: center; }

.edit-page-footer {
  flex-shrink: 0;
  margin: 1.25rem 0 0;
  padding: 1rem 2rem;
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.edit-page-footer__inner {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── List pages (Tabulator + cards) ────────────────────────── */

.app-page,
.dash-page,
.contracts-page,
.clients-page,
.users-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.data-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.data-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.data-panel__overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
}

.data-panel__overlay.is-visible { display: flex; }

.data-panel__overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  color: var(--color-text-muted);
  font-size: .875rem;
}

.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 12rem;
  color: var(--color-text-muted);
  text-align: center;
}

.page-loading--tall {
  min-height: min(420px, calc(100vh - 16rem));
}

.page-body--centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.dash-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: min(420px, calc(100vh - 16rem));
  padding: 2.5rem 1.5rem;
  margin: 0 auto;
  max-width: 28rem;
}

.dash-empty-state__illus {
  width: min(200px, 55vw);
  height: auto;
  margin-bottom: 1.25rem;
}

.dash-empty-state__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  color: var(--color-text);
}

.dash-empty-state__desc {
  margin: 0 0 1.35rem;
  color: var(--color-text-muted);
  font-size: .9rem;
  line-height: 1.55;
  max-width: 22rem;
}

.dash-empty-state__cta {
  min-width: 12rem;
}

.page-loading__spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.list-cards-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: .75rem 0 0;
  flex-shrink: 0;
}

.list-cards-pager__info {
  font-size: .8125rem;
  color: var(--color-text-muted);
  min-width: 10rem;
  text-align: center;
}

.contracts-status {
  flex-shrink: 0;
  margin-bottom: .75rem;
  font-size: .8125rem;
}

.contracts-status--refresh {
  color: var(--color-text-muted);
  text-align: right;
}

.dash-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
  padding: .65rem .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-primary-soft);
  font-size: .875rem;
  font-weight: 600;
}

.is-clickable { cursor: pointer; }

.client-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
  font-size: .78rem;
}

.client-stat-expiring { color: var(--color-warning); font-weight: 600; }

.badge-client-tier--small { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.badge-client-tier--medium { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-client-tier--large { background: #ede9fe; color: #6d28d9; }

.page-intro {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  max-width: 52rem;
}

.placeholder-card,
.report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.report-card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .5rem;
}

.report-card__hint {
  font-size: .875rem;
  color: var(--color-text-muted);
  margin-bottom: .75rem;
}

.report-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.report-chip {
  display: inline-flex;
  align-items: center;
  padding: .35rem .75rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  cursor: pointer;
  font: inherit;
}

.report-chip.is-active {
  background: var(--color-primary);
  color: #fff;
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.report-kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.report-kpi span,
.report-kpi small {
  display: block;
  color: var(--color-text-muted);
  font-size: .75rem;
}

.report-kpi strong {
  display: block;
  margin: .2rem 0 .15rem;
  font-size: 1.15rem;
}

.report-kpi--revenue strong { color: var(--color-success); }
.report-kpi--cost strong { color: var(--color-warning); }

.insight-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.insight-block__head h2 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
}

.insight-block__head p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: .875rem;
}

.insight-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.35rem;
  padding: 0 .4rem;
  margin-left: .35rem;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: .72rem;
  font-weight: 700;
  vertical-align: middle;
}

.insight-card .dash-card__head {
  align-items: flex-start;
  gap: .75rem;
}

.insight-history__head,
.insight-history-row {
  display: grid;
  grid-template-columns: minmax(8rem, .9fr) minmax(8rem, 1.3fr) minmax(7rem, 1fr) 6.5rem minmax(6rem, 1fr);
  gap: .35rem .65rem;
  align-items: center;
  width: 100%;
}

.insight-history__head {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: .35rem .25rem .45rem;
}

.insight-history-row {
  padding: .55rem .25rem;
  border: none;
  border-top: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.insight-history-row.is-clickable { cursor: pointer; }
.insight-history-row.is-clickable:hover { background: var(--color-primary-soft); }

.insight-history-row strong {
  display: block;
  font-size: .8125rem;
}

.insight-history-row small,
.insight-history-row__who {
  display: block;
  font-size: .68rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 639px) {
  .insight-history__head { display: none; }
  .insight-history-row {
    grid-template-columns: 1fr 1fr;
    padding: .7rem .15rem;
  }
  .insight-history-row__contract { grid-column: 1 / -1; }
}

.text-muted { color: var(--color-text-muted); }

body.layout-auth .sidebar,
body.layout-auth .drawer-overlay,
body.layout-auth .topbar { display: none !important; }

body.layout-auth .main {
  margin-left: 0;
  height: 100%;
  max-width: 100vw;
  overflow: auto;
}

body.layout-auth .app-content {
  padding: 0;
  max-width: none;
  min-height: 0;
  overflow: auto;
}

body.layout-auth .app-content > * {
  overflow: visible;
  flex: 1 0 auto;
}

/* ── Responsive ────────────────────────────────────────────── */

.desktop-only { display: block; }
.mobile-only { display: none; }

@media (min-width: 1024px) {
  .mobile-only { display: none !important; }
}

@media (max-width: 1023px) {
  .desktop-only { display: none !important; }
  .main {
    margin-left: 0;
    max-width: 100vw;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.drawer-open { transform: translateX(0); }
  .topbar { padding: 0 1rem; }
  .topbar__title { font-size: .95rem; }
  .topbar__user { display: none; }
  .topbar__locale { min-width: 4.5rem; font-size: .8rem; }
  .topbar__logout { padding: .375rem .625rem; font-size: .8rem; }
  .app-content { padding: 1rem; }
  .app-content:has(.content-page-header) {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }
  .content-page-header {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .page-body,
  .list-page-body {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .edit-page > :not(.content-page-header):not(.edit-page-footer) {
    margin-left: 1rem;
    margin-right: 1rem;
  }
  .edit-page-footer {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
  .page-header { align-items: stretch; }
  .page-actions { flex-wrap: wrap; width: 100%; }
  body.layout-auth .main { padding-bottom: 0; }
  body.layout-auth .app-content { padding-bottom: 0; }
}

/* ── Page ──────────────────────────────────────────────────── */

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  padding: .5rem 1rem; border: 1px solid transparent;
  border-radius: var(--radius-sm); font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  font-family: inherit; line-height: 1.25;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-bg-hover); color: var(--color-text); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  box-shadow: none;
}

.btn-outline:hover:not(:disabled) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.btn-icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1rem;
}
.btn-sm { padding: .3rem .625rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.25rem; font-size: .9375rem; }
.btn-block { width: 100%; }

.btn-spinner {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ─────────────────────────────────────────────────── */

.input {
  padding: .625rem .875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input::placeholder { color: var(--color-text-muted); opacity: .75; }
.input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.input-sm { padding: .375rem .625rem; font-size: .8125rem; }

.form-group { margin-bottom: 1.125rem; }
.form-group label {
  display: block;
  margin-bottom: .375rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .375rem;
  gap: .5rem;
}
.form-label-row label { margin-bottom: 0; }

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.25rem;
  font-size: .875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}
.form-check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
}

.input-password-wrap { position: relative; }
.input-password-wrap .input { padding-right: 2.75rem; }
.input-password-toggle {
  position: absolute;
  right: .25rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
}

/* ── Auth pages ────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  position: relative;
}

.auth-page--bleed {
  background: #0f172a;
}

.auth-page__backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.auth-page__foreground {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.auth-slideshow {
  position: absolute;
  inset: 0;
}

.auth-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.2s ease;
  transform: scale(1.04);
}

.auth-slide.is-active {
  opacity: 1;
  transform: scale(1);
}

.auth-slideshow__overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.55) 0%, rgba(15, 23, 42, 0.78) 45%, rgba(15, 23, 42, 0.88) 100%),
    linear-gradient(135deg, rgba(79, 70, 229, 0.28) 0%, transparent 55%);
}

.auth-slideshow__caption {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 4.5rem;
  z-index: 2;
  color: #fff;
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
  max-width: min(36rem, calc(100% - 2.5rem));
  text-align: center;
  pointer-events: none;
}

.auth-slideshow__dots {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 2rem;
  z-index: 2;
  display: flex;
  gap: .45rem;
}

.auth-slideshow__dot {
  width: .55rem;
  height: .55rem;
  border-radius: 999px;
  border: none;
  padding: 0;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
}

.auth-slideshow__dot.is-active {
  background: #fff;
  transform: scale(1.25);
}

.auth-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}

.auth-page--bleed .auth-toolbar {
  color: #fff;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-page--bleed .auth-toolbar__title {
  color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.auth-page--bleed .auth-toolbar .btn-ghost {
  color: rgba(255, 255, 255, 0.92);
}

.auth-page--bleed .auth-toolbar .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.auth-page--bleed .locale-select__trigger {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  backdrop-filter: blur(8px);
}

.auth-page--bleed .locale-select__menu {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.auth-page--bleed .locale-select__option:hover,
.auth-page--bleed .locale-select__option.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.auth-toolbar__brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: -0.02em;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-brand-icon {
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(79, 70, 229, 0.18));
}

.app-brand-icon--sm { width: 2rem; height: 2rem; }
.app-brand-icon--md { width: 3.5rem; height: 3.5rem; }
.app-brand-icon--lg { width: 4.5rem; height: 4.5rem; }

.auth-toolbar__actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.auth-select { width: auto; min-width: 7rem; }

.auth-page__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1.5rem 2rem;
}

.auth-page--bleed .auth-page__body {
  background: transparent;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35), var(--shadow-lg);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.auth-page--bleed .auth-card {
  backdrop-filter: blur(6px);
}

.auth-card__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.auth-card__icon .app-brand-icon--lg {
  width: 4.75rem;
  height: 4.75rem;
}

.auth-card__title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: .375rem;
}

.auth-card__subtitle {
  font-size: .9375rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.auth-card--wide { max-width: 520px; }

.auth-page__body--wide {
  align-items: flex-start;
  padding-top: .75rem;
  padding-bottom: 2rem;
}

.auth-page--bleed .auth-page__body--wide {
  align-items: flex-start;
  padding-top: 1rem;
}

.register-page.auth-card--wide,
.auth-card.register-page {
  max-width: min(980px, 100%);
  padding: 1.5rem 1.75rem;
}

.auth-card.register-page .auth-card__header {
  margin-bottom: 1rem;
}

.auth-card.register-page .auth-card__icon {
  margin-bottom: .65rem;
}

.auth-card.register-page .auth-card__icon .app-brand-icon--lg {
  width: 3.75rem;
  height: 3.75rem;
}

.register-form__title {
  font-size: 1rem;
  font-weight: 700;
  margin: .5rem 0 .25rem;
}

.register-form__hint {
  font-size: .8125rem;
  color: var(--color-text-muted);
  margin-bottom: .75rem;
  line-height: 1.35;
}

.register-form--compact .form-group {
  margin-bottom: .65rem;
}

.register-form--compact .form-group label {
  margin-bottom: .2rem;
  font-size: .8125rem;
}

.register-form--compact .input {
  padding: .55rem .75rem;
  font-size: .875rem;
}

.register-form--compact .register-wizard__actions {
  margin-top: 0;
}

.register-wizard__panels {
  display: grid;
  align-items: stretch;
}

.register-wizard__panel {
  grid-area: 1 / 1;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  visibility: hidden;
  pointer-events: none;
}

.register-wizard__panel.is-active {
  visibility: visible;
  pointer-events: auto;
}

.register-wizard__panel-body {
  flex: 1 1 auto;
  min-height: 0;
}

.register-wizard__panel-footer {
  flex-shrink: 0;
  padding-top: 1rem;
}

.register-form--wizard-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100%;
}

.register-wizard__panel-footer .alert-error:not(.hidden) {
  margin-bottom: .65rem;
}

.register-wizard__panel-footer .auth-card__cta {
  margin-top: .85rem;
}

.register-wizard__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem .75rem;
  margin-bottom: .85rem;
}

.register-wizard__steps {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.register-wizard__step {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.register-wizard__step.is-current {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.register-wizard__step.is-done {
  color: var(--color-success, #16a34a);
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.08);
}

.register-wizard__step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.06);
}

.register-wizard__step.is-current .register-wizard__step-index {
  background: var(--color-primary);
  color: #fff;
}

.register-wizard__step.is-done .register-wizard__step-index {
  background: var(--color-success, #16a34a);
  color: #fff;
}

.register-wizard__plan-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .45rem;
  margin-left: auto;
  padding: .35rem .65rem;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: .72rem;
  line-height: 1.3;
  max-width: min(100%, 22rem);
}

.register-wizard__plan-chip-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.register-wizard__plan-chip strong {
  font-weight: 700;
}

.register-wizard__plan-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .65rem;
  margin-bottom: 1rem;
  padding: .75rem .9rem;
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: .875rem;
}

.register-wizard__plan-summary-label {
  color: var(--color-text-muted);
}

.register-wizard__actions {
  margin-top: 0;
}

.register-wizard__actions--split {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
}

.register-wizard__actions--split .btn-primary {
  flex: 1;
  min-width: 12rem;
}

.payment-picker {
  margin-top: .25rem;
}

.payment-picker__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .35rem;
}

.payment-picker__hint {
  font-size: .85rem;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}

.payment-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .65rem;
}

.payment-picker__option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
  text-align: left;
  padding: .85rem .9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.payment-picker__option:hover {
  border-color: var(--color-primary);
}

.payment-picker__option.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
  background: var(--color-primary-soft);
}

.payment-picker__label {
  font-size: .9rem;
  font-weight: 700;
}

.payment-picker__desc {
  font-size: .75rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

.payment-picker__option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
}

.payment-picker__soon {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--color-text-muted);
  background: var(--color-surface-muted, rgba(0, 0, 0, .06));
  padding: .15rem .4rem;
  border-radius: 999px;
  white-space: nowrap;
}

.payment-picker__option.is-disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.payment-picker__option.is-disabled:hover {
  border-color: var(--color-border);
}

.plan-card--selectable {
  cursor: pointer;
}

.plan-card--selectable:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.plan-picker { margin-bottom: 1rem; }

.plan-picker__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}

.plan-picker__title {
  font-size: 1rem;
  font-weight: 700;
}

.plan-picker__cycle {
  display: inline-flex;
  padding: .2rem;
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.plan-picker__cycle-btn {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: .8125rem;
  font-weight: 600;
  padding: .45rem .75rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.plan-picker__cycle-btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

.plan-picker__save {
  font-size: .68rem;
  font-weight: 700;
  opacity: .95;
}

.plan-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .85rem;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.plan-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.plan-card--trial.is-selected {
  border-color: var(--color-success, #16a34a);
  box-shadow: 0 0 0 1px var(--color-success, #16a34a);
}

.plan-card__badge {
  position: absolute;
  top: .65rem;
  right: .65rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .2rem .45rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
}

.plan-card__name {
  font-size: .95rem;
  font-weight: 700;
}

.plan-card__price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.plan-card__equiv {
  margin: .15rem 0 0;
  font-size: .78rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.plan-card__save {
  margin: .2rem 0 0;
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-success, #16a34a);
}

.plan-card__trial {
  font-size: .78rem;
  font-weight: 600;
  color: var(--color-success, #16a34a);
}

.plan-card__desc {
  font-size: .78rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  min-height: 2.4em;
}

.plan-card__limits {
  list-style: none;
  margin: .15rem 0 .35rem;
  padding: 0;
  font-size: .74rem;
  color: var(--color-text-muted);
}

.plan-card__limits li + li { margin-top: .15rem; }

.plan-picker--loading .plan-picker__loading-hint {
  margin: .75rem 0 0;
  text-align: center;
  font-size: .8125rem;
  color: var(--color-text-muted);
}

.plan-card--skeleton {
  pointer-events: none;
  border-color: var(--color-border);
  background: var(--color-surface);
}

.skeleton-block {
  border-radius: var(--radius-sm, 6px);
  background: linear-gradient(
    90deg,
    var(--color-border) 0%,
    color-mix(in srgb, var(--color-border) 55%, var(--color-surface)) 50%,
    var(--color-border) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-block--heading {
  width: 9rem;
  height: 1.25rem;
}

.skeleton-block--cycle {
  width: 11rem;
  height: 2rem;
  border-radius: 999px;
}

.skeleton-block--sm {
  width: 4.5rem;
  height: 1rem;
  margin-bottom: .65rem;
}

.skeleton-block--title {
  width: 70%;
  height: 1.1rem;
  margin-bottom: .5rem;
}

.skeleton-block--price {
  width: 45%;
  height: 1.35rem;
  margin-bottom: .65rem;
}

.skeleton-block--line {
  width: 100%;
  height: .65rem;
  margin-bottom: .4rem;
}

.skeleton-block--short {
  width: 75%;
}

.skeleton-block--btn {
  width: 100%;
  height: 2.25rem;
  margin-top: .75rem;
  border-radius: var(--radius);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.plan-card__action { margin-top: auto; }

.plan-picker__notice { margin-top: .85rem; font-size: .85rem; }

.subscription-current { margin-bottom: 1.25rem; }

.subscription-current__plan {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .2rem;
}

.subscription-current__price {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: .35rem;
}

.subscription-current__meta,
.subscription-current__trial,
.subscription-current__cancel {
  font-size: .85rem;
  color: var(--color-text-muted);
}

.subscription-current__cancel {
  color: var(--color-warning, #b45309);
  margin-top: .35rem;
}

.subscription-period {
  margin-top: 1rem;
}

.subscription-billing-details {
  display: grid;
  gap: .65rem;
  margin-top: 1rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface-muted, rgba(0, 0, 0, .03));
  border: 1px solid var(--color-border);
}

.subscription-billing-details div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: .85rem;
}

.subscription-billing-details dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.subscription-billing-details dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.subscription-usage-list {
  display: grid;
  gap: .75rem;
  margin-top: 1rem;
}

.subscription-usage__head {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  margin-bottom: .25rem;
}

.subscription-usage__track {
  height: .45rem;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.subscription-usage__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
}

@media (max-width: 640px) {
  .plan-picker__head { flex-direction: column; align-items: stretch; }
  .plan-picker__cycle { width: 100%; justify-content: stretch; }
  .plan-picker__cycle-btn { flex: 1; justify-content: center; }
}

.ack-contract {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--color-text);
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}

.form-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid--3 { grid-template-columns: 1fr; }
}

.form-field {
  margin-bottom: 1.125rem;
}

.form-field label {
  display: block;
  margin-bottom: .375rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-grid__full { grid-column: 1 / -1; }

.form-hint {
  margin-top: .375rem;
  font-size: .75rem;
  color: var(--color-text-muted);
}

@media (max-width: 540px) {
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 1.5rem; }
}

.auth-form { margin-bottom: 1.25rem; }

.auth-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  transition: opacity var(--transition);
}
.auth-link:hover { opacity: .85; text-decoration: underline; }
.auth-link-sm { font-size: .8125rem; font-weight: 500; }

.auth-forgot-row {
  margin: .375rem 0 0;
  text-align: right;
}

.auth-card__footer {
  text-align: center;
  font-size: .875rem;
  color: var(--color-text-muted);
}

.auth-card__footer--compact {
  margin-top: 1rem;
}

.auth-card__cta {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.auth-card__cta-label {
  margin: 0 0 .65rem;
  text-align: center;
  font-size: .875rem;
  color: var(--color-text-muted);
}

.auth-card__cta-hint {
  margin: .55rem 0 0;
  text-align: center;
  font-size: .78rem;
  color: var(--color-text-muted);
}

.auth-register-cta,
.auth-login-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 600;
}

.auth-attribution {
  flex-shrink: 0;
  margin: 0;
  padding: 0 1rem 1rem;
  text-align: center;
  font-size: .65rem;
  color: rgba(255, 255, 255, 0.55);
  z-index: 2;
}

.auth-attribution a {
  color: rgba(255, 255, 255, 0.72);
}

.locale-select {
  position: relative;
}

.locale-select__trigger {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-width: 8.5rem;
  justify-content: flex-start;
  text-align: left;
}

.locale-select__label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.locale-select__chev {
  font-size: .7rem;
  opacity: .65;
}

.locale-flag {
  display: block;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.locale-select__menu {
  position: absolute;
  top: calc(100% + .35rem);
  right: 0;
  min-width: 100%;
  margin: 0;
  padding: .35rem;
  list-style: none;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 40;
}

.locale-select__menu.hidden {
  display: none;
}

.locale-select__option {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .8125rem;
  padding: .45rem .55rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  text-align: left;
}

.locale-select__option:hover,
.locale-select__option.is-active {
  background: var(--color-primary-soft);
}

.topbar__locale-select .locale-select__trigger {
  min-width: 7.5rem;
}

@media (max-width: 720px) {
  .register-wizard__plan-chip {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius);
  }
}

@media (max-width: 960px) {
  .auth-slideshow__caption {
    bottom: 3.25rem;
    font-size: 1rem;
    max-width: calc(100% - 2rem);
  }

  .auth-slideshow__dots {
    bottom: 1.35rem;
  }

  .auth-page__body {
    padding: .75rem 1rem 1.25rem;
  }

  .auth-card {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4), var(--shadow-lg);
  }

  .auth-attribution {
    padding-bottom: .75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-slide {
    transition: none;
  }
}

/* ── DataGrid (Desktop) ────────────────────────────────────── */

.datagrid {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.datagrid-header, .datagrid-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border-bottom: 1px solid var(--color-border);
}
.datagrid-header {
  background: var(--color-bg-subtle);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}
.datagrid-row:hover { background: var(--color-bg-hover); }
.datagrid-row:last-child { border-bottom: none; }
.datagrid-cell { padding: .75rem 1rem; font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.datagrid-actions { display: flex; gap: .25rem; }
.datagrid-empty { padding: 2rem; text-align: center; color: var(--color-text-muted); grid-column: 1 / -1; }

.sortable { cursor: pointer; }
.sortable:hover { color: var(--color-primary); }

/* ── Card List (Mobile) ────────────────────────────────────── */

.card-list { display: flex; flex-direction: column; gap: .75rem; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow); border-color: var(--color-border-strong); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: .5rem; font-size: .8rem; color: var(--color-text-muted); }
.card-list-empty { text-align: center; padding: 2rem; color: var(--color-text-muted); }

/* ── Contracts list (Tabulator + cards) ───────────────────── */

.view-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.view-mode-switch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 0;
  transition: background .15s ease, color .15s ease;
}

.view-mode-switch__btn:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

.view-mode-switch__btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

.view-mode-switch__btn.is-active:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

/* Mobile first: cartões visíveis; grelha só se o utilizador escolher */
.contracts-cards-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.contracts-grid-panel {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.contracts-page[data-view="grid"] .contracts-cards-panel,
.clients-page[data-view="grid"] .contracts-cards-panel,
.users-page[data-view="grid"] .contracts-cards-panel { display: none; }
.contracts-page[data-view="grid"] .contracts-grid-panel,
.clients-page[data-view="grid"] .contracts-grid-panel,
.users-page[data-view="grid"] .contracts-grid-panel {
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .content-page-header__actions .view-mode-switch { display: none !important; }
  .contracts-cards-panel { display: none !important; }
  .contracts-grid-panel {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
  }
}

#contracts-tabulator,
#clients-tabulator,
#users-tabulator {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
}

.contracts-grid-panel .tabulator {
  height: 100%;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
}

.contracts-grid-panel .tabulator .tabulator-tableholder,
.client-contracts-grid-panel .tabulator .tabulator-tableholder {
  overflow-x: auto !important;
  overflow-y: auto !important;
}

.contract-card-list { display: flex; flex-direction: column; gap: .75rem; }

.contract-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.contract-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .75rem;
}

.contract-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: flex-end;
  flex-shrink: 0;
  align-items: center;
}

.contract-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.contract-card-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .35rem .75rem;
  margin: 0 0 .75rem;
  font-size: .8125rem;
  align-items: start;
}

.contract-card-meta dt {
  margin: 0;
  color: var(--color-text-muted);
  font-weight: 500;
}

.contract-card-meta dd {
  margin: 0;
  color: var(--color-text);
}

.contract-card-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: .5rem;
  border-top: 1px solid var(--color-border);
}

.tabulator {
  background: var(--color-surface);
  border: none;
  font-size: .875rem;
  color: var(--color-text);
}

.tabulator .tabulator-header {
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-weight: 600;
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--color-bg-hover);
  color: var(--color-primary);
}

.tabulator .tabulator-header .tabulator-col-content {
  padding: .5rem .75rem;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  min-height: 44px;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-row-even {
  background: var(--color-surface);
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover {
  background: var(--color-bg-hover);
}

.tabulator .tabulator-cell {
  border-right: 1px solid var(--color-border);
  padding: .5rem .75rem;
}

.tabulator .tabulator-cell.grid-person-cell {
  white-space: normal;
  line-height: 1.25;
  overflow: visible;
}

.grid-person,
.grid-person-list {
  display: flex;
  flex-direction: column;
  gap: .12rem;
  min-width: 0;
}

.grid-person.is-empty,
.grid-person-list.is-empty {
  color: var(--color-text-muted);
  font-size: .8125rem;
}

.grid-person__name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-text);
}

.grid-person__email {
  font-size: .75rem;
  color: var(--color-primary);
  word-break: break-all;
}

.grid-person__phone {
  font-size: .75rem;
  color: #0f766e;
}

[data-theme="dark"] .grid-person__phone {
  color: #5eead4;
}

.grid-person-list__name {
  font-size: .8125rem;
  color: var(--color-text);
}

.tabulator .tabulator-col.tabulator-frozen.tabulator-frozen-right,
.tabulator .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
  background: var(--color-surface);
  z-index: 11;
}

.tabulator .tabulator-header .tabulator-col.tabulator-frozen.tabulator-frozen-right {
  background: var(--color-bg-subtle);
  z-index: 12;
}

.tabulator .tabulator-col.tabulator-frozen.tabulator-frozen-right,
.tabulator .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
  box-shadow: -6px 0 10px -4px rgba(0, 0, 0, 0.12);
  border-left: 1px solid var(--color-border);
}

.tabulator .tabulator-row:hover .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
  background: var(--color-bg-hover);
}

.tabulator .tabulator-cell.tabulator-actions-col {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap;
  padding-left: .35rem;
  padding-right: .35rem;
}

.tabulator-actions-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
}

.tabulator-icon-btn {
  min-width: 2rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.tabulator-icon-btn svg {
  display: block;
}

.list-export {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.tabulator-print-fullscreen {
  background: #fff;
  color: #111;
  padding: 1.25rem;
}

.tabulator-print-fullscreen h1,
.tabulator-print-header h1 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  color: #111;
}

.list-print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.list-print-table th,
.list-print-table td {
  border: 1px solid #cbd5e1;
  padding: .35rem .5rem;
  text-align: left;
}

.list-print-table th {
  background: #f1f5f9;
}

@media print {
  .tabulator-print-fullscreen-hide > :not(.tabulator-print-fullscreen) {
    display: none !important;
  }
}

.tabulator .tabulator-footer {
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.tabulator .tabulator-footer .tabulator-page {
  color: var(--color-text);
}

.tabulator .tabulator-footer .tabulator-page.active {
  color: var(--color-primary);
  font-weight: 600;
}

.tabulator .tabulator-header-filter input,
.tabulator .tabulator-header-filter select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: .25rem .5rem;
  font-size: .8125rem;
  width: 100%;
}

.tabulator .tabulator-placeholder {
  color: var(--color-text-muted);
}

.tabulator .tabulator-alert {
  background: var(--color-surface);
  color: var(--color-text);
}

/* ── Badges ────────────────────────────────────────────────── */

.badge {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 999px; font-size: .72rem; font-weight: 600;
}
.badge-active { background: var(--color-success-soft); color: var(--color-success); }
.badge-inactive { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.badge-negotiation { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-review { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-cancelled { background: var(--color-danger-soft); color: var(--color-danger); }

/* ── Dashboard ─────────────────────────────────────────────── */

.dash-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.dash-page > .content-page-header { margin-bottom: 0; }

.dash-page > .page-body {
  display: flex;
  flex-direction: column;
  gap: .85rem;
  padding-bottom: 1.25rem;
}

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
}

.dash-kpi {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}

.dash-kpi__label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: .2rem;
}

.dash-kpi__value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.dash-kpi--warn .dash-kpi__value { color: var(--color-warning); }
.dash-kpi--info .dash-kpi__value { color: var(--color-primary); }
.dash-kpi--danger .dash-kpi__value { color: var(--color-danger); }

.dash-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.dash-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .85rem;
}

.dash-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-card__hint {
  margin: .25rem 0 0;
  font-size: .8125rem;
  color: var(--color-text-muted);
}

.dash-empty {
  margin: 0;
  color: var(--color-text-muted);
  font-size: .875rem;
}

.dash-portfolio__hero {
  margin: 0;
  text-align: right;
}

.dash-portfolio__hero-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.dash-portfolio__hero-row .dash-portfolio__hero {
  text-align: left;
  padding: .75rem .875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--transition);
}

.dash-portfolio__hero-row .dash-portfolio__hero:hover {
  border-color: var(--color-primary);
}

.dash-portfolio__hero--revenue {
  background: var(--color-success-soft);
  border-color: rgba(34, 197, 94, 0.3);
}

.dash-portfolio__hero--cost {
  background: var(--color-warning-soft);
  border-color: rgba(217, 119, 6, 0.3);
}

.dash-portfolio__hero--revenue .dash-portfolio__hero-value { color: var(--color-success); }
.dash-portfolio__hero--cost .dash-portfolio__hero-value { color: var(--color-warning); }

.dash-nature {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .15rem .4rem;
  border-radius: 4px;
}

.dash-nature--provided {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.dash-nature--received {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.dash-risk-row__value--revenue { color: var(--color-success); }
.dash-risk-row__value--cost { color: var(--color-warning); }

.dash-window__split {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .5rem;
  margin-top: .25rem;
  font-size: .72rem;
  font-weight: 600;
}

.dash-window__part--revenue { color: var(--color-success); }
.dash-window__part--cost { color: var(--color-warning); }

.dash-bars__amounts {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .5rem;
  font-size: .75rem;
  font-weight: 600;
}

.dash-bars__amount--revenue { color: var(--color-success); }
.dash-bars__amount--cost { color: var(--color-warning); }

.dash-portfolio__hero-label {
  display: block;
  font-size: .75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.dash-portfolio__hero-value {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.dash-card__head--portfolio {
  margin-bottom: .5rem;
}

.dash-portfolio-subs {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.dash-portfolio-sub {
  padding: 1.125rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}

.dash-portfolio-sub--revenue {
  border-color: rgba(34, 197, 94, 0.25);
}

.dash-portfolio-sub--cost {
  border-color: rgba(217, 119, 6, 0.25);
}

.dash-portfolio-sub__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.dash-portfolio-sub__title {
  margin: 0 0 .25rem;
  font-size: 1rem;
  font-weight: 700;
}

.dash-portfolio-sub--revenue .dash-portfolio-sub__title { color: var(--color-success); }
.dash-portfolio-sub--cost .dash-portfolio-sub__title { color: var(--color-warning); }

.dash-portfolio-sub__hint {
  margin: 0;
  font-size: .8125rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  max-width: 36rem;
}

.dash-portfolio-sub__total {
  text-align: right;
  padding: .5rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-width: 9rem;
}

.dash-portfolio-sub--revenue .dash-portfolio-sub__total {
  border-color: rgba(34, 197, 94, 0.3);
  background: var(--color-success-soft);
}

.dash-portfolio-sub--cost .dash-portfolio-sub__total {
  border-color: rgba(217, 119, 6, 0.3);
  background: var(--color-warning-soft);
}

.dash-portfolio-sub__total-label {
  display: block;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

.dash-portfolio-sub__total-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-portfolio-sub--revenue .dash-portfolio-sub__total-value { color: var(--color-success); }
.dash-portfolio-sub--cost .dash-portfolio-sub__total-value { color: var(--color-warning); }

.dash-portfolio-sub .dash-bar {
  margin-bottom: .45rem;
}

.dash-bar--revenue { background: rgba(34, 197, 94, 0.1); }
.dash-bar--cost { background: rgba(217, 119, 6, 0.1); }

.dash-portfolio-sub .dash-bar__legend {
  margin-bottom: .85rem;
}

.dash-portfolio-sub .dash-windows {
  margin-top: 0;
}

.dash-portfolio-sub__notes {
  margin-top: .75rem;
  font-size: .8125rem;
  color: var(--color-text-muted);
}

.dash-portfolio-sub__notes p { margin: .25rem 0 0; }

.dash-bar {
  display: flex;
  height: .65rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--color-bg-subtle);
}

.dash-bar__seg { height: 100%; min-width: 0; flex: 0 1 0; }
.dash-bar__seg--visible { min-width: 4px; }
.dash-bar__seg--15 { background: var(--color-danger); }
.dash-bar__seg--30 { background: #fb923c; }
.dash-bar__seg--60 { background: #facc15; }
.dash-bar__seg--stable { background: var(--color-success); }

/* Tomado: verde = poupança breve → vermelho = compromisso longo */
.dash-bar__seg--save-15 { background: var(--color-success); }
.dash-bar__seg--save-30 { background: #86efac; }
.dash-bar__seg--save-60 { background: #facc15; }
.dash-bar__seg--save-stable { background: #ea580c; }

.dash-bar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  font-size: .75rem;
  color: var(--color-text-muted);
}

.dash-dot {
  display: inline-block;
  width: .55rem;
  height: .55rem;
  border-radius: 999px;
  margin-right: .35rem;
  vertical-align: middle;
}
.dash-dot--15 { background: var(--color-danger); }
.dash-dot--30 { background: #fb923c; }
.dash-dot--60 { background: #facc15; }
.dash-dot--stable { background: var(--color-success); }
.dash-dot--save-15 { background: var(--color-success); }
.dash-dot--save-30 { background: #86efac; }
.dash-dot--save-60 { background: #facc15; }
.dash-dot--save-stable { background: #ea580c; }

.dash-windows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}

.dash-window {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .75rem .85rem;
  background: var(--color-bg-subtle);
  text-align: left;
  font: inherit;
  color: inherit;
}

.dash-window__label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.dash-window__value {
  display: block;
  font-size: 1.05rem;
  margin: .15rem 0;
}

.dash-window__value--stack {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dash-window__cur {
  display: block;
  font-size: 0.95rem;
  line-height: 1.25;
}

.dash-card__hint--bar {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  opacity: 0.85;
}

.dash-window__meta {
  display: block;
  font-size: .72rem;
  color: var(--color-text-muted);
}

.dash-window__value--revenue { color: var(--color-success); }
.dash-window__value--cost { color: var(--color-warning); }

.dash-window--stable { background: var(--color-success-soft); }
.dash-window--stable-revenue { background: var(--color-success-soft); }
.dash-window--stable-cost { background: var(--color-warning-soft); }

.dash-portfolio__notes {
  margin-top: .85rem;
  font-size: .8125rem;
  color: var(--color-text-muted);
}
.dash-portfolio__notes p { margin: .25rem 0; }

.dash-split {
  display: grid;
  gap: .85rem;
}

.dash-risk__list { min-width: 0; }

.dash-risk__body { min-width: 0; }

.dash-risk-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1.4fr) minmax(5rem, 1fr) minmax(5rem, .75fr) minmax(5.5rem, .85fr) minmax(5rem, 1fr);
  gap: .35rem .65rem;
  align-items: center;
  width: 100%;
  padding: .45rem .25rem;
  border: none;
  border-top: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  min-height: 2.55rem;
}

.dash-risk-row:first-child { border-top: none; }

.dash-risk-row__title strong {
  display: block;
  font-size: .8125rem;
  line-height: 1.25;
}

.dash-risk-row__title small {
  display: block;
  font-size: .68rem;
  color: var(--color-text-muted);
}

.dash-risk-row__value,
.dash-risk-row__date {
  font-size: .8125rem;
  text-align: right;
}

.dash-risk-row__value small {
  display: block;
  font-size: .68rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.dash-risk-row__date small {
  display: block;
  font-size: .68rem;
  color: var(--color-text-muted);
}

.dash-risk-row__client,
.dash-risk-row__who {
  font-size: .8125rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-risk-row.is-urgent .dash-risk-row__date small { color: var(--color-danger); font-weight: 600; }
.dash-risk-row.is-soon .dash-risk-row__date small { color: var(--color-warning); }
.dash-risk-row.is-clickable:hover { background: var(--color-primary-soft); }

.dash-risk-row--head {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: .35rem .25rem .45rem;
  min-height: 0;
  border-top: 0;
}

.dash-risk__pager { margin-top: .5rem; }

.dash-bars {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.dash-bars__row {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}

.dash-bars__meta {
  display: flex;
  justify-content: space-between;
  font-size: .8125rem;
  margin-bottom: .25rem;
}

.dash-bars__track {
  height: .45rem;
  background: var(--color-bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.dash-bars__fill {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
}

.dash-chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.dash-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: .35rem .65rem;
  background: var(--color-surface);
  font: inherit;
  font-size: .8125rem;
}

.dash-chip--muted { opacity: .75; }

.dash-chip__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .3rem;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: .72rem;
  font-weight: 700;
}

@media (max-width: 639px) {
  .dash-portfolio__hero { text-align: left; width: 100%; }
  .dash-portfolio__hero-row { grid-template-columns: 1fr; }
  .dash-kpi--danger { grid-column: 1 / -1; }

  .dash-risk-row {
    grid-template-columns: 1fr 1fr;
    gap: .25rem .5rem;
    padding: .65rem .15rem;
  }

  .dash-risk-row--head { display: none; }

  .dash-risk-row__client::before,
  .dash-risk-row__value::before,
  .dash-risk-row__date::before,
  .dash-risk-row__who::before {
    content: attr(data-label) ': ';
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: .68rem;
  }

  .dash-risk-row__title { grid-column: 1 / -1; }
}

@media (min-width: 640px) {
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-windows { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dash-kpi__value { font-size: 1.7rem; }
}

@media (min-width: 900px) {
  .dash-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .dash-split { grid-template-columns: 1.1fr .9fr; align-items: start; }
  .dash-card { padding: 1.15rem 1.25rem 1.3rem; }
  .dash-risk__body { min-height: calc(10 * 3.05rem); }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-label { display: block; font-size: .8rem; color: var(--color-text-muted); margin-bottom: .25rem; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.stat-warning .stat-value { color: var(--color-warning); }

.dashboard-section h2 { font-size: 1.1rem; margin-bottom: 1rem; font-weight: 600; }
.chart-placeholder {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  height: 240px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
}

/* ── Alerts ────────────────────────────────────────────────── */

.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}
.alert-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border: 1px solid rgba(220, 38, 38, 0.25);
}

[data-theme="dark"] .alert-error {
  background: #991b1b;
  color: #ffffff;
  border-color: #b91c1c;
}

.alert-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.alerts-tabs {
  display: flex;
  gap: .375rem;
  margin-bottom: 1.25rem;
  max-width: 28rem;
}

[data-alerts-panel][hidden] { display: none !important; }

.alerts-test-card {
  max-width: 36rem;
}

.alerts-test-form {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.alerts-test-form .btn {
  align-self: flex-start;
  margin-top: .5rem;
}

.hidden { display: none !important; }

/* ── User ──────────────────────────────────────────────────── */

.user-info { font-size: .8rem; color: var(--color-text-muted); }

/* ── Contract Wizard ───────────────────────────────────────── */

.wizard-page {
  max-width: none;
  margin: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.wizard-header {
  margin-bottom: 1.25rem;
}

.wizard-back-link {
  margin-bottom: .5rem;
  padding-left: 0;
}

.wizard-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.wizard-stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .5rem;
  margin-bottom: 1.25rem;
  padding: 0;
  flex-shrink: 0;
}

.wizard-stepper__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  text-align: center;
  position: relative;
}

.wizard-stepper__item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 1.125rem;
  left: calc(50% + 1.25rem);
  width: calc(100% - 1.5rem);
  height: 2px;
  background: var(--color-border);
  z-index: 0;
}

.wizard-stepper__item.is-done:not(:last-child)::after,
.wizard-stepper__item.is-active:not(:last-child)::after {
  background: var(--color-primary);
  opacity: .35;
}

.wizard-stepper__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--color-bg-subtle);
  border: 2px solid var(--color-border);
  position: relative;
  z-index: 1;
  transition: all var(--transition);
}

.wizard-stepper__item.is-active .wizard-stepper__icon {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-soft);
}

.wizard-stepper__item.is-done .wizard-stepper__icon {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
}

.wizard-stepper__label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--color-text-muted);
  line-height: 1.2;
  max-width: 4.25rem;
}

.wizard-stepper__item.is-active .wizard-stepper__label {
  color: var(--color-primary);
}

.wizard-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.wizard-panel__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: .375rem;
  letter-spacing: -0.02em;
}

.wizard-panel__hint {
  color: var(--color-text-muted);
  font-size: .875rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.field-required-badge {
  display: inline-block;
  margin-left: .35rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .12rem .4rem;
  border-radius: 4px;
  background: var(--color-warning-soft);
  color: var(--color-warning);
  vertical-align: middle;
}

.wizard-suggestions {
  margin: 0 0 1.5rem;
  padding: .875rem 1rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.wizard-suggestions__title {
  margin: 0 0 .25rem;
  font-size: .875rem;
  font-weight: 700;
}

.wizard-suggestions .form-hint {
  margin: 0 0 .75rem;
}

.wizard-suggestions__list {
  list-style: none;
  margin: 0 0 .875rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.wizard-suggestions__row {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr auto;
  gap: .5rem .75rem;
  align-items: start;
  font-size: .78rem;
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
}

.wizard-suggestions__label {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  font-weight: 600;
  cursor: pointer;
}

.wizard-suggestions__value {
  color: var(--color-text-muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.wizard-suggestions__conf {
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.wizard-suggestions__conf.is-high { color: var(--color-success); }
.wizard-suggestions__conf.is-mid { color: #facc15; }
.wizard-suggestions__conf.is-low { color: var(--color-danger); }

.wizard-suggestions__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.wizard-suggestions-empty { margin-bottom: 1.25rem; }

.wizard-class-lookups .form-group { margin-bottom: 1rem; }

@media (max-width: 720px) {
  .wizard-suggestions__row {
    grid-template-columns: 1fr auto;
  }
  .wizard-suggestions__value { grid-column: 1 / -1; }
}

.wizard-autocomplete { position: relative; }

.wizard-autocomplete__wrap { position: relative; }

.wizard-field-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

.wizard-field-icon--inline { top: 50%; }

.wizard-input-icon { padding-left: 2.5rem !important; }

.wizard-autocomplete__list {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
}

.wizard-autocomplete__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: .625rem .875rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.wizard-autocomplete__item:last-child { border-bottom: none; }
.wizard-autocomplete__item:hover { background: var(--color-bg-hover); }
.wizard-autocomplete__item small { color: var(--color-text-muted); font-size: .75rem; }

.wizard-value-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  align-items: center;
}

.wizard-value-row__input-wrap {
  position: relative;
  min-width: 0;
}

.wizard-value-row__input-wrap .wizard-field-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
}

.wizard-value-row__input-wrap .wizard-input-icon {
  width: 100%;
  padding-left: 2.5rem !important;
}

.wizard-value-row .wizard-currency-select {
  grid-column: 2;
  grid-row: 1;
}

.wizard-currency-select {
  width: auto;
  min-width: 7.5rem;
  font-weight: 600;
}

.wizard-dates .form-group { margin-bottom: 1rem; }

.wizard-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}

.wizard-pill {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem .875rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: all var(--transition);
  user-select: none;
}

.wizard-pill input { display: none; }

.wizard-pill.is-checked {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.wizard-custom-days {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.wizard-pill--custom { flex-shrink: 0; }

.wizard-custom-days .input-sm {
  width: 5rem;
}

.wizard-chip-group {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.wizard-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .625rem .875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all var(--transition);
}

.wizard-chip:hover { border-color: var(--color-border-strong); background: var(--color-bg-hover); }

.wizard-chip.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.wizard-chip__avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-chip__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.wizard-chip__text strong {
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wizard-chip__text small {
  font-size: .75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wizard-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}

.wizard-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: 1.25rem .75rem;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  min-height: 120px;
}

.wizard-upload-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.wizard-upload-card.is-selected {
  border-color: var(--color-primary);
  border-style: solid;
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.wizard-upload-card__icon { font-size: 1.75rem; }

.wizard-upload-card strong { font-size: .875rem; }
.wizard-upload-card small { font-size: .75rem; color: var(--color-text-muted); }

.document-pending {
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}

.document-pending__file {
  margin: 0 0 .75rem;
  font-size: .875rem;
}

.document-pending__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}

.document-kind-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin: 0 0 1rem;
}

.document-kind-grid .wizard-upload-card {
  text-align: center;
  cursor: pointer;
  border-style: solid;
  font: inherit;
  color: inherit;
  width: 100%;
  background: var(--color-surface);
}

.document-history {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.document-history__item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: .875rem 1rem;
  background: var(--color-bg);
}

.document-history__item.is-active {
  border-color: var(--color-success);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-success) 45%, transparent);
}

.document-history__item.is-annulled {
  opacity: .72;
}

.document-history__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
}

.document-history__title {
  margin: 0;
  font-size: .9375rem;
  font-weight: 700;
}

.document-history__meta {
  margin: .3rem 0 0;
  font-size: .8rem;
  color: var(--color-text-muted);
}

.document-history__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .75rem;
}

@media (max-width: 640px) {
  .document-kind-grid { grid-template-columns: 1fr; }
}

body.doc-wizard-open { overflow: hidden; }

.doc-wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 2050;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem 1rem 2rem;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .doc-wizard-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.doc-wizard {
  position: relative;
  width: min(36rem, 100%);
  margin: auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
}

.doc-wizard__loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2rem 1.5rem;
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  text-align: center;
}

.doc-wizard__loading-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.doc-wizard__loading-hint {
  margin: 0;
  font-size: .875rem;
  color: var(--color-text-muted);
}

.doc-wizard__header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.doc-wizard__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.doc-wizard__file {
  margin: .35rem 0 1rem;
  font-size: .8125rem;
  color: var(--color-text-muted);
  word-break: break-all;
}

.doc-wizard__steps {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin: 0;
  padding: 0;
}

.doc-wizard__step {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.doc-wizard__step span {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  font-size: .75rem;
}

.doc-wizard__step.is-active { color: var(--color-primary); }
.doc-wizard__step.is-active span {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.doc-wizard__step.is-done span {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
}

.doc-wizard__body {
  padding: 1.25rem 1.5rem;
}

.doc-wizard__hint {
  margin: 0 0 1rem;
  font-size: .875rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.doc-wizard__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

.doc-wizard__footer-end {
  display: flex;
  gap: .5rem;
  margin-left: auto;
}

.input.is-changed {
  border-color: var(--color-warning);
  background: var(--color-warning-soft);
  box-shadow: 0 0 0 1px var(--color-warning);
}

.form-hint--changed {
  color: var(--color-warning);
  font-weight: 600;
}

.doc-record__header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.doc-record {
  margin: 0;
}

.doc-record__row {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: .5rem 1rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--color-border);
}

.doc-record__row:last-child { border-bottom: none; }

.doc-record__row dt {
  margin: 0;
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

.doc-record__row dd {
  margin: 0;
  font-size: .9375rem;
  overflow-wrap: anywhere;
}

.doc-record__notes {
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
}

@media (max-width: 640px) {
  .doc-record__row { grid-template-columns: 1fr; }
}

.wizard-doc-result {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  overflow: hidden;
}

.wizard-doc-preview {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.wizard-doc-preview--file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  background: var(--color-primary-soft);
  overflow: hidden;
}

.wizard-doc-preview--pdf {
  background: var(--color-primary-soft);
}

.wizard-doc-preview__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.wizard-doc-preview__type {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.wizard-doc-meta {
  flex: 1;
  min-width: 0;
}

.wizard-doc-name {
  font-size: .9rem;
  font-weight: 600;
  margin: 0 0 .375rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.wizard-doc-meta strong { display: block; margin-bottom: .25rem; word-break: break-all; }

.wizard-status {
  display: inline-block;
  font-size: .75rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: .25rem;
}

.wizard-summary {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.wizard-summary__row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: .75rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--color-border);
}

.wizard-summary__row:last-child { border-bottom: none; padding-bottom: 0; }

.wizard-summary__row dt {
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.wizard-summary__row dd {
  font-size: .9rem;
  font-weight: 500;
  margin: 0;
}

.wizard-tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .15rem .4rem;
  border-radius: 4px;
  background: var(--color-warning-soft);
  color: var(--color-warning);
  vertical-align: middle;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  position: static;
  padding: 1rem 2rem;
}

@media (max-width: 640px) {
  .wizard-page { padding-bottom: 1rem; }
  .wizard-card { padding: 1.125rem; border-radius: var(--radius); }
  .wizard-stepper__label { font-size: .62rem; max-width: 3.5rem; }
  .wizard-stepper__icon { width: 2rem; height: 2rem; font-size: .9rem; }
  .wizard-upload-grid { grid-template-columns: 1fr; }
  .wizard-value-row { grid-template-columns: 1fr; }
  .wizard-currency-select { width: 100%; }
  .wizard-summary__row { grid-template-columns: 1fr; gap: .25rem; }
  .wizard-doc-result { flex-direction: column; align-items: stretch; }
  .wizard-doc-preview { align-self: center; }
  .wizard-actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: .875rem 1.25rem calc(.875rem + env(safe-area-inset-bottom, 0));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 80;
    margin: 0;
  }
  .wizard-page { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0)); }
}

@media (max-width: 380px) {
  .wizard-stepper__label { display: none; }
  .wizard-stepper { gap: .25rem; }
}

/* ── Contract Edit (tabs) ──────────────────────────────────── */

.contract-edit-page {
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 2rem;
}

.contract-edit-header {
  margin-bottom: 1rem;
}

.contract-edit-header__main {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.contract-edit-header__title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}

.contract-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .375rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.contract-tabs__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: .625rem .375rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: .68rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: all var(--transition);
  min-height: 3.25rem;
}

.contract-tabs__btn:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.contract-tabs__btn.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.contract-tabs__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.contract-tabs__label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-edit-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
  position: relative;
}

.contract-edit-card__overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  border-radius: inherit;
}

.contract-edit-card__overlay.is-visible {
  display: flex;
}

.edit-panel__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.edit-panel__hint {
  color: var(--color-text-muted);
  font-size: .8125rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.form-field .edit-panel__hint,
.avatar-field__actions .edit-panel__hint {
  margin: .375rem 0 0;
}

.form-grid + .edit-panel__hint,
.edit-form > .edit-panel__hint {
  margin-top: .75rem;
  margin-bottom: 0;
}

.edit-notes {
  resize: vertical;
  min-height: 4.5rem;
}

.edit-panel--fill,
.edit-panel__scroll--column {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.form-group--fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.edit-notes--fill {
  flex: 1;
  min-height: 6rem;
  resize: none;
}

.lookup-field__input { width: 100%; }

.lookup-field .wizard-autocomplete__wrap {
  position: relative;
}

.lookup-field__badge {
  position: absolute;
  right: .625rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.lookup-field__input {
  padding-right: 4.25rem !important;
}

.edit-subform {
  margin: 1.25rem 0;
  padding: 1rem 1.125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
}

.edit-subform__title {
  font-size: .9375rem;
  font-weight: 700;
  margin: 0 0 .25rem;
}

.edit-subform__hint {
  font-size: .8125rem;
  color: var(--color-text-muted);
  margin: 0 0 .875rem;
  line-height: 1.45;
}

.contract-nature__panel {
  padding: .875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: background .2s ease, border-color .2s ease;
}

.contract-nature__panel--provided {
  background: var(--color-success-soft);
  border-color: rgba(34, 197, 94, 0.35);
}

.contract-nature__panel--received {
  background: var(--color-warning-soft);
  border-color: rgba(217, 119, 6, 0.35);
}

.contract-nature__panel.is-disabled { opacity: .65; }

.contract-nature__toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.contract-nature__btn {
  padding: .625rem .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-text-muted);
}

.contract-nature__btn--provided.is-active {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.contract-nature__btn--received.is-active {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #fff;
}

.contract-nature__hint {
  margin: .625rem 0 0;
  font-size: .75rem;
  color: var(--color-text-muted);
  line-height: 1.45;
}

.wizard-panel--scroll {
  min-height: 0;
}

.wizard-page .wizard-notes {
  min-height: 5rem;
  resize: vertical;
}

.form-grid__full { grid-column: 1 / -1; }

.contract-edit-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .75rem;
  position: sticky;
  bottom: 0;
  padding: .75rem 0;
  background: linear-gradient(transparent, var(--color-bg) 25%);
}

@media (max-width: 768px) {
  .contract-tabs__label { display: none; }
  .contract-tabs__btn {
    min-height: 2.75rem;
    padding: .5rem .25rem;
  }
  .contract-tabs__icon { font-size: 1.25rem; }
}

@media (max-width: 640px) {
  .contract-edit-card { padding: 1.125rem; border-radius: var(--radius); }
  .contract-edit-actions {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom, 0));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 80;
    justify-content: space-between;
  }
  .contract-edit-page {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0));
  }
}

/* ── Edit pages (flex layout) ────────────────────────────────── */

.edit-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.contract-edit-page {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
}

.contract-edit-page .contract-edit-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contract-edit-page .contract-edit-card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.contract-edit-page .edit-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.contract-edit-page > .profile-tabs,
.contract-edit-page > .settings-tabs,
.contract-edit-page > .alert,
.contract-edit-page > .edit-page-footer {
  flex-shrink: 0;
}

.contract-edit-page .edit-panel__scroll {
  -webkit-overflow-scrolling: touch;
}

.edit-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.edit-panel__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.client-edit-page .contract-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 28rem;
}

.client-contracts-panel__status {
  margin: 0 0 .5rem;
}

.client-contracts-tab {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.client-contracts-tab__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
  flex-shrink: 0;
}

.client-contracts-tab__intro {
  flex: 1;
  min-width: 12rem;
}

.client-contracts-tab__intro .edit-panel__title {
  margin-bottom: .25rem;
}

.client-contracts-tab__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.client-contracts-cards-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: .25rem 0;
}

.client-contracts-grid-panel {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.client-contracts-tab[data-view="grid"] .client-contracts-cards-panel {
  display: none;
}

.client-contracts-tab[data-view="grid"] .client-contracts-grid-panel {
  display: flex;
  flex-direction: column;
}

.client-contracts-tab[data-view="cards"] .client-contracts-grid-panel {
  display: none;
}

.client-contracts-tab[data-view="cards"] .client-contracts-cards-panel {
  display: block;
}

#client-contracts-tabulator {
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
}

.client-contracts-grid-panel .tabulator {
  height: 100%;
  max-width: 100%;
  width: 100%;
  border: none;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .client-contracts-tab .view-mode-switch {
    display: none;
  }

  .client-contracts-tab[data-view="grid"] .client-contracts-cards-panel,
  .client-contracts-tab[data-view="cards"] .client-contracts-cards-panel {
    display: none !important;
  }

  .client-contracts-tab .client-contracts-grid-panel {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
  }
}

/* ── User avatar ───────────────────────────────────────────── */

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  overflow: hidden;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 700;
  flex-shrink: 0;
  vertical-align: middle;
}

.user-avatar--sm { width: 2rem; height: 2rem; font-size: .68rem; }
.user-avatar--md { width: 2.5rem; height: 2.5rem; font-size: .78rem; }
.user-avatar--lg { width: 3.25rem; height: 3.25rem; font-size: .95rem; }

.user-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-avatar__initials {
  line-height: 1;
  letter-spacing: .02em;
}

.tabulator-avatar-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── User menu (topbar) ────────────────────────────────────── */

.user-menu {
  position: relative;
  flex-shrink: 0;
}

.user-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .125rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.user-menu__trigger:hover {
  border-color: var(--color-border-strong);
  background: var(--color-bg-hover);
}

.user-menu__chevron {
  font-size: .7rem;
  color: var(--color-text-muted);
  padding-right: .35rem;
}

.user-menu-popover {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  z-index: 120;
  width: min(18rem, calc(100vw - 1.5rem));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.user-menu-popover__header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.user-menu-popover__identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .125rem;
}

.user-menu-popover__name {
  font-size: .9375rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-popover__email {
  font-size: .78rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-popover__role {
  font-size: .72rem;
  color: var(--color-text-muted);
}

.user-menu-popover__section,
.user-menu-popover__footer {
  padding: .375rem;
}

.user-menu-popover__footer {
  border-top: 1px solid var(--color-border);
}

.user-menu-popover__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  padding: .55rem .65rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: .875rem;
  text-align: left;
  cursor: pointer;
}

.user-menu-popover__item:hover {
  background: var(--color-bg-hover);
}

.user-menu-popover__item--danger {
  color: var(--color-danger);
}

.user-menu-popover__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .35rem;
  border-radius: 999px;
  background: var(--color-danger);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
}

/* ── Profile page ────────────────────────────────────────────── */

.profile-page .profile-tabs {
  display: flex;
  gap: .375rem;
  margin-bottom: 1rem;
  max-width: 24rem;
}

.profile-tabs__btn {
  flex: 1;
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-tabs__btn.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.profile-card {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.profile-panel__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.avatar-field {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.avatar-field__preview-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar-field__busy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-surface) 55%, transparent);
  color: var(--color-text);
}

.avatar-field__busy[hidden] {
  display: none;
}

.avatar-field__spinner {
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.avatar-field__busy-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.avatar-field.is-uploading .avatar-field__upload {
  pointer-events: none;
  opacity: .55;
}

.avatar-field__error {
  margin: 0;
  font-size: .8rem;
  color: var(--color-danger, #dc2626);
}

.avatar-field__actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.avatar-field__upload {
  cursor: pointer;
}

.contract-card-header--with-avatar {
  align-items: center;
  gap: .75rem;
}

.contract-card-header__text {
  min-width: 0;
  flex: 1;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Document analyze overlay (OCR) ────────────────────────── */

.doc-analyze-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(2px);
  border-radius: inherit;
}

.doc-analyze-overlay.is-visible {
  display: flex;
}

.doc-analyze-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem 2.5rem;
  max-width: 24rem;
}

.doc-analyze-overlay__spinner {
  width: 3.25rem;
  height: 3.25rem;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.doc-analyze-overlay__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.45;
  margin: 0;
  letter-spacing: -0.02em;
}

.doc-analyze-overlay__phase {
  font-size: .875rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Document viewer modal ─────────────────────────────────── */

body.doc-viewer-open {
  overflow: hidden;
}

.doc-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: doc-viewer-fade-in .2s ease;
}

[data-theme="dark"] .doc-viewer-overlay {
  background: rgba(0, 0, 0, 0.72);
}

@keyframes doc-viewer-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.doc-viewer {
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: min(88vh, 900px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: doc-viewer-slide-in .22s ease;
}

@keyframes doc-viewer-slide-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.doc-viewer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-hover);
  flex-shrink: 0;
}

.doc-viewer__toolbar-group {
  display: flex;
  align-items: center;
  gap: .375rem;
  min-width: 0;
}

.doc-viewer__toolbar-group--start {
  flex: 1 1 30%;
}

.doc-viewer__toolbar-group--center {
  flex: 0 1 auto;
  justify-content: center;
  flex-wrap: wrap;
}

.doc-viewer__toolbar-group--end {
  flex: 1 1 30%;
  justify-content: flex-end;
}

.doc-viewer__filename {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-viewer__zoom-label {
  min-width: 3.25rem;
  text-align: center;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.doc-viewer__btn-icon {
  min-width: 2.25rem;
  font-size: 1.125rem;
  line-height: 1;
  padding-inline: .5rem;
}

.doc-viewer__viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(45deg, var(--color-bg-subtle) 25%, transparent 25%),
    linear-gradient(-45deg, var(--color-bg-subtle) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--color-bg-subtle) 75%),
    linear-gradient(-45deg, transparent 75%, var(--color-bg-subtle) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: var(--color-bg);
}

.doc-viewer__loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  color: var(--color-text-muted);
  text-align: center;
}

.doc-viewer__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.doc-viewer__zoom-host {
  margin: 0 auto;
  min-width: min-content;
}

.doc-viewer__stage {
  display: inline-flex;
  justify-content: center;
  align-items: flex-start;
  transform-origin: top left;
  transform: scale(var(--doc-viewer-zoom, 1));
  transition: transform .12s ease;
}

.doc-viewer__pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.doc-viewer__page {
  display: block;
  max-width: none;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
}

.doc-viewer__image {
  display: block;
  max-width: none;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
}

.doc-viewer__iframe {
  width: min(920px, 100%);
  height: calc(88vh - 5rem);
  border: none;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow);
}

.doc-viewer--wide {
  width: min(1280px, 100%);
}

.doc-viewer__sheet {
  min-width: 720px;
  max-width: none;
  padding: 1.25rem 1.35rem 1.5rem;
  background: #fff;
  color: #0f172a;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.doc-viewer__sheet-head {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .85rem;
}

.doc-viewer__sheet-head--logo .doc-viewer__sheet-sub {
  margin-bottom: 0;
}

.doc-viewer__sheet-logo {
  width: 84px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.doc-viewer__sheet-head-text {
  min-width: 0;
}

.doc-viewer__sheet-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #4f46e5;
  margin-bottom: .2rem;
}

.doc-viewer__sheet-sub {
  font-size: .78rem;
  color: #64748b;
  margin-bottom: .85rem;
}

.doc-viewer__sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}

.doc-viewer__sheet-table th,
.doc-viewer__sheet-table td {
  border: 1px solid #e2e8f0;
  padding: .4rem .55rem;
  text-align: left;
  vertical-align: middle;
  white-space: normal;
  max-width: 16rem;
}

.doc-viewer__sheet-table th {
  background: #4f46e5;
  color: #fff;
  font-weight: 700;
}

.doc-viewer__sheet-table tbody tr:nth-child(even) td:not([style*="background"]) {
  background: #f8fafc;
}

@media (max-width: 768px) {
  .doc-viewer-overlay { padding: .5rem; }
  .doc-viewer { height: 92vh; border-radius: var(--radius); }
  .doc-viewer__toolbar {
    flex-wrap: wrap;
    padding: .625rem .75rem;
  }
  .doc-viewer__toolbar-group--start,
  .doc-viewer__toolbar-group--center,
  .doc-viewer__toolbar-group--end {
    flex: 1 1 100%;
    justify-content: center;
  }
  .doc-viewer__toolbar-group--start { order: -1; }
  .doc-viewer__toolbar-group--end .btn-primary { flex: 1; }
}

/* ── Confirm dialog ────────────────────────────────────────── */

body.confirm-dialog-open {
  overflow: hidden;
}

.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: doc-viewer-fade-in .2s ease;
}

[data-theme="dark"] .confirm-dialog-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.confirm-dialog {
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem 1.5rem 1.25rem;
  animation: doc-viewer-slide-in .22s ease;
}

.confirm-dialog__icon {
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  margin-bottom: 1rem;
}

.confirm-dialog__title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.confirm-dialog__message {
  color: var(--color-text-muted);
  font-size: .875rem;
  line-height: 1.55;
  margin: 0 0 1.25rem;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .confirm-dialog__actions {
    flex-direction: column-reverse;
  }
  .confirm-dialog__actions .btn {
    width: 100%;
  }
}

/* ── Operation loading & success modal ─────────────────────── */

body.operation-overlay-open,
body.success-modal-open {
  overflow: hidden;
}

.operation-overlay {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: doc-viewer-fade-in .2s ease;
}

[data-theme="dark"] .operation-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.operation-overlay__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .75rem;
  padding: 2rem 2.5rem;
  max-width: 24rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: doc-viewer-slide-in .22s ease;
}

.operation-overlay__spinner {
  width: 3.25rem;
  height: 3.25rem;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.operation-overlay__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.45;
  margin: 0;
  letter-spacing: -0.02em;
}

.operation-overlay__hint {
  font-size: .875rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

.success-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: doc-viewer-fade-in .2s ease;
  overflow: hidden;
}

[data-theme="dark"] .success-modal-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.success-modal__confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.success-modal {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
  animation: doc-viewer-slide-in .25s ease;
}

.success-modal__icon {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-success-soft, color-mix(in srgb, var(--color-success) 15%, transparent));
  color: var(--color-success);
  margin: 0 auto 1rem;
}

.success-modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--color-text);
}

.success-modal__message {
  color: var(--color-text-muted);
  font-size: .9375rem;
  line-height: 1.55;
  margin: 0 0 1.25rem;
}

.success-modal__actions {
  display: flex;
  justify-content: center;
}

.success-modal__actions .btn {
  min-width: 8rem;
}

/* ── Forbidden / access denied modal ───────────────────────── */

body.forbidden-modal-open {
  overflow: hidden;
}

.forbidden-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  animation: doc-viewer-fade-in .2s ease;
}

[data-theme="dark"] .forbidden-modal-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.forbidden-modal {
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
  animation: doc-viewer-slide-in .25s ease;
}

.forbidden-modal__icon {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-warning-soft);
  color: var(--color-warning);
  margin: 0 auto 1rem;
}

.forbidden-modal__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--color-text);
}

.forbidden-modal__message {
  color: var(--color-text-muted);
  font-size: .9375rem;
  line-height: 1.55;
  margin: 0 0 1.25rem;
}

.forbidden-modal__actions {
  display: flex;
  justify-content: center;
}

.forbidden-modal__actions .btn {
  min-width: 8rem;
}

.subscription-gate-overlay {
  z-index: 2400;
}

.subscription-gate-modal {
  width: min(480px, 100%);
}

.subscription-gate-modal__icon {
  background: var(--color-danger-soft, rgba(239, 68, 68, 0.12));
  color: var(--color-danger, #dc2626);
}

.subscription-gate-modal__hint {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.subscription-gate-modal__actions {
  flex-direction: column;
  gap: 0.5rem;
}

.subscription-gate-modal__actions .btn {
  width: 100%;
}

.subscription-upgrade-payment {
  margin-top: 1.25rem;
}

.subscription-upgrade-payment__plan {
  margin: 0 0 1rem;
  font-weight: 600;
}

.subscription-upgrade-payment__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

@media (max-width: 1023px) {
  .topbar__actions {
    gap: .375rem;
  }
}

/* ── Settings ────────────────────────────────────────────────── */

.settings-page > .content-page-header,
.settings-page > .profile-tabs,
.settings-page > .settings-tabs,
.settings-page > .alert {
  flex-shrink: 0;
}

.settings-page .profile-card {
  margin-bottom: 0;
}

.settings-page .edit-panel__scroll {
  padding-bottom: env(safe-area-inset-bottom, 0);
  -webkit-overflow-scrolling: touch;
}

.settings-page .settings-tabs {
  max-width: 28rem;
}

.settings-classification-hint {
  margin: 0 0 1rem;
}

.settings-lookups {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-lookup-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 0;
  min-width: 0;
  overflow: hidden;
}

.settings-lookup-section__title {
  margin: 0;
  padding: .65rem 1rem;
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid color-mix(in srgb, var(--color-primary) 10%, var(--color-border));
  background: var(--lookup-panel-gradient);
  color: var(--lookup-panel-title);
}

.settings-lookup-tabulator {
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: var(--color-surface-raised);
  margin-bottom: 0;
}

.settings-lookup-tabulator .tabulator {
  background: transparent;
  font-size: .8125rem;
}

.settings-lookup-tabulator .tabulator-header {
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
}

.settings-lookup-tabulator .tabulator-header .tabulator-col {
  background: var(--color-surface-raised);
  border-right-color: var(--color-border);
}

.settings-lookup-tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: .28rem .5rem;
  background: var(--color-surface-raised);
}

.settings-lookup-tabulator .tabulator-header .tabulator-col .tabulator-col-title-holder {
  display: none;
}

.settings-lookup-tabulator .tabulator-header .tabulator-col .tabulator-header-filter {
  padding: .28rem .5rem;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
}

.settings-lookup-tabulator .tabulator-header-filter input,
.settings-lookup-tabulator .tabulator-header-filter select {
  padding: .15rem .4rem;
  font-size: .8125rem;
  min-height: 1.6rem;
  background: var(--color-surface);
}

.settings-lookup-tabulator .tabulator-tableholder .tabulator-table .tabulator-row,
.settings-lookup-tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-row-even {
  min-height: 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.settings-lookup-tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover {
  background: var(--color-bg-hover);
}

.settings-lookup-tabulator .tabulator-cell {
  padding: .18rem .5rem;
}

.settings-lookup-tabulator .tabulator-icon-btn {
  min-width: 1.65rem;
  width: 1.65rem;
  height: 1.65rem;
}

.settings-lookup-tabulator .tabulator-col.tabulator-frozen.tabulator-frozen-right,
.settings-lookup-tabulator .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
  background: inherit;
}

.settings-lookup-tabulator .tabulator-header .tabulator-col.tabulator-frozen.tabulator-frozen-right {
  background: var(--color-surface-raised);
}

.settings-lookup-tabulator .tabulator-tableholder {
  overflow-y: auto !important;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-text-muted) 45%, transparent) transparent;
}

.settings-lookup-tabulator .tabulator-tableholder::-webkit-scrollbar {
  width: 8px;
}

.settings-lookup-tabulator .tabulator-tableholder::-webkit-scrollbar-track {
  background: transparent;
}

.settings-lookup-tabulator .tabulator-tableholder::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-text-muted) 40%, transparent);
  border-radius: 4px;
}

.settings-lookup-tabulator .tabulator-tableholder::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--color-text-muted) 60%, transparent);
}

.settings-lookup-section__footer {
  padding: .55rem 1rem;
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
}

.settings-lookup-add {
  display: flex;
  gap: .5rem;
  margin-top: 0;
  align-items: center;
}

.settings-lookup-add .input {
  flex: 1;
  min-width: 0;
}

.settings-tier-preview {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .85rem;
}

.settings-company-section {
  margin-bottom: 1.75rem;
}

.settings-company-section:last-child {
  margin-bottom: 0;
}

.settings-company-section .edit-panel__title {
  margin-bottom: 1rem;
}

.company-logo-preview {
  width: 9rem;
  height: 3.5rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--color-border);
  background: var(--color-bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.company-logo-preview .user-avatar,
.company-logo-preview .user-avatar__initials {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.company-logo-preview__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.company-logo-preview__placeholder {
  font-size: .75rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0 .5rem;
}

.password-meter {
  margin-top: .5rem;
}

.password-meter__head {
  display: block;
}

.password-meter--compact {
  margin-top: .3rem;
}

.password-meter--compact .password-meter__head {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .15rem;
}

.password-meter--compact .password-meter__track {
  flex: 1;
  min-width: 0;
  height: .28rem;
}

.password-meter--compact .password-meter__label {
  margin: 0;
  font-size: .7rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.password-meter--compact .password-meter__rules {
  grid-template-columns: 1fr 1fr;
  gap: .05rem .4rem;
  font-size: .68rem;
  line-height: 1.2;
}

.password-meter--compact .password-meter__rules li::before {
  margin-right: .2rem;
  font-size: .55rem;
}

.password-meter__track {
  height: .35rem;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.password-meter__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--color-danger);
  transition: width .2s ease, background .2s ease;
}

.password-meter[data-level="medium"] .password-meter__fill {
  background: var(--color-warning);
}

.password-meter[data-level="strong"] .password-meter__fill {
  background: var(--color-success);
}

.password-meter__label {
  margin: .35rem 0 .25rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.password-meter[data-level="strong"] .password-meter__label {
  color: var(--color-success);
}

.password-meter__rules {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: .2rem;
  font-size: .8125rem;
  color: var(--color-text-muted);
}

.password-meter__rules li::before {
  content: '○';
  margin-right: .35rem;
  color: var(--color-text-muted);
}

.password-meter__rules li.is-ok {
  color: var(--color-success);
}

.password-meter__rules li.is-ok::before {
  content: '●';
  color: var(--color-success);
}

.perm-panels {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.perm-panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  padding: 1rem;
  min-width: 0;
}

.perm-panel__title {
  margin: 0 0 .35rem;
  font-size: .95rem;
  font-weight: 700;
}

.perm-panel__hint {
  margin: 0 0 .85rem;
  font-size: .8125rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.perm-panel__toggles {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.perm-toggle {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-radius: 999px;
  padding: .4rem .85rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.perm-toggle:hover:not(:disabled) {
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.perm-toggle.is-on {
  background: var(--color-success-soft);
  border-color: var(--color-success);
  color: var(--color-success);
}

.perm-toggle:disabled {
  opacity: .65;
  cursor: not-allowed;
}
