:root {
  --navy: #0a1e46;
  --navy-2: #102f69;
  --red: #e6000a;
  --paper: #f4f6f9;
  --white: #fff;
  --text: #15213d;
  --muted: #69758b;
  --line: #dfe5ee;
  --success: #17743b;
  --warning: #8a5a00;
  --danger: #a00007;
  --shadow: 0 18px 50px rgba(10, 30, 70, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
}

.portal-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 8%, rgba(230, 0, 10, 0.07), transparent 24rem),
    var(--paper);
}

.portal-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  padding: 13px clamp(20px, 4vw, 64px);
  backdrop-filter: blur(16px);
}

.portal-logo img {
  display: block;
  width: 195px;
  max-width: 50vw;
}

.portal-header nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 13px;
  font-weight: 750;
}

.portal-header nav a {
  text-decoration: none;
}

.portal-main {
  width: min(1280px, calc(100% - 40px));
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: 52px 0 90px;
}

.portal-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  background: var(--navy);
  color: #c7d1e3;
  padding: 24px clamp(20px, 4vw, 64px);
  font-size: 12px;
}

.portal-eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.portal-main h1 {
  margin: 0 0 32px;
  color: var(--navy);
  font-size: clamp(38px, 5vw, 68px);
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.portal-main h2,
.portal-main h3 {
  margin-top: 0;
  color: var(--navy);
  line-height: 1.15;
}

.portal-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--white);
  padding: 24px;
  box-shadow: 0 12px 35px rgba(10, 30, 70, 0.06);
}

.portal-alert {
  margin: 0 auto 18px;
  border: 1px solid #bee6cc;
  border-radius: 12px;
  background: #ecf9f1;
  color: var(--success);
  padding: 14px 16px;
  font-weight: 700;
}

.global-portal-announcement {
  margin: 1rem auto 0;
  max-width: 1180px;
}

.portal-alert.error {
  border-color: #f0bec2;
  background: #fff0f1;
  color: var(--danger);
}

.portal-alert.info {
  border-color: #f0daa8;
  background: #fff8e6;
  color: var(--warning);
}

.portal-form {
  display: grid;
}

.portal-form label {
  margin: 13px 0 6px;
  color: #253451;
  font-size: 13px;
  font-weight: 800;
}

.portal-form input,
.portal-form select,
.portal-form textarea,
.inline-admin-form input,
.inline-admin-form select,
.inline-admin-form textarea,
.table-form select {
  width: 100%;
  border: 1px solid #cfd7e4;
  border-radius: 11px;
  outline: 0;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  font: inherit;
}

.portal-form input:focus,
.portal-form select:focus,
.portal-form textarea:focus,
.inline-admin-form textarea:focus {
  border-color: var(--navy-2);
  box-shadow: 0 0 0 3px rgba(16, 47, 105, 0.1);
}

.portal-form textarea {
  min-height: 120px;
  resize: vertical;
}

.portal-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  border: 1px solid #bfc9d9;
  border-radius: 11px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  padding: 11px 17px;
  font-weight: 850;
  text-decoration: none;
}

.portal-button.primary {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 10px 24px rgba(230, 0, 10, 0.2);
}

.portal-button.is-disabled {
  border-color: #d9dfe7;
  background: #eef1f5;
  color: #667085;
  cursor: default;
}

.portal-button:hover {
  transform: translateY(-1px);
}

.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-wrap {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(520px, 1.25fr);
  gap: clamp(35px, 6vw, 90px);
  align-items: start;
}

.auth-intro {
  position: sticky;
  top: 130px;
  padding-top: 30px;
}

.auth-intro h1 {
  margin-bottom: 24px;
}

.auth-intro p {
  color: var(--muted);
  line-height: 1.7;
}

.auth-intro a {
  color: var(--red);
  font-weight: 800;
}

.auth-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.reset-form {
  grid-column: 1 / -1;
}

.installer-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background:
    radial-gradient(circle at 85% 10%, rgba(230, 0, 10, 0.1), transparent 22rem),
    linear-gradient(135deg, #eef2f8, #fff);
  padding: 24px;
}

.installer-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  padding: clamp(26px, 5vw, 48px);
  box-shadow: var(--shadow);
}

.installer-card > img {
  width: 230px;
  max-width: 70%;
  margin-bottom: 34px;
}

.installer-card h1 {
  margin-bottom: 12px;
  color: var(--navy);
  font-size: clamp(34px, 7vw, 52px);
  letter-spacing: -0.05em;
  line-height: 1;
}

.installer-card > p {
  color: var(--muted);
  line-height: 1.7;
}

.install-success {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 50%;
  background: #e6f8ed;
  color: var(--success);
  font-size: 28px;
}

.installer-note {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  font-size: 12px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(28px, 5vw, 68px);
  align-items: start;
}

.dashboard-sidebar {
  position: sticky;
  top: 110px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(10, 30, 70, 0.05);
}

.dashboard-sidebar h2 {
  margin-bottom: 4px;
}

.dashboard-sidebar > p:not(.portal-eyebrow) {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
}

.dashboard-sidebar nav {
  display: grid;
  gap: 5px;
  margin-top: 24px;
}

.dashboard-sidebar nav a {
  border-radius: 9px;
  color: #4a5871;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.dashboard-sidebar nav a:hover,
.dashboard-sidebar nav a.active {
  background: #eef2f8;
  color: var(--navy);
}

.dashboard-sidebar nav a.active {
  box-shadow: inset 3px 0 var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.metric-grid > div {
  display: grid;
  min-height: 128px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 18px;
}

.metric-grid strong {
  color: var(--red);
  font-size: 35px;
  letter-spacing: -0.05em;
}

.metric-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-metrics {
  grid-template-columns: repeat(5, 1fr);
}

.admin-metrics strong {
  font-size: clamp(20px, 2.3vw, 34px);
}

.portal-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.card-heading,
.record-title,
.record-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.card-heading a {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.record-list {
  display: grid;
}

.record-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.record-list span {
  min-width: 0;
}

.record-list strong,
.record-list small {
  display: block;
}

.record-list small {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

.record-list p {
  margin: 8px 0 0;
  color: #45516a;
  font-size: 12px;
  line-height: 1.55;
}

.record-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.record-actions a {
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  flex: 0 0 auto;
  border-radius: 100px;
  background: #edf0f4;
  color: #566176;
  padding: 6px 9px;
  font-size: 9px;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status.new,
.status.open,
.status.pending,
.status.awaiting_configuration {
  background: #fff0f1;
  color: #a51d28;
}

.status.contacted,
.status.processing,
.status.in_progress,
.status.waiting_client,
.status.scheduled {
  background: #eaf1ff;
  color: #24569a;
}

.status.qualified,
.status.active,
.status.paid,
.status.confirmed,
.status.won,
.status.completed,
.status.resolved {
  background: #e8f8ee;
  color: #19713a;
}

.status.closed,
.status.cancelled,
.status.failed,
.status.suspended,
.status.expired,
.status.refunded {
  background: #eef0f3;
  color: #667083;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.plan-card {
  display: flex;
  flex-direction: column;
}

.plan-card p {
  color: var(--muted);
  line-height: 1.65;
}

.plan-price {
  display: block;
  color: var(--red);
  font-size: 28px;
}

.plan-card > small {
  color: var(--muted);
}

.plan-card ul {
  flex: 1;
  padding-left: 18px;
  color: #4b5770;
  font-size: 13px;
}

.plan-card label {
  margin: 8px 0 5px;
  font-size: 12px;
  font-weight: 800;
}

.plan-card select {
  width: 100%;
  border: 1px solid #cfd7e4;
  border-radius: 10px;
  padding: 11px;
}

.admin-records {
  display: grid;
  gap: 15px;
}

.admin-record {
  box-shadow: none;
}

.record-title h2,
.record-title p {
  margin-bottom: 4px;
}

.record-title p,
.admin-record > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.record-details {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 15px 0;
  border-block: 1px solid var(--line);
  padding: 12px 0;
  font-size: 12px;
}

.record-details a {
  color: var(--red);
}

.inline-admin-form {
  display: grid;
  grid-template-columns: 170px minmax(250px, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin-top: 20px;
}

.inline-admin-form textarea {
  min-height: 80px;
  resize: vertical;
}

.inline-admin-form .portal-button {
  margin-top: 0;
}

.inline-admin-form.compact {
  grid-template-columns: 190px auto;
}

.section-heading {
  margin: 44px 0 16px !important;
}

.check-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.check-label input {
  width: auto;
}

.system-checks {
  margin: 0;
  padding: 0;
  list-style: none;
}

.system-checks li {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
  font-size: 12px;
}

.system-checks strong {
  color: var(--success);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table th {
  background: #eef2f8;
  color: #58647a;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-align: left;
  text-transform: uppercase;
}

.admin-table th,
.admin-table td {
  min-width: 120px;
  border-bottom: 1px solid var(--line);
  padding: 13px;
  vertical-align: top;
}

.admin-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.table-form {
  display: flex;
  gap: 6px;
}

.table-form select {
  min-width: 100px;
  padding: 7px;
  font-size: 11px;
}

.table-form button {
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  cursor: pointer;
  padding: 7px 10px;
}

.content-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.settings-section {
  margin-bottom: 1.25rem;
}

.danger-zone {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(160, 0, 7, 0.18);
}

.portal-button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.login-choice-wrap {
  align-items: stretch;
}

.login-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.login-choice-card {
  display: flex;
  min-height: 330px;
  flex-direction: column;
}

.login-choice-card > p:not(.portal-eyebrow) {
  flex: 1;
}

.login-choice-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 1.2rem;
  place-items: center;
  border-radius: 14px;
  background: #f1f5f9;
  color: var(--navy);
  font-size: 1.2rem;
}

.admin-choice .login-choice-icon {
  background: #fff0f1;
  color: var(--danger);
}

.product-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.1rem;
}

.portal-product-card {
  display: flex;
  flex-direction: column;
}

.portal-product-card > p {
  flex: 1;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.access-instructions {
  margin-top: 0.75rem;
  padding: 0.8rem;
  border-radius: 10px;
  background: #f5f7fa;
}

@media (max-width: 760px) {
  .login-choice-grid {
    grid-template-columns: 1fr;
  }
}

.new-content {
  border-style: dashed;
}

@media (max-width: 1050px) {
  .admin-metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .plan-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .portal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-header nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    white-space: nowrap;
  }

  .auth-wrap,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .auth-intro,
  .dashboard-sidebar {
    position: static;
  }

  .dashboard-sidebar nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-grid,
  .admin-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .portal-two-column,
  .content-editor-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 580px) {
  .portal-main {
    width: min(100% - 26px, 1280px);
    padding-top: 34px;
  }

  .portal-footer {
    flex-direction: column;
  }

  .auth-forms,
  .metric-grid,
  .admin-metrics,
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .inline-admin-form,
  .inline-admin-form.compact {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar nav {
    grid-template-columns: 1fr;
  }

  .record-title,
  .card-heading {
    align-items: flex-start;
  }
}
