* { box-sizing: border-box; }

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d9e2ec;
  --border-strong: #c5d0dc;
  --text: #172033;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #d97706;
  --danger: #dc2626;
  --focus: rgba(15, 118, 110, 0.18);
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0 !important;
  min-height: 100vh;
  padding: 20px !important;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif !important;
  font-size: 14px;
  line-height: 1.45;
}

body > h2:first-child {
  margin: 0 0 16px;
  padding: 16px 18px;
  color: #0f172a;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.2;
}

h3 {
  margin: 0 0 12px;
  color: #1e293b;
  font-size: 17px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid #dbe4ee;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
}

hr {
  display: none;
}

section {
  margin: 0 0 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

input,
select,
textarea {
  min-height: 40px;
  max-width: 100%;
  margin: 4px 6px 8px 0 !important;
  padding: 9px 11px !important;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  vertical-align: middle;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
  outline: none;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  color: #334155;
}

label input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  margin: 0 !important;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  max-width: 100%;
  min-width: 0;
  margin: 4px 6px 8px 0;
  padding: 9px 13px !important;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button > *,
a > * {
  min-width: 0;
}

button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.session-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
}

.session-nav button,
.session-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 100%;
  margin: 0 !important;
  padding: 8px 12px !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: #0f172a;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.session-nav button:hover,
.session-nav a:hover {
  border-color: var(--primary);
  background: #ecfdf5;
  color: var(--primary);
  text-decoration: none;
}

.session-nav [data-session-logout] {
  border-color: #fecaca;
  color: #991b1b;
}

.session-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.session-status.session-warning {
  color: #b45309;
}

table {
  width: 100%;
  margin-top: 12px;
  overflow: hidden;
  border-collapse: separate !important;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

th,
td {
  max-width: 280px;
  padding: 10px 12px !important;
  border: 0 !important;
  border-bottom: 1px solid #edf2f7 !important;
  color: #263447;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: 0 !important;
}

th {
  background: var(--surface-soft) !important;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.cards {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
  gap: 12px !important;
  margin: 12px 0 16px !important;
}

.card {
  min-width: 0;
  padding: 14px !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
  color: var(--muted);
}

.card strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 22px !important;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.wizard-steps button {
  margin: 0;
  background: #e2e8f0;
  color: #334155;
}

.wizard-steps button.active {
  background: var(--primary);
  color: #fff;
}

.wizard-panel {
  display: none;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.wizard-panel.active {
  display: grid;
}

.wizard-panel label {
  display: grid;
  align-items: stretch;
  min-height: 0;
  color: #475569;
  font-weight: 800;
}

.wizard-panel input,
.wizard-panel select {
  width: 100%;
  margin-right: 0 !important;
}

.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.wizard-review {
  display: grid;
  gap: 4px;
  min-height: 80px;
  padding: 12px;
  border: 1px solid #dbe4ee;
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
}

.wizard-review strong {
  color: var(--text);
}

.installer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.installer-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.installer-card h4 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.installer-card p {
  margin: 0;
}

.download-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  max-width: 100%;
  padding: 9px 13px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.download-button:hover {
  color: #fff;
  background: var(--primary-dark);
  text-decoration: none;
}

.steps-list {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
}

.steps-list li {
  margin: 6px 0;
}

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px !important;
  overflow-x: hidden;
  background:
    linear-gradient(140deg, rgba(15, 118, 110, 0.10), transparent 42%),
    linear-gradient(320deg, rgba(217, 119, 6, 0.10), transparent 38%),
    var(--bg);
}

.auth-shell {
  width: 100%;
  max-width: 440px;
}

.auth-panel {
  width: min(440px, calc(100vw - 36px));
  max-width: 100%;
  margin: 0;
  padding: 26px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.auth-panel h1 {
  margin: 0;
  color: #0f172a;
  font-size: 28px;
  line-height: 1.15;
}

.auth-support {
  min-height: 20px;
  margin: 0 0 14px;
}

.auth-fields {
  display: grid;
  gap: 7px;
}

.auth-fields label {
  min-height: 0;
  font-size: 13px;
  font-weight: 700;
}

.auth-fields input,
.auth-fields button {
  width: 100%;
  margin: 0 !important;
}

.auth-fields input {
  min-height: 46px;
}

.primary-action {
  min-height: 46px;
  margin-top: 7px !important;
}

.form-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 760px) {
  body {
    padding: 12px !important;
    font-size: 13px;
  }

  body > h2:first-child {
    padding: 14px;
  }

  section {
    padding: 14px;
  }

  input,
  select,
  textarea,
  button {
    width: 100%;
    margin-right: 0 !important;
  }

  label {
    width: 100%;
  }

  label input[type="checkbox"] {
    width: 16px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  th,
  td {
    max-width: 220px;
    white-space: normal;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  }

  .auth-page {
    padding: 14px !important;
  }

  .auth-panel {
    width: min(360px, calc(100vw - 32px));
    max-width: 440px;
    padding: 22px;
  }

}

body.saas-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  padding: 0 !important;
  background: #eef3f7;
}

.saas-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px;
  background: #101827;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.saas-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  margin-bottom: 18px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.saas-brand .brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  background: #0f766e;
  color: #fff;
  font-weight: 900;
}

.saas-brand strong,
.saas-brand small {
  display: block;
  color: #fff;
  line-height: 1.2;
}

.saas-brand small {
  margin-top: 3px;
  color: #cbd5e1;
  font-size: 12px;
}

.saas-nav {
  display: grid;
  gap: 5px;
}

.nav-group-title {
  margin: 16px 8px 5px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.saas-nav-btn {
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  margin: 0 !important;
  padding: 9px 10px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: #e2e8f0 !important;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: none !important;
}

.saas-nav-btn:hover,
.saas-nav-btn.active {
  background: rgba(15, 118, 110, 0.22) !important;
  border-color: rgba(45, 212, 191, 0.32) !important;
  color: #fff !important;
}

.saas-main {
  min-width: 0;
  padding: 22px;
}

.saas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.saas-topbar h1 {
  margin: 0;
  color: #0f172a;
  font-size: 28px;
  line-height: 1.15;
}

.saas-topbar p:last-child {
  max-width: 720px;
  margin: 6px 0 0;
}

.saas-quick-actions,
.quick-link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.secondary-link,
.quick-link-grid a,
.quick-link-grid button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin: 0 !important;
  padding: 8px 12px !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: #0f172a;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.secondary-link:hover,
.quick-link-grid a:hover,
.quick-link-grid button:hover {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f766e;
  text-decoration: none;
}

.secondary-link:focus-visible,
.quick-link-grid a:focus-visible,
.quick-link-grid button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.saas-view a:not(.download-button):not(.secondary-link) {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: #0f766e;
  line-height: 1.2;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.saas-view a:not(.download-button):not(.secondary-link):hover {
  background: #ecfdf5;
  border-color: #0f766e;
  color: #115e59;
}

.saas-view {
  display: none;
  min-width: 0;
  margin: 0;
}

.saas-view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.2;
}

.section-heading p {
  max-width: 560px;
  margin: 2px 0 0;
  text-align: right;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.form-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.form-grid.messaging-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.form-grid button,
.saas-view textarea,
.wizard-panel input,
.wizard-panel select,
.wizard-panel button {
  width: 100%;
  margin: 0 !important;
}

.table-wrap {
  width: 100%;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.table-wrap table {
  margin: 0;
  border: 0;
  box-shadow: none;
}

.table-wrap th:first-child,
.table-wrap td:first-child {
  border-left: 0;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.info-panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.info-panel h3 {
  margin-bottom: 10px;
}

.steps-list {
  margin: 0;
  padding-left: 20px;
  color: #334155;
}

.steps-list li + li {
  margin-top: 7px;
}

.action-card {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 128px;
  cursor: pointer;
  color: #475569;
  text-align: left;
  line-height: 1.25;
}

.action-card strong {
  display: block;
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.action-card small {
  display: block;
  margin-top: 0;
  color: #64748b;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.action-card:hover {
  border-color: #0f766e !important;
  background: #f0fdfa !important;
  color: #0f172a;
}

.action-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0 !important;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  font-weight: 700;
}

.inline-check input {
  width: 16px;
  min-height: 16px;
  margin: 0 !important;
}

.feature-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.feature-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 68px;
  margin: 0 !important;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.feature-check input {
  flex: 0 0 auto;
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0 !important;
}

.feature-check span {
  min-width: 0;
}

.feature-check strong,
.feature-check small {
  display: block;
  overflow-wrap: anywhere;
}

.feature-check small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.saas-view pre {
  max-height: 460px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f172a;
  color: #dbeafe;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  body.saas-shell {
    display: block;
  }

  .saas-sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .saas-nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
  }

  .nav-group-title {
    display: none;
  }

  .saas-nav-btn {
    width: auto;
    flex: 0 1 150px;
    min-width: 112px;
    max-width: 190px;
    white-space: normal;
  }

  .saas-main {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  .saas-topbar,
  .section-heading {
    display: block;
  }

  .saas-topbar h1 {
    font-size: 24px;
  }

  .section-heading p {
    text-align: left;
  }

  .saas-quick-actions {
    margin-top: 12px;
  }

  .secondary-link,
  .quick-link-grid a,
  .quick-link-grid button {
    width: 100%;
    white-space: normal;
  }
}
