:root {
  --if-ink: #0f172a;
  --if-muted: #64748b;
  --if-bg: #f8fafc;
  --if-card: #ffffff;
  --if-accent: #0d9488;
  --if-accent-hover: #0f766e;
  --if-border: #e2e8f0;
  --sl-font-sans: "Source Sans 3", system-ui, sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,400;0,600;0,700;1,400&display=swap");

body {
  margin: 0;
  font-family: var(--sl-font-sans);
  color: var(--if-ink);
  background: var(--if-bg);
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--if-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand sl-icon {
  font-size: 1.5rem;
  color: var(--if-accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.muted {
  color: var(--if-muted);
  font-size: 0.9rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.drop-target {
  border: 2px dashed var(--if-border);
  border-radius: var(--sl-border-radius-medium);
  padding: 2rem;
  text-align: center;
  background: var(--if-card);
  transition:
    border-color 0.15s,
    background 0.15s;
}

.drop-target.dragover {
  border-color: var(--if-accent);
  background: rgba(13, 148, 136, 0.06);
}

.field-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.link {
  color: var(--if-accent);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.link:hover {
  color: var(--if-accent-hover);
  text-decoration: underline;
}

.kanban {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.kanban-col {
  flex: 1 1 220px;
  min-width: 220px;
  max-width: 320px;
  background: var(--if-card);
  border: 1px solid var(--if-border);
  border-radius: var(--sl-border-radius-medium);
  padding: 0.65rem;
}

.kanban-col h3 {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--if-muted);
}

.kanban-cards {
  min-height: 120px;
}

.kanban-card {
  background: var(--if-bg);
  border: 1px solid var(--if-border);
  border-radius: var(--sl-border-radius-medium);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  cursor: grab;
  font-size: 0.9rem;
}

.kanban-card:active {
  cursor: grabbing;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.task-table th,
.task-table td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--if-border);
}

.task-table th {
  color: var(--if-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.firm-timer-strip {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(90deg, #1e3a8a, #2d5bff);
  color: #f8fafc;
  padding: 0.45rem 1.25rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.firm-timer-strip[hidden] {
  display: none !important;
}

.firm-timer-strip a {
  color: inherit;
  font-weight: 600;
}

.strip-stop-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: inherit;
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.strip-stop-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.portal-app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.portal-app-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: var(--if-card);
  border: 1px solid var(--if-border);
  border-radius: var(--sl-border-radius-medium);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.portal-app-card:hover {
  border-color: var(--if-accent);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.12);
}

.portal-mini-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.portal-embed-page-card {
  max-width: 100%;
}

.portal-embed-shell {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 220px);
}

.portal-embed-frame {
  flex: 1;
  width: 100%;
  min-height: 480px;
  border: 1px solid var(--if-border);
  border-radius: var(--sl-border-radius-medium);
  background: var(--if-card);
}

/* —— Client portal shell (top nav + card content) —— */
.portal-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Inter", system-ui, sans-serif;
  background: #eef1f4;
  --sl-color-primary-600: var(--if-accent);
  --sl-color-primary-700: var(--if-accent-hover);
}

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #dce1e8;
  flex-wrap: wrap;
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--if-accent);
}

.portal-brand sl-icon {
  font-size: 1.55rem;
  color: var(--if-accent);
}

.portal-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.portal-brand-line1,
.portal-brand-line2 {
  display: block;
}

.portal-topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.35rem;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.portal-topnav-link {
  text-decoration: none;
  color: #64748b;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
  transition:
    color 0.12s,
    border-color 0.12s;
}

.portal-topnav-link:hover {
  color: #0f172a;
}

.portal-topnav-link.is-active {
  color: var(--if-accent);
  border-bottom-color: var(--if-accent);
}

.portal-topbar-user {
  flex-shrink: 0;
}

.portal-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  color: inherit;
}

.portal-user-trigger:hover {
  background: #f1f5f9;
}

.portal-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.portal-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1e293b;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-user-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #94a3b8;
  margin-left: 0.1rem;
}

.portal-main {
  flex: 1;
  padding: 1.35rem 1.5rem 2rem;
  min-width: 0;
}

.portal-page-card {
  background: #fff;
  border: 1px solid #dce1e8;
  border-radius: 10px;
  padding: 1.35rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.portal-page-card--narrow {
  max-width: 520px;
}

.portal-inpage-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-client-tag {
  color: var(--if-muted);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.portal-home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 768px) {
  .portal-home-grid {
    grid-template-columns: 1fr;
  }
}

.portal-home-apps {
  grid-column: 1 / -1;
}

.portal-app .portal-surface-card::part(base) {
  border-radius: 8px;
  border: 1px solid var(--if-border);
  box-shadow: none;
}

.portal-inline-link {
  color: var(--if-accent);
  font-weight: 600;
  text-decoration: none;
}

.portal-inline-link:hover {
  text-decoration: underline;
}

.portal-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--if-border);
}

.portal-list-row:last-child {
  border-bottom: none;
}

.portal-list-row--lg {
  padding: 0.65rem 0;
}

.portal-drop-target {
  margin-top: 0.5rem;
}

.portal-wizard-card {
  background: #fff;
  border: 1px solid #dce1e8;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.portal-wizard-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
}

@media (max-width: 900px) {
  .portal-wizard-grid {
    grid-template-columns: 1fr;
  }
}

.portal-wizard-sidebar {
  background: #f4f6f8;
  border-right: 1px solid #e2e8f0;
  padding: 1.2rem 1rem 1.5rem;
}

@media (max-width: 900px) {
  .portal-wizard-sidebar {
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
}

.portal-progress-head {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.45rem;
}

.portal-progress-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
}

.portal-progress-fraction {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--if-accent);
}

.portal-progress-bar {
  --indicator-color: var(--if-accent);
}

.portal-stepper {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
}

.portal-step {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  opacity: 0.5;
}

.portal-step.is-active,
.portal-step.is-done {
  opacity: 1;
}

.portal-step-marker {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  background: #fff;
}

.portal-step.is-done .portal-step-marker {
  background: var(--if-accent);
  border-color: var(--if-accent);
  color: #fff;
  font-size: 0.62rem;
}

.portal-step.is-active .portal-step-marker {
  border-color: #94a3b8;
  color: #475569;
}

.portal-step-body strong {
  font-size: 0.86rem;
  display: block;
  margin-bottom: 0.3rem;
  color: #334155;
}

.portal-step-subs {
  list-style: none;
  margin: 0;
  padding: 0;
}

.portal-step-sub {
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.12rem 0 0.12rem 0.45rem;
  border-left: 2px solid transparent;
}

.portal-step-sub.is-active {
  color: var(--if-accent);
  font-weight: 600;
  border-left-color: var(--if-accent);
}

.portal-wizard-main {
  padding: 1.35rem 1.5rem 1rem;
  min-width: 0;
  background: #fff;
}

.portal-wizard-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.portal-wizard-h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-saved-badge {
  font-size: 0.78rem;
  color: #64748b;
  white-space: nowrap;
  padding-top: 0.2rem;
}

.portal-wizard-section-bar {
  background: #eef1f4;
  color: #475569;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.1rem;
}

.portal-wizard-lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.portal-field-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--if-border);
  flex-wrap: wrap;
}

.portal-wizard-footer-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#portal-wiz-prev::part(base) {
  background: #e8ecf0;
  border-color: #d1d9e0;
  color: #334155;
}

.portal-readonly-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-readonly-field {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--if-border);
}

.portal-readonly-field:last-child {
  border-bottom: none;
}

.portal-readonly-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  margin-bottom: 0.25rem;
}

.portal-readonly-value {
  font-size: 0.95rem;
}

.portal-embed-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.portal-embed-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* —— Firm app shell (dashboard-style) —— */
.firm-app {
  display: flex;
  min-height: 100vh;
  font-family: "Inter", system-ui, sans-serif;
}

.firm-sidebar {
  width: 88px;
  flex-shrink: 0;
  background: #1a1c2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  color: rgba(255, 255, 255, 0.88);
}

.firm-sidebar-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.firm-logo-mark {
  display: flex;
  color: #fff;
  text-decoration: none;
}

.firm-logo-mark sl-icon {
  font-size: 1.65rem;
  color: #fff;
}

.firm-quick-add {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #2d5bff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.45rem;
  font-weight: 300;
  line-height: 1;
  margin-top: 0.85rem;
  transition:
    background 0.15s,
    transform 0.1s;
}

.firm-quick-add:hover {
  background: #2448d9;
  color: #fff;
}

.firm-quick-add:active {
  transform: scale(0.96);
}

.firm-nav-mid {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  margin-top: 1.35rem;
  width: 100%;
  padding: 0 0.35rem;
}

.firm-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.45rem 0.2rem;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.62rem;
  font-weight: 500;
  text-align: center;
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition:
    color 0.15s,
    background 0.15s;
}

.firm-nav-item:hover {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.06);
}

.firm-nav-item.is-active {
  color: #fff;
  background: rgba(45, 91, 255, 0.22);
  border-left-color: #2d5bff;
}

.firm-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.firm-nav-svg {
  opacity: 0.95;
}

.firm-nav-label {
  max-width: 76px;
  line-height: 1.15;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #e11d48;
  border-radius: 9px;
  margin-left: 4px;
  vertical-align: middle;
}

.firm-nav-item.is-active .nav-badge {
  background: #ff6b8a;
}

.firm-nav-item--icononly {
  padding: 0.5rem;
}

.firm-nav-item--icononly .firm-nav-label {
  display: none;
}

.firm-sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0 0.25rem;
}

.firm-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2d5bff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.firm-logout-btn::part(base) {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.62rem;
}

.firm-logout-btn::part(base):hover {
  color: rgba(255, 255, 255, 0.9);
}

.firm-main {
  flex: 1;
  min-width: 0;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  --firm-primary: #2d5bff;
  --sl-color-primary-50: #eef2ff;
  --sl-color-primary-100: #e0e7ff;
  --sl-color-primary-600: #2d5bff;
  --sl-color-primary-700: #2448d9;
  --sl-color-primary-800: #1c38ad;
}

.firm-main-header {
  padding: 1.5rem 2rem 0;
}

.firm-welcome {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #111827;
}

.firm-page-title {
  margin: 0 0 0.15rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111827;
}

.firm-tabs {
  display: flex;
  gap: 1.75rem;
  margin-top: 0.65rem;
  border-bottom: 1px solid #e8eaef;
}

.firm-tab {
  padding: 0.45rem 0 0.7rem;
  text-decoration: none;
  color: #6b7280;
  font-weight: 500;
  font-size: 0.9rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.firm-tab:hover {
  color: #374151;
}

.firm-tab.is-active {
  color: #111827;
  font-weight: 700;
  border-bottom-color: #2d5bff;
}

.firm-breadcrumb {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: #6b7280;
}

.firm-breadcrumb-link {
  color: #2d5bff;
  text-decoration: none;
  font-weight: 500;
}

.firm-breadcrumb-link:hover {
  text-decoration: underline;
}

.firm-breadcrumb-sep {
  color: #9ca3af;
  margin: 0 0.2rem;
}

.firm-main-body {
  padding: 1.25rem 2rem 2.5rem;
  flex: 1;
}

.firm-main-body .link {
  color: #2d5bff;
}

.firm-main-body .link:hover {
  color: #2448d9;
}

.firm-dash-grid {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .firm-dash-grid {
    grid-template-columns: 1fr;
  }
}

.firm-dash-col--wide {
  min-width: 0;
}

.firm-dash-subgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (max-width: 720px) {
  .firm-dash-subgrid {
    grid-template-columns: 1fr;
  }
}

.firm-main-body sl-card::part(base) {
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.firm-schedule-date {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

.firm-empty-state {
  text-align: center;
  padding: 0.75rem 0.5rem 0.25rem;
}

.firm-empty-state--inline {
  padding: 1.25rem 0.5rem;
  border-top: 1px solid #f3f4f6;
  margin-top: 0.5rem;
}

.firm-empty-title {
  font-weight: 600;
  margin: 0.35rem 0 0.25rem;
  color: #374151;
  font-size: 1rem;
}

.firm-empty-sub {
  margin: 0;
  font-size: 0.88rem;
}

.firm-empty-illus {
  color: #cbd5e1;
}

.firm-empty-illus--sm {
  margin: 0 auto;
}

.firm-links-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.firm-links-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.firm-links-list li:last-child {
  border-bottom: none;
}

.firm-link {
  color: #2d5bff;
  font-weight: 500;
  text-decoration: none;
}

.firm-link:hover {
  text-decoration: underline;
}

.firm-link--small {
  font-size: 0.85rem;
}

.firm-card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1rem;
}

.firm-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 1rem 0;
  border-top: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
}

@media (max-width: 600px) {
  .firm-stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.firm-stat {
  text-align: center;
}

.firm-stat-num {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: #2d5bff;
  line-height: 1.2;
}

.firm-stat-lab {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
}

.firm-chart-placeholder {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 88px;
  padding: 0.75rem 0 0.25rem;
  color: #d1d5db;
}

.firm-chart-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #e5e7eb, #cbd5e1);
  margin: 0 1rem 1.25rem;
}

.firm-chart-lab {
  font-size: 0.75rem;
  color: #9ca3af;
  align-self: flex-end;
  margin-bottom: 0.15rem;
}

.firm-tasks-hint {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.firm-quick-links {
  gap: 0.5rem;
}

.firm-subnav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Status badges for invoices */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.status-draft {
  background: #f3f4f6;
  color: #6b7280;
}

.status-open {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-paid {
  background: #d1fae5;
  color: #047857;
}

.status-void {
  background: #fee2e2;
  color: #b91c1c;
}

/* ===== Branding Page Styles ===== */
.branding-page {
  max-width: 900px;
}

.branding-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.branding-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1.5rem;
}

.branding-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1.25rem 0;
  color: #111827;
}

/* Domain Section */
.domain-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.domain-input {
  flex: 1;
  max-width: 320px;
}

/* Toggle Items */
.branding-toggle-item {
  padding: 1rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.branding-toggle-item:last-child {
  border-bottom: none;
}

.toggle-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.toggle-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toggle-title {
  font-weight: 500;
  font-size: 0.9rem;
  color: #374151;
}

.toggle-description {
  font-size: 0.8rem;
  color: #6b7280;
}

.toggle-content {
  margin-top: 0.75rem;
  margin-left: 3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toggle-content.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Field Labels */
.field-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #374151;
}

.field-label .required {
  color: #dc2626;
}

.field-label .optional {
  color: #9ca3af;
  font-weight: 400;
}

.field-row {
  display: flex;
  gap: 1rem;
}

.field-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Logo Upload */
.section-help {
  font-size: 0.8rem;
  color: #6b7280;
  margin: -0.75rem 0 1rem 0;
}

.logo-upload-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.logo-preview {
  width: 280px;
  height: 100px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  overflow: hidden;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #9ca3af;
}

.placeholder-icon {
  font-size: 2rem;
}

.logo-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #374151;
  margin-left: 0.5rem;
}

/* Color Selection */
.color-grid {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.color-custom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.color-custom sl-color-picker {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-swatch {
  cursor: pointer;
  border: 2px solid #e5e7eb;
}

.color-label {
  font-size: 0.75rem;
  color: #6b7280;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 0.5rem;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.is-selected::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px solid currentColor;
  border-radius: 6px;
}

/* Background Images */
.background-images-section {
  margin-bottom: 1.5rem;
}

.background-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.background-thumb {
  aspect-ratio: 4/3;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.background-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-thumb.is-selected {
  border-color: #2d5bff;
}

.thumb-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: #2d5bff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
}

.upload-area {
  border: 2px dashed #e5e7eb;
  border-radius: 8px;
  padding: 2rem;
  margin-top: 1rem;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
}

.upload-icon {
  font-size: 2.5rem;
  color: #9ca3af;
}

.upload-title {
  font-weight: 500;
  color: #374151;
}

.upload-hint {
  font-size: 0.75rem;
  color: #6b7280;
  max-width: 300px;
}

/* Welcome Message */
.welcome-message-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f3f4f6;
}

.welcome-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.welcome-fields.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.char-count {
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: right;
}

/* Template Selection */
.template-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f3f4f6;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.template-card {
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.template-card.is-selected {
  border-color: #2d5bff;
}

.template-preview {
  aspect-ratio: 4/3;
  background: #f9fafb;
}

/* Template Preview Miniatures */
.tpl-preview-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
}

.tpl-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
}

.tpl-right {
  background: linear-gradient(135deg, #e5e7eb, #d1d5db);
}

.tpl-preview-center {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0.75rem;
}

.tpl-card {
  background: white;
  border-radius: 4px;
  padding: 0.75rem;
  width: 80%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tpl-preview-modern {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.tpl-angle {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 100%;
  height: 200%;
  transform: rotate(15deg);
}

.tpl-content {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.75rem;
}

.tpl-logo {
  font-size: 0.6rem;
  font-weight: 600;
  color: #6b7280;
}

.tpl-form-line {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
}

.tpl-form-line.short {
  width: 60%;
}

.tpl-btn {
  height: 12px;
  border-radius: 2px;
  margin-top: 0.25rem;
}

.tpl-welcome {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 0.5rem;
}

.tpl-welcome-line {
  height: 4px;
  background: #374151;
  border-radius: 2px;
  margin-bottom: 4px;
}

/* Previews Section */
.preview-item {
  margin-bottom: 2rem;
}

.preview-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.75rem 0;
}

.preview-link {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: inline-block;
}

.preview-frame {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.login-preview-frame {
  max-width: 480px;
  aspect-ratio: 16/10;
}

.portal-preview-frame {
  max-width: 520px;
  aspect-ratio: 16/9;
}

.email-preview-frame {
  max-width: 320px;
  background: #f3f4f6;
  padding: 1rem;
}

.invoice-preview-frame {
  max-width: 400px;
  aspect-ratio: 3/4;
}

/* Preview Content Styles */
.preview-login-modern {
  position: relative;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-angle {
  position: absolute;
  top: -30%;
  left: -20%;
  width: 70%;
  height: 160%;
  transform: rotate(12deg);
  z-index: 1;
}

.login-content {
  position: relative;
  z-index: 2;
  display: contents;
}

.login-card {
  background: white;
  margin: 1rem;
  padding: 1rem;
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-welcome-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.welcome-overlay {
  background: rgba(255,255,255,0.95);
  padding: 0.75rem;
  border-radius: 4px;
  text-align: center;
}

.welcome-overlay h3 {
  margin: 0 0 0.25rem 0;
  font-size: 0.9rem;
}

.welcome-overlay p {
  margin: 0;
  font-size: 0.75rem;
  color: #6b7280;
}

.preview-logo {
  max-height: 30px;
  max-width: 80px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

.preview-logo-placeholder {
  font-size: 0.7rem;
  font-weight: 700;
  color: #9ca3af;
  margin-bottom: 0.5rem;
}

.login-field label {
  font-size: 0.6rem;
  color: #6b7280;
  display: block;
  margin-bottom: 0.15rem;
}

.login-field input {
  width: 100%;
  padding: 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  font-size: 0.7rem;
}

.login-btn {
  color: white;
  border: none;
  padding: 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.25rem;
}

.preview-login-default {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1rem;
}

.login-card-center {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  width: 70%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Portal Preview */
.preview-portal {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.preview-portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid;
}

.preview-portal-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.preview-portal-logo {
  max-height: 20px;
  max-width: 60px;
  object-fit: contain;
}

.preview-portal-nav {
  display: flex;
  gap: 0.75rem;
  font-size: 0.65rem;
}

.preview-portal-nav span {
  color: #6b7280;
}

.preview-user {
  font-size: 0.65rem;
  color: #374151;
}

.preview-portal-body {
  flex: 1;
  display: grid;
  grid-template-columns: 80px 1fr;
  padding: 0.5rem;
  gap: 0.5rem;
}

.preview-sidebar {
  background: #f9fafb;
  border-radius: 4px;
  padding: 0.5rem;
}

.preview-progress {
  font-size: 0.6rem;
}

.preview-progress-header {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.25rem;
}

.preview-check {
  margin-bottom: 0.15rem;
}

.preview-uncheck {
  color: #9ca3af;
}

.preview-main-content {
  background: #f9fafb;
  border-radius: 4px;
  padding: 0.5rem;
}

.preview-main-content h4 {
  font-size: 0.7rem;
  margin: 0 0 0.5rem 0;
  color: #374151;
}

.preview-form-group label {
  font-size: 0.6rem;
  color: #6b7280;
  display: block;
  margin-bottom: 0.15rem;
}

.preview-form-group input {
  width: 100%;
  padding: 0.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  font-size: 0.65rem;
}

/* Email Preview */
.preview-email {
  background: white;
  border-radius: 4px;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.email-header {
  text-align: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f3f4f6;
}

.email-logo {
  max-height: 24px;
  max-width: 100px;
  object-fit: contain;
}

.email-logo-placeholder {
  font-size: 0.7rem;
  font-weight: 700;
}

.email-body {
  padding: 0.75rem 0;
}

.email-title {
  font-size: 0.65rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  text-align: center;
}

.email-text {
  font-size: 0.6rem;
  color: #4b5563;
  margin: 0 0 0.35rem 0;
  line-height: 1.4;
}

.email-btn {
  color: white;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  font-size: 0.6rem;
  font-weight: 500;
  cursor: pointer;
  display: block;
  margin: 0.75rem auto 0;
}

.email-footer {
  text-align: center;
  padding-top: 0.5rem;
  border-top: 1px solid #f3f4f6;
  font-size: 0.55rem;
  color: #9ca3af;
}

.email-footer p {
  margin: 0 0 0.15rem 0;
}

/* Invoice Preview */
.preview-invoice {
  padding: 0.75rem;
  font-size: 0.6rem;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.invoice-from {
  color: #374151;
}

.invoice-from strong {
  display: block;
  margin-bottom: 0.25rem;
}

.invoice-from p {
  margin: 0 0 0.15rem 0;
  font-size: 0.55rem;
}

.invoice-logo {
  max-height: 30px;
  max-width: 60px;
  object-fit: contain;
}

.invoice-logo-text {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: right;
  line-height: 1.1;
}

.invoice-details {
  margin-bottom: 0.75rem;
}

.invoice-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.invoice-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.55rem;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.55rem;
}

.invoice-table th,
.invoice-table td {
  text-align: left;
  padding: 0.25rem 0.15rem;
  border-bottom: 1px solid #f3f4f6;
}

.invoice-table th {
  font-weight: 600;
  color: #6b7280;
  border-bottom-width: 2px;
}

/* Save Actions */
.branding-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
}

.save-status {
  font-size: 0.85rem;
}

.save-status.success {
  color: #059669;
}

.save-status.error {
  color: #dc2626;
}
