:root {
  --portal-border: #d4dbe4;
}

.admin-shell {
  padding-bottom: 3rem;
}

.content {
  padding: 1.6rem 0 2.2rem;
}

.card {
  background: var(--surface);
  padding: 1.6rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid #e7ebf1;
  margin-bottom: 1.4rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.2rem;
  align-items: stretch;
}

.dashboard-grid .card {
  margin-bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.dashboard-grid .dashboard-span {
  grid-column: 1 / -1;
}

.dashboard-friendly .dashboard-hero {
  background: linear-gradient(140deg, #f7fbff 0%, #ffffff 70%);
}

.dashboard-friendly .dashboard-hero h3 {
  margin-bottom: 0.35rem;
}

.dashboard-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.9rem 0 0.6rem;
}

.dashboard-stat .dashboard-kpi {
  margin: 0.2rem 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.dashboard-link-stack {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.dashboard-link-stack a {
  color: var(--accent);
  text-decoration: none;
}

.dashboard-link-stack a:hover {
  text-decoration: underline;
}

@media (max-width: 760px) {
  .dashboard-quick-links .btn,
  .dashboard-quick-links .btn-outline {
    width: 100%;
  }
}

.dashboard-grid .btn,
.dashboard-grid .btn-outline,
.dashboard-grid button {
  min-width: 140px;
}

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

.actions-stack form {
  margin: 0;
}

.actions-stack .btn,
.actions-stack button {
  width: 100%;
}

.admin-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--border);
}

.menu-group {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem;
}

.menu-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.admin-menu a {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.admin-menu a:hover { background: var(--highlight); }

input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
  background: #fff;
}

label { display: block; font-weight: 600; margin-top: 0.7rem; }

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

.checkout-layout {
  display: grid;
  gap: 1.6rem;
}

@media (min-width: 980px) {
  .checkout-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
    align-items: start;
  }
}

.checkout-form {
  gap: 0.65rem;
}

.checkout-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin: 0.4rem 0 1rem;
}

.checkout-steps .step {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.checkout-steps .step.active {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 23, 32, 0.08);
}

.checkout-summary {
  align-self: start;
  position: sticky;
  top: 1.5rem;
}

@media (max-width: 980px) {
  .checkout-summary {
    position: static;
  }
}

.checkout-section {
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.checkout-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.checkout-section h4 {
  margin: 0 0 0.4rem;
}

.checkout-row {
  display: grid;
  gap: 0.6rem;
}

@media (min-width: 640px) {
  .checkout-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
  border-bottom: 1px dashed rgba(15, 23, 32, 0.08);
}

.summary-total {
  font-weight: 700;
  font-size: 1.05rem;
  margin-top: 0.6rem;
}

.summary-next {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.summary-terms {
  background: var(--highlight);
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  margin-top: 0.5rem;
}

.summary-trust {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.order-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  background: #fff;
}

.order-item-table {
  width: 100%;
  border-collapse: collapse;
}

.order-item-table th {
  text-align: left;
  width: 140px;
  color: var(--muted);
  font-weight: 600;
  padding: 0.4rem 0.5rem 0.4rem 0;
  vertical-align: top;
}

.order-item-table td {
  padding: 0.4rem 0;
}

@media (max-width: 720px) {
  .order-item-table th,
  .order-item-table td {
    display: block;
    width: 100%;
  }

  .order-item-table th {
    padding-bottom: 0.1rem;
  }
}

.address-results {
  display: none;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.address-results button {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-radius: 0;
  border: none;
  background: #fff;
  color: var(--text);
  font-weight: 500;
  margin-top: 0;
}

.address-results button:hover {
  background: var(--highlight);
  color: var(--text);
}

.impersonation-banner {
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  padding: 0.4rem 0;
}

.impersonation-banner .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.impersonation-banner .btn-outline {
  border-color: #fff;
  color: #fff;
}

button {
  margin-top: 16px;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: 2px solid transparent;
  font-weight: 600;
  cursor: pointer;
}

button:hover { background: var(--accent-strong); }

button.btn-outline,
button.btn-outline:visited {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 720px) {
  .card {
    padding: 1.2rem;
  }

  .btn,
  button {
    width: 100%;
  }

  .summary-line {
    flex-direction: column;
    align-items: flex-start;
  }
}

.btn,
button.btn,
button.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  line-height: 1;
  padding: 0.5rem 1.1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

@media (max-width: 900px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

table thead th {
  text-align: left;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0.5rem;
}

table tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.5rem;
}

table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.inline-form {
  display: inline-block;
  margin-left: 6px;
}

.invoice-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
}

.invoice-header p {
  margin: 0.15rem 0;
}

.invoice-brand {
  max-width: 320px;
}

.invoice-company {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.invoice-meta {
  text-align: right;
}

.invoice-title {
  font-size: 2rem;
  font-weight: 700;
  color: #4e535c;
  margin-bottom: 0.2rem;
}

.invoice-table thead th {
  background: #0d83dd;
  color: #fff;
  border-bottom: none;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.invoice-table tbody td {
  border-bottom: 1px solid var(--border);
}

.invoice-totals {
  display: flex;
  justify-content: flex-end;
  gap: 2rem;
  margin-top: 1rem;
}

.invoice-totals p {
  margin: 0.2rem 0;
}

.invoice-billto {
  margin: 1.2rem 0 1.6rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  max-width: 360px;
}

.invoice-billto h4 {
  margin: 0 0 0.5rem;
}

.invoice-notes {
  margin-top: 1.4rem;
}

.invoice-notes p {
  margin: 0.35rem 0;
}

.modal[aria-hidden="true"] { display: none; }
.modal[aria-hidden="false"] { display: block; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 40;
}

.modal-card {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 1.2rem;
  z-index: 41;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.error { color: #b42318; margin-top: 8px; }
.notice { color: var(--muted); margin-top: 8px; }
.muted { color: var(--muted); }

.alert-banner {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #cbd5f5;
  background: linear-gradient(135deg, rgba(79, 112, 255, 0.12), rgba(56, 189, 248, 0.12));
  color: #1e293b;
  font-weight: 600;
}

.alert-banner p {
  margin: 0.2rem 0 0;
  font-weight: 500;
  color: #334155;
}

.spinner-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #cbd5f5;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.payment-box {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.card-element {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--portal-border);
  background: #fff;
}

.notice-row td {
  background: #eef2ff;
  color: #1e293b;
  font-weight: 600;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.status-paid {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.status-due {
  color: #9a3412;
  background: #ffedd5;
  border-color: #fed7aa;
}

.status-overdue {
  color: #b42318;
  background: #fee2e2;
  border-color: #fecaca;
}

.status-cancelled {
  color: #475569;
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.status-waived {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: help;
}

.region-note {
  margin: 6px 0 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f7fb;
  border: 1px solid var(--portal-border);
  color: #3b4452;
  font-size: 0.9rem;
}

.ticket-thread {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
}

.ticket-message {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  background: #f9fafb;
}

.ticket-meta {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

.ticket-meta strong { color: var(--text); }

.ticket-body { white-space: pre-wrap; line-height: 1.5; }

.ticket-attachments {
  margin-top: 0.6rem;
  font-size: 0.9rem;
}

.ticket-attachments ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.wysiwyg {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: #f0f4fa;
}

.wysiwyg-toolbar button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
}

.wysiwyg-editor {
  min-height: 160px;
  padding: 0.8rem;
  outline: none;
}

.wysiwyg-fallback {
  width: 100%;
  min-height: 160px;
  padding: 0.8rem;
  border: none;
  display: none;
}

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