:root {
  --bg: #181a1f;
  --bg-soft: #20242c;
  --panel: #242b36;
  --panel-2: #2f3745;
  --ink: #f4f7fb;
  --muted: #a9b3c2;
  --line: rgba(255, 255, 255, 0.09);
  --primary: #3b82f6;
  --primary-2: #275cc2;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --formal: #8b5cf6;
  --radius: 20px;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.12), transparent 30%),
    linear-gradient(180deg, #17191d 0%, #1b2028 100%);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #161b22;
  color: var(--ink);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

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

button {
  border: 0;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    background 0.18s ease;
}

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

button:active {
  transform: translateY(0);
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.app-shell {
  width: min(1160px, 94vw);
  margin: 0 auto;
  padding: 20px 0 42px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(560px, 100%);
  background: rgba(36, 43, 54, 0.96);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 16px;
}

.auth-card--wide {
  width: min(620px, 100%);
}

.brand-lockup {
  display: grid;
  gap: 10px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  color: #cbe0ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.screen {
  display: none;
}

.screen--active {
  display: block;
}

.hidden {
  display: none !important;
}

.topbar,
.topline,
.plain-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.topbar {
  background: rgba(36, 43, 54, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 22px;
}

.topbar__title {
  font-size: 1.2rem;
  font-weight: 800;
}

.topbar__meta {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
  word-break: break-word;
}

.topbar__actions,
.inline-action-group,
.filter-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.panel,
.question-card,
.summary-box,
.result-box,
.summary-panel,
.notice-card {
  background: rgba(36, 43, 54, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.notice-card {
  margin: 18px 0 24px;
}

.notice-card p {
  margin: 8px 0 0;
  color: #d7e4ff;
  line-height: 1.65;
}

.notice-card--subtle {
  margin-top: 0;
  margin-bottom: 24px;
}

.card-grid,
.form-grid,
.summary-list,
.action-grid,
.grid-two,
.admin-grid,
.compact-form-grid {
  display: grid;
  gap: 14px;
}

.home-grid {
  grid-template-columns: 1fr;

  /* grid-template-columns: repeat(4, minmax(0, 1fr)); */
}

.grid-two,
.admin-grid {
  grid-template-columns: 1fr 1fr;
}

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

.two-col-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-block {
  display: grid;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.type-card,
.primary-btn,
.secondary-btn,
.pass-btn,
.fail-btn,
.delete-btn,
.back-btn,
.filter-tab {
  color: var(--ink);
}

.type-card {
  width: 100%;
  min-height: 108px;
  border-radius: var(--radius);
  background: rgba(36, 43, 54, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 800;
  padding: 18px;
  text-align: left;
}

.type-card--secondary,
.secondary-btn,
.filter-tab {
  background: var(--panel-2);
}

.primary-btn,
.secondary-btn,
.pass-btn,
.fail-btn,
.delete-btn {
  min-height: 48px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.secondary-btn {
  color: var(--ink);
}

.pass-btn {
  background: var(--good);
  color: #fff;
}

.fail-btn,
.delete-btn {
  background: var(--bad);
  color: #fff;
}

.full-width {
  width: 100%;
}

.table-action-btn {
  min-height: 38px;
  padding: 0 14px;
}

.back-btn,
button[data-back],
#setupBackBtn,
#summaryBackBtn,
#registerBackBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-weight: 800;
  line-height: 1;
  width: fit-content;
}

.filter-tabs {
  margin-bottom: 18px;
}

.filter-tab {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 800;
}

.filter-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.message-box {
  min-height: 24px;
  font-weight: 700;
  color: var(--muted);
}

.message-box--error {
  color: #ffadad;
}

.message-box--success {
  color: #9fe870;
}

.auth-note {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.rule-panel,
.question-hint {
  color: #d6e3ff;
  line-height: 1.6;
}

.inspection-kind-preview,
.inspection-class-badge,
.status-chip,
.question-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: fit-content;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.inspection-kind-preview,
.inspection-class-badge {
  background: rgba(255, 255, 255, 0.08);
  color: #d2d8e2;
}

.inspection-kind-preview.is-formal,
.inspection-class-badge.is-formal {
  background: rgba(139, 92, 246, 0.18);
  color: #dbc8ff;
}

.inspection-kind-preview.is-routine,
.inspection-class-badge.is-routine {
  background: rgba(59, 130, 246, 0.18);
  color: #cbe0ff;
}

.status-chip.pass,
.status-chip.passed,
.question-status.pass {
  background: rgba(34, 197, 94, 0.18);
  color: #9be9b2;
}

.status-chip.fail,
.status-chip.failed,
.question-status.fail {
  background: rgba(239, 68, 68, 0.18);
  color: #ffb3b3;
}

.status-chip.pending,
.status-chip.new,
.question-status.pending {
  background: rgba(255, 255, 255, 0.08);
  color: #d2d8e2;
}

.status-chip.formalinspectionexpired,
.status-chip.expired {
  background: rgba(245, 158, 11, 0.18);
  color: #ffd58d;
}

.status-chip.formalinspectionduesoon,
.status-chip.duesoon {
  background: rgba(59, 130, 246, 0.18);
  color: #b5d2ff;
}

.status-chip.formalinspectionrequired {
  background: rgba(139, 92, 246, 0.18);
  color: #dbc8ff;
}

.question-type {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 12px 0 18px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7fb1ff);
  border-radius: inherit;
  transition: width 0.2s ease;
}

.action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.photo-preview {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: block;
}

.table-wrap,
.admin-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-list {
  margin-top: 8px;
}

.summary-row {
  display: grid;
  gap: 6px;
}

.summary-row strong {
  color: var(--ink);
}

.summary-row span {
  color: var(--muted);
  line-height: 1.5;
}

.summary-row--highlight {
  padding: 14px;
  border-radius: 16px;
  background: rgba(59, 130, 246, 0.12);
}

.summary-row--highlight span {
  color: #dbe9ff;
  font-weight: 800;
}

.history-section {
  margin-top: 22px;
}

.history-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.02);
  line-height: 1.6;
}

.formal-history {
  border-color: rgba(139, 92, 246, 0.35);
}

.routine-history {
  border-color: rgba(59, 130, 246, 0.35);
}

.empty-cell,
.muted-inline {
  color: var(--muted);
}

.stack-on-mobile {
  align-items: flex-start;
}

.full-width-on-mobile {
  width: fit-content;
}

/* CLIENT TOPBAR */
.client-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  width: min(1160px, 94vw);
  margin: 18px auto 0;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(36, 43, 54, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.client-topbar__left {
  display: grid;
  gap: 6px;
}

.client-topbar__meta {
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

/* ADMIN */
.admin-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

#adminDashboardWrap {
  display: none;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 24px;
}

.summary-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: stretch;
}

.summary-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 22px;
  border-radius: 24px;
}

.summary-panel input,
.summary-panel select,
.summary-panel textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 54px;
  height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  box-sizing: border-box;
}

.summary-panel select {
  padding-right: 44px;
}

.summary-panel textarea {
  min-height: 120px;
  height: auto;
  padding: 14px 16px;
}

.summary-panel .primary-btn,
.summary-panel .secondary-btn {
  min-height: 52px;
}

/* SETUP SCREEN SPACING / MOBILE */
#screen-inspection-setup .panel,
#screen-inspection-setup .summary-box,
#screen-inspection-setup .result-box {
  padding: 22px;
  margin-bottom: 22px;
}

#screen-inspection-setup .field-block {
  gap: 10px;
  margin-bottom: 22px;
}

#screen-inspection-setup .field-label {
  font-size: 0.98rem;
  line-height: 1.3;
}

#screen-inspection-setup input,
#screen-inspection-setup select,
#screen-inspection-setup textarea {
  width: 100%;
  min-height: 62px;
  height: 62px;
  padding: 0 18px;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.2;
  box-sizing: border-box;
}

#screen-inspection-setup select,
#setupQualification {
  min-height: 62px !important;
  height: 62px !important;
  padding: 0 52px 0 18px !important;
  border-radius: 18px !important;
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #d7dfec 50%),
    linear-gradient(135deg, #d7dfec 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
}

#screen-inspection-setup input[type="date"] {
  min-height: 62px;
  height: 62px;
  padding-right: 16px;
}

#inspectionRuleCard,
.rule-panel {
  margin-top: 0;
  margin-bottom: 22px;
  padding: 20px 22px;
  line-height: 1.65;
}

#beginChecklistBtn {
  min-height: 62px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 1.04rem;
  font-weight: 800;
}

/* ANALYTICS */
.analytics-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.analytics-cards .summary-box {
  display: grid;
  gap: 8px;
  min-height: 120px;
  align-content: start;
}

.analytics-cards .summary-box strong {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.analytics-cards .summary-box span {
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--ink);
}

#screen-analytics .summary-panel {
  margin-bottom: 18px;
}

#screen-analytics h2 {
  margin-bottom: 8px;
}

#screen-analytics .lead {
  margin-bottom: 22px;
}

@media (max-width: 1180px) {
  .analytics-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .home-grid,
  .grid-two,
  .admin-grid,
  .two-col-summary {
    grid-template-columns: 1fr;
  }

  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100%, 100vw);
    padding: 14px 14px 34px;
  }

  .client-topbar {
    width: calc(100% - 28px);
    margin-top: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar,
  .topline,
  .plain-topbar,
  .stack-on-mobile,
  .admin-topbar {
    flex-direction: column;
  }

  .topbar__actions,
  .inline-action-group,
  .filter-tabs {
    width: 100%;
  }

  .topbar__actions > *,
  .inline-action-group > *,
  .filter-tabs > * {
    flex: 1 1 auto;
  }

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

  .full-width-on-mobile {
    width: 100%;
  }

  .auth-card {
    padding: 22px;
    border-radius: 22px;
  }

  .panel,
  .question-card,
  .summary-box,
  .result-box,
  .summary-panel,
  .notice-card {
    padding: 16px;
  }

  .type-card {
    min-height: 92px;
  }

  #screen-inspection-setup .panel,
  #screen-inspection-setup .summary-box,
  #screen-inspection-setup .result-box {
    padding: 18px;
    margin-bottom: 22px;
  }

  #screen-inspection-setup input,
  #screen-inspection-setup select,
  #screen-inspection-setup textarea,
  #setupQualification {
    min-height: 58px !important;
    height: 58px !important;
    font-size: 16px !important;
  }

  #beginChecklistBtn {
    width: 100%;
    min-height: 58px;
  }

  .back-btn,
  button[data-back],
  #setupBackBtn,
  #summaryBackBtn,
  #registerBackBtn {
    min-height: 50px;
    padding: 0 16px;
    margin-bottom: 18px;
  }

  .summary-panel input,
  .summary-panel select,
  .summary-panel textarea {
    font-size: 16px;
  }

  .analytics-cards {
    grid-template-columns: 1fr 1fr;
  }

  table {
    min-width: 700px;
  }
}

@media (max-width: 560px) {
  .home-grid,
  .analytics-cards {
    grid-template-columns: 1fr;
  }

  .client-topbar__meta {
    font-size: 0.95rem;
  }

  .analytics-cards .summary-box {
    min-height: auto;
  }
}
/* =========================
   BUTTON + PANEL SPACING FIXES
   ========================= */

.panel {
  display: grid;
  gap: 18px;
}

.panel .primary-btn,
.panel .secondary-btn,
.panel .delete-btn,
.panel .pass-btn,
.panel .fail-btn {
  margin-top: 6px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 24px;
  font-weight: 800;
}

.back-btn + h2,
.back-btn + h1 {
  margin-top: 6px;
}

#screen-search .panel,
#screen-start-lookup .panel {
  padding: 26px;
  gap: 18px;
}

#screen-search input,
#screen-start-lookup input {
  margin-bottom: 6px;
}

#screen-search .primary-btn,
#screen-start-lookup .primary-btn {
  width: fit-content;
  min-width: 160px;
}

.topline,
.inline-action-group {
  gap: 14px;
}

.action-grid {
  gap: 14px;
}

@media (max-width: 760px) {
  .back-btn {
    min-height: 52px;
    padding: 0 20px;
    margin-bottom: 20px;
  }

  #screen-search .panel,
  #screen-start-lookup .panel {
    padding: 18px;
    gap: 16px;
  }

  #screen-search .primary-btn,
  #screen-start-lookup .primary-btn {
    width: 100%;
    min-width: 0;
  }
}
/* =========================
   AUTH BUTTON SPACING FIX
   ========================= */

#platformAdminLoginBtn,
#companyAdminLoginBtn,
#clientLoginBtn,
#adminLoginBtn {
  margin-top: 14px;
}

#platformLoginScreen .field-block:last-of-type,
#companyAdminLoginScreen .field-block:last-of-type,
#clientLoginScreen .field-block:last-of-type,
#adminLoginScreen .field-block:last-of-type {
  margin-bottom: 4px;
}
