.btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.5rem 1rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: 0.875rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-icon { background: transparent; border: none; color: var(--text-secondary); cursor: pointer; padding: 0.5rem; border-radius: var(--radius); position: relative; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge-count {
  position: absolute; top: 4px; right: 4px;
  background: var(--badge-bg); color: #fff; font-size: 0.65rem;
  min-width: 1.1rem; height: 1.1rem; border-radius: 999px;
  display: grid; place-items: center; padding: 0 4px;
}
.greeting-banner {
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin-bottom: 1.5rem;
}
.chip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-chip {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  transition: border-color .15s, transform .15s;
}
.stat-chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-chip-count { font-size: 1.75rem; font-weight: 700; }
.stat-chip-label { font-size: 0.8rem; color: var(--text-secondary); }
.data-table { width: 100%; border-collapse: collapse; background: var(--bg-surface); border-radius: var(--radius-lg); overflow: hidden; }
.data-table th, .data-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); }
.status-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 500; }
.status-active, .status-open { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.status-draft, .status-new { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }
.row-actions { display: flex; gap: 0.25rem; }
.flyout-panel {
  position: absolute; right: 0; top: 100%; margin-top: 0.5rem;
  width: 320px; max-height: 400px; overflow: auto;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); z-index: 200;
}
.flyout-panel[hidden] { display: none !important; }
.profile-dropdown { display: flex; flex-direction: column; padding: 0.5rem; }
.profile-dropdown a { padding: 0.5rem 0.75rem; color: var(--text-primary); border-radius: var(--radius); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 0.875rem;
}
.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow);
}
.auth-card__header {
  margin-bottom: 1.5rem; text-align: center;
}
.auth-card__logo {
  display: block; width: min(100%, 280px); height: auto; margin: 0 auto 0.75rem;
}
.auth-card__title {
  margin: 0; font-size: 0.9375rem; font-weight: 500; color: var(--text-secondary);
}
.auth-card .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.auth-card input {
  width: 100%; padding: 0.65rem 0.75rem; margin: 0 0 0.75rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-primary); font: inherit;
}
.auth-card input::placeholder { color: var(--text-muted); opacity: 1; }
.auth-card input:last-of-type { margin-bottom: 0.75rem; }
.auth-card input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 1px; border-color: var(--accent);
}
.auth-card input.is-invalid { border-color: var(--error); }
.auth-card input.is-invalid:focus {
  outline-color: color-mix(in srgb, var(--error) 40%, transparent);
  border-color: var(--error);
}
.auth-card__submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.75rem;
  margin: 0;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid color-mix(in srgb, var(--accent-hover) 70%, #000);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent) 88%, #fff) 0%,
    var(--accent) 42%,
    var(--accent-hover) 100%
  );
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 12%, transparent) inset,
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 4px 14px color-mix(in srgb, var(--accent) 38%, transparent);
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.auth-card__submit:hover {
  filter: brightness(1.06);
  box-shadow:
    0 1px 0 color-mix(in srgb, #fff 14%, transparent) inset,
    0 2px 4px rgba(0, 0, 0, 0.22),
    0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}
.auth-card__submit:active {
  transform: translateY(1px);
  filter: brightness(0.98);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.18),
    0 2px 8px color-mix(in srgb, var(--accent) 28%, transparent);
}
.auth-card__footer {
  margin: 1rem 0 0;
  text-align: center;
}
.auth-card__hint {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.portal-alert {
  margin-bottom: 1.25rem; padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 0.9375rem; line-height: 1.45;
}
.portal-alert--error {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 40%, transparent);
  color: var(--text-primary);
}
.portal-alert__title {
  display: block; margin-bottom: 0.2rem; font-weight: 600; color: var(--error);
}
.portal-alert__message { color: var(--text-primary); }
.portal-alert--success {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 40%, transparent);
  color: var(--text-primary);
}
.auth-panel[hidden] { display: none !important; }
.auth-card__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.auth-card__link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.auth-card__link-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.auth-card__back {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}
.auth-card__back:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.auth-field-error {
  margin: -0.5rem 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--error);
}
@media (max-width: 900px) { .chip-grid { grid-template-columns: repeat(2, 1fr); } }

/* Portal help center */
.portal-help-index__header { margin-bottom: 1.5rem; max-width: 40rem; }
.portal-help-index__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
}
.portal-help-index__lead {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.55;
}
.portal-help-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 24rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.portal-help-search__label {
  display: flex;
  color: var(--text-muted);
  flex-shrink: 0;
}
.portal-help-search__input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9375rem;
  outline: none;
  min-width: 0;
}
.portal-help-search__input::placeholder { color: var(--text-muted); }
.portal-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.75rem;
  max-width: 56rem;
}
.portal-help-card {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1rem 1.125rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.portal-help-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--bg-hover);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--shadow, #000) 8%, transparent);
}
.portal-help-card__icon {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 0.1rem;
}
.portal-help-card__body { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.portal-help-card__title { font-weight: 600; font-size: 1rem; line-height: 1.3; }
.portal-help-card__desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.portal-help-no-results {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.portal-help-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}
.portal-help-back:hover { color: var(--accent-hover); text-decoration: underline; }
.portal-help-article-page__title {
  margin: 0 0 1.25rem;
  font-size: 1.75rem;
  line-height: 1.25;
  max-width: 45rem;
}
.portal-help-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}
.portal-help-article-layout--with-toc {
  grid-template-columns: minmax(0, 1fr) 14rem;
  max-width: 56rem;
}
.portal-help-article-layout__main { min-width: 0; }
.portal-help-article {
  max-width: 45rem;
  line-height: 1.65;
  color: var(--text-primary);
  font-size: 1rem;
}
.portal-help-article > *:first-child { margin-top: 0; }
.portal-help-article h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--text-primary);
  scroll-margin-top: 1rem;
}
.portal-help-article h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.0625rem;
  scroll-margin-top: 1rem;
}
.portal-help-article p { margin: 0 0 1rem; color: var(--text-primary); }
.portal-help-article ul,
.portal-help-article ol {
  margin: 0 0 1rem 1.25rem;
  padding: 0;
  color: var(--text-primary);
}
.portal-help-article li { margin-bottom: 0.35rem; }
.portal-help-article li > ul,
.portal-help-article li > ol { margin-top: 0.35rem; margin-bottom: 0; }
.portal-help-article strong { font-weight: 600; color: var(--text-primary); }
.portal-help-article a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.portal-help-article a:hover { color: var(--accent-hover); }
.portal-help-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}
.portal-help-article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.12em 0.35em;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.portal-help-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
}
.portal-help-article th,
.portal-help-article td {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.portal-help-article th {
  background: var(--bg-elevated);
  font-weight: 600;
}
.portal-help-article tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-surface) 60%, transparent);
}
.portal-help-toc {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
}
.portal-help-toc__label {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.portal-help-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.portal-help-toc__item { margin-bottom: 0.35rem; }
.portal-help-toc__item--h3 { padding-left: 0.75rem; }
.portal-help-toc__item a {
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.4;
}
.portal-help-toc__item a:hover { color: var(--accent); }
.portal-help-toc-mobile {
  display: none;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.portal-help-toc-mobile__label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.portal-help-toc-mobile__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.875rem;
}
.portal-help-toc-mobile__list a {
  color: var(--accent);
  text-decoration: none;
}
.portal-help-toc-mobile__list a:hover { text-decoration: underline; }
.portal-avatar-menu a.is-active {
  background: var(--bg-hover);
  color: var(--accent);
}
@media (max-width: 768px) {
  .portal-help-article-layout--with-toc {
    grid-template-columns: 1fr;
  }
  .portal-help-toc { display: none; }
  .portal-help-toc-mobile { display: block; }
  .portal-help-grid { grid-template-columns: 1fr; }
}

/* Portal floating actions (to top + quick message) */
.portal-fab-stack {
  position: fixed;
  z-index: 900;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
  pointer-events: none;
}
.portal-fab-stack > * {
  pointer-events: auto;
}
.portal-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--shadow, #000) 18%, transparent);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, opacity 0.2s ease;
}
.portal-fab:hover {
  background: var(--bg-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent-hover, var(--accent));
}
.portal-fab:active {
  transform: scale(0.96);
}
.portal-fab--top {
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.35rem);
}
.portal-fab--top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.portal-fab--top:not(.is-visible) {
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .portal-fab--top {
    transition: opacity 0.1s ease;
  }
}
.portal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
}
.portal-modal[hidden] {
  display: none !important;
}
.portal-modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #000 45%, transparent);
}
.portal-modal__panel {
  position: relative;
  width: 100%;
  max-width: 28rem;
  max-height: min(90vh, 32rem);
  overflow: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px color-mix(in srgb, var(--shadow, #000) 22%, transparent);
}
.portal-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 0;
}
.portal-modal__title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}
.portal-modal__close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.portal-modal__close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.portal-modal__body {
  padding: 0 1.25rem 1.25rem;
}
.portal-modal__lead {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.portal-modal__error {
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--error);
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 35%, transparent);
}
.portal-modal__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}
.portal-modal__input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.9375rem;
}
.portal-modal__textarea {
  resize: vertical;
  min-height: 6rem;
}
.portal-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.25rem;
}
.portal-toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}
.portal-toast--success {
  background: color-mix(in srgb, var(--success, #22c55e) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--success, #22c55e) 40%, transparent);
  color: var(--text-primary);
}
.portal-toast--error {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--error) 40%, transparent);
  color: var(--error);
}
.portal-fab-toast {
  position: fixed;
  z-index: 1100;
  top: max(4.5rem, calc(env(safe-area-inset-top, 0px) + 3.5rem));
  right: max(1rem, env(safe-area-inset-right, 0px));
  left: max(1rem, env(safe-area-inset-left, 0px));
  margin: 0 auto;
  max-width: 24rem;
  margin-left: auto;
  animation: portal-fab-toast-out 4s forwards;
}
@keyframes portal-fab-toast-out {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

.support-sla {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}

.support-sla--green {
  background: color-mix(in srgb, var(--success, #22c55e) 18%, transparent);
  color: var(--text-primary);
}

.support-sla--amber {
  background: color-mix(in srgb, var(--warning, #f59e0b) 18%, transparent);
  color: var(--text-primary);
}

.support-sla--red {
  background: color-mix(in srgb, var(--error) 18%, transparent);
  color: var(--text-primary);
}

.support-note-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  color: var(--text-secondary);
}

.support-note-badge--internal {
  opacity: 0.75;
}

.row-show-client {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.visibility-toggle.is-visible {
  color: var(--accent);
}
