/*
 * Firm portal — Direction B ("Modern dashboard") restyle.
 *
 * DESIGN TOKENS (paired set): the values below mirror the Direction-B tokens
 * defined in assets/css/new-admin.css EXACTLY. The portal cannot share the
 * admin stylesheet on the front end, so the values are duplicated here and MUST
 * be kept identical to new-admin.css so admin and portal stay one product. If
 * you change a token here, change it there too (and vice versa).
 *
 * Source of truth: docs/superpowers/specs/2026-05-29-firms-dashboard-visual-enhancement-design.md §3.
 */

.msw-firm-portal {
  /* Direction-B design tokens (mirror new-admin.css — keep identical). */
  --msw-bg: #f6f7f9;
  --msw-card: #ffffff;
  --msw-border: #e8eaed;
  --msw-hairline: #f1f3f5;
  --msw-ink: #0f172a;
  --msw-muted: #64748b;
  --msw-accent: #b91c1c;
  --msw-accent-dark: #7f1010;
  --msw-accent-tint: #fdecec;
  --msw-ok: #16a34a;
  --msw-ok-tint: #dcfce7;
  --msw-info: #2563eb;
  --msw-info-tint: #dbeafe;
  --msw-warn: #d97706;
  --msw-warn-tint: #fef3c7;
  --msw-danger: #b91c1c;
  --msw-danger-tint: #fee2e2;
  /* Pending pill (portal-only, per spec §5.2). */
  --msw-pending: #b45309;
  --msw-pending-tint: #fef3c7;
  --msw-radius: 12px;
  --msw-radius-sm: 9px;
  --msw-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .06);
  --msw-shadow-accent: 0 1px 2px rgba(185, 28, 28, .4);

  /* Legacy --msw-firm-* names remapped onto the shared tokens above so the rest
     of this file (and any cached markup) keeps working with one palette. */
  --msw-firm-surface: var(--msw-card);
  --msw-firm-surface-alt: var(--msw-bg);
  --msw-firm-border: var(--msw-border);
  --msw-firm-hairline: var(--msw-hairline);
  --msw-firm-muted: var(--msw-muted);
  --msw-firm-text: var(--msw-ink);
  --msw-firm-primary: var(--msw-accent);

  max-width: var(--msw-content-width, 1120px);
  margin: 0 auto;
  padding: 32px 16px;
  color: var(--msw-firm-text);
  font-family: var(--msw-font-family, inherit);
  background: var(--msw-bg);
}

/* ---------------------------------------------------------------- Header */

.msw-firm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.msw-firm-header h1 {
  margin: 0 0 4px;
  font-size: 2rem;
  line-height: 1.15;
  color: var(--msw-ink);
}

.msw-firm-header p {
  margin: 0;
  color: var(--msw-firm-muted);
}

/* ---------------------------------------------------------- Summary cards */

.msw-firm-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.msw-firm-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--msw-card);
  border: 1px solid var(--msw-border);
  border-radius: var(--msw-radius);
  box-shadow: var(--msw-shadow);
}

.msw-firm-stat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: var(--msw-radius-sm);
  background: var(--msw-accent-tint);
  color: var(--msw-accent);
}

.msw-firm-stat-chip svg {
  width: 18px;
  height: 18px;
}

.msw-firm-stat-body {
  min-width: 0;
}

.msw-firm-stat-label {
  display: block;
  margin-bottom: 2px;
  color: var(--msw-firm-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.msw-firm-stat-value {
  display: block;
  font-size: 1.625rem;
  font-weight: 750;
  line-height: 1.15;
  color: var(--msw-ink);
}

.msw-firm-stat-value--text {
  font-size: 1.0625rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- Sections */

.msw-firm-section {
  background: var(--msw-card);
  border: 1px solid var(--msw-border);
  border-radius: var(--msw-radius);
  box-shadow: var(--msw-shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.msw-firm-section h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  color: var(--msw-ink);
}

.msw-firm-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.msw-firm-section-header h2 {
  margin-bottom: 4px;
}

.msw-firm-section-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.msw-firm-section-title h2 {
  margin: 0;
}

/* Paired billing + domains cards. */
.msw-firm-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.msw-firm-pair .msw-firm-section {
  margin-bottom: 20px;
}

/* ----------------------------------------------------------- Status pills */

.msw-firm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.msw-firm-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.msw-firm-pill.ok {
  color: var(--msw-ok);
  background: var(--msw-ok-tint);
}

.msw-firm-pill.info {
  color: var(--msw-info);
  background: var(--msw-info-tint);
}

.msw-firm-pill.warn {
  color: var(--msw-warn);
  background: var(--msw-warn-tint);
}

.msw-firm-pill.pending {
  color: var(--msw-pending);
  background: var(--msw-pending-tint);
}

.msw-firm-pill.danger {
  color: var(--msw-danger);
  background: var(--msw-danger-tint);
}

/* --------------------------------------------------------- Progress bars */

.msw-firm-progress {
  height: 7px;
  margin: 4px 0 14px;
  border-radius: 999px;
  background: #eef0f3;
  overflow: hidden;
}

.msw-firm-progress-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--msw-ok);
  transition: width 0.3s ease;
}

/* --------------------------------------------------------- Renewal tiles */

.msw-firm-renewal-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.msw-firm-renewal-tile {
  border: 1px solid var(--msw-border);
  border-radius: var(--msw-radius-sm);
  padding: 18px;
  background: var(--msw-card);
}

.msw-firm-renewal-tile span,
.msw-firm-renewal-tile p {
  color: var(--msw-firm-muted);
  font-size: 0.8125rem;
}

.msw-firm-renewal-tile span,
.msw-firm-renewal-tile strong {
  display: block;
}

.msw-firm-renewal-tile strong {
  margin: 6px 0 12px;
  font-size: 1.25rem;
  line-height: 1.25;
  color: var(--msw-ink);
  overflow-wrap: anywhere;
}

/* "Total due" hero tile in branded red. */
.msw-firm-hero {
  background: linear-gradient(135deg, var(--msw-accent), var(--msw-accent-dark));
  border-color: var(--msw-accent-dark);
  color: #ffffff;
}

.msw-firm-hero span,
.msw-firm-hero p {
  color: rgba(255, 255, 255, 0.82);
}

.msw-firm-hero strong {
  margin-bottom: 8px;
  font-size: 1.875rem;
  font-weight: 750;
  color: #ffffff;
}

.msw-firm-renewal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msw-firm-seat-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 150px;
}

.msw-firm-seat-action-form {
  display: none;
}

.msw-firm-confirmed-by {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--msw-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ------------------------------------------------------- Branded checkbox */

.msw-firm-check {
  display: inline-flex;
  position: relative;
  cursor: pointer;
}

.msw-firm-check input[type="checkbox"] {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.msw-firm-check-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--msw-border);
  border-radius: 6px;
  background: var(--msw-card);
  color: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.msw-firm-check-box svg {
  width: 14px;
  height: 14px;
}

.msw-firm-check input:checked ~ .msw-firm-check-box {
  background: var(--msw-accent);
  border-color: var(--msw-accent);
  color: #ffffff;
}

.msw-firm-check input:focus-visible ~ .msw-firm-check-box {
  outline: 2px solid var(--msw-accent);
  outline-offset: 2px;
}

.msw-firm-check input:disabled {
  cursor: not-allowed;
}

.msw-firm-check input:disabled ~ .msw-firm-check-box {
  background: var(--msw-hairline);
  border-color: var(--msw-border);
  opacity: 0.6;
  cursor: not-allowed;
}

/* ----------------------------------------------------------- Pay footer */

.msw-firm-renewal-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--msw-hairline);
}

.msw-firm-pay-summary {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--msw-ink);
}

/* ------------------------------------------------------------- Buttons */

.msw-firm-button,
.msw-firm-link-button {
  border-radius: var(--msw-radius-sm);
  border: 1px solid var(--msw-accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.msw-firm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  background: var(--msw-accent);
  color: #ffffff;
  text-decoration: none;
  box-shadow: var(--msw-shadow-accent);
  transition: background 0.15s ease;
}

.msw-firm-button:hover {
  background: var(--msw-accent-dark);
}

.msw-firm-button.secondary {
  background: var(--msw-card);
  color: var(--msw-accent);
  box-shadow: none;
}

.msw-firm-button.secondary:hover {
  background: var(--msw-accent-tint);
}

.msw-firm-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--msw-accent);
  border-color: var(--msw-border);
  padding: 6px 12px;
  min-height: 32px;
  text-decoration: none;
}

.msw-firm-link-button:hover {
  background: var(--msw-accent-tint);
  border-color: var(--msw-accent);
}

.msw-firm-link-button.danger {
  color: var(--msw-danger);
  border-color: #f3b6af;
}

.msw-firm-link-button.danger:hover {
  background: var(--msw-danger-tint);
}

.msw-firm-button:disabled,
.msw-firm-link-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.msw-firm-button:disabled:hover {
  background: var(--msw-accent);
}

.msw-firm-link-button:disabled:hover {
  background: transparent;
  border-color: var(--msw-border);
}

/* Visible focus rings for all interactive controls. */
.msw-firm-button:focus-visible,
.msw-firm-link-button:focus-visible,
.msw-firm-domain-form textarea:focus-visible,
.msw-firm-domain-edit summary:focus-visible {
  outline: 2px solid var(--msw-accent);
  outline-offset: 2px;
}

/* Fallback for browsers without :focus-visible. */
.msw-firm-button:focus,
.msw-firm-link-button:focus,
.msw-firm-domain-form textarea:focus {
  outline: 2px solid var(--msw-accent);
  outline-offset: 2px;
}

/* ----------------------------------------------------------- Domain chips */

.msw-firm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.msw-firm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--msw-accent-tint);
  color: var(--msw-accent);
  font-size: 0.8125rem;
  font-weight: 600;
}

.msw-firm-chip-icon {
  display: inline-flex;
}

.msw-firm-chip-icon svg {
  width: 14px;
  height: 14px;
}

.msw-firm-domain-edit {
  margin-top: 4px;
  border-top: 1px solid var(--msw-hairline);
  padding-top: 12px;
}

.msw-firm-domain-edit summary {
  cursor: pointer;
  color: var(--msw-accent);
  font-weight: 600;
  list-style: none;
}

.msw-firm-domain-edit summary::-webkit-details-marker {
  display: none;
}

.msw-firm-domain-edit summary::before {
  content: "+ ";
  font-weight: 700;
}

.msw-firm-domain-edit[open] summary::before {
  content: "\2212 "; /* minus sign */
}

.msw-firm-domain-edit .msw-firm-domain-form {
  margin-top: 14px;
}

.msw-firm-domain-form label,
.msw-firm-domain-form textarea {
  display: block;
  width: 100%;
}

.msw-firm-domain-form label {
  margin-bottom: 8px;
  font-weight: 600;
}

.msw-firm-domain-form textarea {
  min-height: 120px;
  margin-bottom: 12px;
  border: 1px solid var(--msw-border);
  border-radius: var(--msw-radius-sm);
  padding: 10px 12px;
  color: var(--msw-firm-text);
  background: var(--msw-card);
  font: inherit;
  box-sizing: border-box;
}

/* ------------------------------------------------------- Billing contact */

.msw-firm-contact {
  display: grid;
  gap: 12px;
  margin: 0;
}

.msw-firm-contact div {
  border-bottom: 1px solid var(--msw-hairline);
  padding-bottom: 12px;
}

.msw-firm-contact div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.msw-firm-contact dt {
  color: var(--msw-firm-muted);
  font-size: 0.8125rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.msw-firm-contact dd {
  margin: 0;
  color: var(--msw-ink);
  overflow-wrap: anywhere;
}

.msw-firm-contact a {
  color: var(--msw-accent);
}

.msw-firm-muted {
  color: var(--msw-firm-muted);
}

/* --------------------------------------------------------------- Tables */

.msw-firm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msw-firm-table-wrap {
  overflow-x: auto;
}

.msw-firm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.msw-firm-table caption {
  text-align: left;
  color: var(--msw-firm-muted);
  margin-bottom: 10px;
}

.msw-firm-table th,
.msw-firm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--msw-hairline);
  text-align: left;
  vertical-align: middle;
}

.msw-firm-table th {
  color: var(--msw-firm-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom-color: var(--msw-border);
}

.msw-firm-table tbody tr:hover {
  background: var(--msw-bg);
}

.msw-firm-table tbody tr:last-child td {
  border-bottom: 0;
}

/* --------------------------------------------------------------- Notices */

.msw-firm-notice {
  padding: 12px 14px;
  border-radius: var(--msw-radius-sm);
  margin-bottom: 16px;
}

.msw-firm-notice.success {
  background: var(--msw-ok-tint);
  color: #085d3a;
  border: 1px solid #abefc6;
}

.msw-firm-notice.error {
  background: var(--msw-danger-tint);
  color: #912018;
  border: 1px solid #fecdca;
}

/* ------------------------------------------------------------ Responsive */

@media (max-width: 768px) {
  .msw-firm-header {
    display: block;
  }

  .msw-firm-header form {
    margin-top: 16px;
  }

  .msw-firm-summary,
  .msw-firm-renewal-tiles,
  .msw-firm-pair {
    grid-template-columns: 1fr;
  }

  .msw-firm-section-header {
    display: block;
  }

  .msw-firm-section-header form {
    margin-top: 12px;
  }

  .msw-firm-renewal-submit {
    flex-direction: column;
    align-items: stretch;
  }

  .msw-firm-renewal-submit .msw-firm-button {
    width: 100%;
  }

  .msw-firm-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .msw-firm-actions form,
  .msw-firm-actions button {
    width: 100%;
  }
}

@media (max-width: 360px) {
  .msw-firm-portal {
    padding-left: 10px;
    padding-right: 10px;
  }

  .msw-firm-section {
    padding: 16px;
  }

  .msw-firm-header h1 {
    font-size: 1.6rem;
  }

  .msw-firm-stat-card {
    padding: 14px;
  }

  .msw-firm-stat-value {
    font-size: 1.375rem;
  }
}
