:root {
  --paper: #fbf8f0;
  --ink: #24283b;
  --blue: #263f9a;
  --teal: #2f7f7a;
  --red: #a92d2d;
  --green: #197653;
  --line: rgba(47, 59, 114, 0.18);
  --soft: rgba(255, 255, 255, 0.9);
  --muted: rgba(36, 40, 59, 0.66);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(47, 127, 122, 0.12), transparent 34%),
    var(--paper);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  min-height: 38px;
}

.admin-shell {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: clamp(14px, 2.5vw, 34px);
}

.auth-panel {
  width: min(100%, 420px);
  margin: 16vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  box-shadow: 0 14px 34px rgba(36, 40, 59, 0.14);
  padding: 26px;
}

.auth-panel h1,
.admin-header h1,
.tool-panel h2 {
  margin: 0;
  color: var(--blue);
}

.auth-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.admin-language-toggle {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  box-shadow: 0 8px 20px rgba(36, 40, 59, 0.08);
}

.admin-language-toggle button {
  min-width: 34px;
  min-height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(36, 40, 59, 0.62);
  font-size: 0.68rem;
  font-weight: 850;
  cursor: pointer;
}

.admin-language-toggle button.is-active {
  background: var(--blue);
  color: white;
}

.auth-panel p,
.admin-header p,
.tool-panel p {
  color: var(--muted);
}

button,
.header-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
}

.auth-panel button,
.primary-button,
.dialog-actions button:first-child,
.filter-actions button:first-child {
  border: 0;
  background: var(--blue);
  color: white;
}

.auth-panel button {
  width: 100%;
  margin-top: 8px;
}

.status-line {
  min-height: 22px;
  font-weight: 750;
}

.status-line.is-error {
  color: var(--red);
}

.admin-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.admin-header,
.tool-panel,
.admin-tabs {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 28px rgba(36, 40, 59, 0.08);
}

.admin-header {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-weight: 850;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.header-actions,
.section-heading,
.filter-actions,
.compact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-actions {
  justify-content: flex-end;
}

.stacked-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.section-heading {
  align-items: flex-start;
  justify-content: space-between;
}

.header-actions a,
.header-actions button,
.section-heading button,
.filter-actions button,
.row-button,
.dialog-actions button {
  border: 1px solid var(--line);
  background: white;
  color: var(--blue);
  padding: 0 12px;
  text-decoration: none;
}

.row-button.is-danger,
.dialog-actions button.is-danger {
  color: var(--red);
}

.row-button:disabled,
.dialog-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font: inherit;
  font-weight: 850;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link-button.is-selected {
  color: var(--ink);
  text-decoration-thickness: 2px;
}

.run-link {
  white-space: normal;
}

.table-header-link {
  font-size: 0.76rem;
  text-transform: uppercase;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
}

.admin-tabs button {
  flex: 1 0 max-content;
  border: 1px solid transparent;
  background: transparent;
  color: var(--blue);
  padding: 0 13px;
}

.admin-tabs button.is-active {
  background: var(--blue);
  color: white;
}

.tool-panel {
  padding: 16px;
  min-width: 0;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  min-width: 0;
}

.source-change-matrix-wrap {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.source-change-matrix {
  min-width: 540px;
  background: rgba(255, 255, 255, 0.72);
}

.source-change-matrix th,
.source-change-matrix td {
  vertical-align: middle;
}

.source-change-matrix th:not(:first-child),
.source-change-matrix td {
  width: 15%;
  text-align: center;
}

.source-change-matrix .link-button {
  min-height: 0;
  text-align: center;
}

.source-change-matrix tbody th,
.source-change-matrix tfoot th {
  color: var(--ink);
  font-size: 0.88rem;
  text-transform: none;
}

.source-change-matrix tfoot th,
.source-change-matrix tfoot td {
  border-top: 2px solid var(--line);
  border-bottom: 0;
  font-weight: 800;
}

.lifecycle-section + .lifecycle-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.lifecycle-section h3 {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 1rem;
}

.builder-log-panel {
  display: grid;
  gap: 18px;
}

.builder-current-status-panel {
  margin-top: 18px;
}

.builder-current-status-panel:empty {
  display: none;
}

.date-person-links {
  display: grid;
  gap: 4px;
}

.date-person-links .link-button {
  min-height: 0;
  text-align: left;
}

.date-diagnostics-table {
  max-height: min(62vh, 680px);
  overflow: auto;
}

.date-report-print-view {
  display: none;
}

.builder-status-divider {
  height: 0;
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.metric-item {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 4px;
  align-content: stretch;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.metric-item span:first-child {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-item strong {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.95rem;
}

.metric-item > :last-child {
  align-self: end;
}

.metric-item.is-value-centered > :last-child {
  justify-self: center;
  text-align: center;
}

.metric-item .link-button {
  min-height: 0;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}

th {
  color: rgba(36, 40, 59, 0.72);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
}

.label-edit {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 6px;
}

.label-edit input,
.filter-bar input,
.filter-bar select,
.dialog-form input,
.dialog-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: white;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(47, 127, 122, 0.12);
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 800;
}

.pill.is-red {
  background: rgba(169, 45, 45, 0.1);
  color: var(--red);
}

.pill.is-green {
  background: rgba(25, 118, 83, 0.11);
  color: var(--green);
}

.pill.is-blue {
  background: rgba(30, 63, 148, 0.1);
  color: var(--blue);
}

.muted {
  color: var(--muted);
}

.invite-code-inline {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(47, 127, 122, 0.08);
  color: var(--blue);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.empty {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0 4px;
}

#tab-builder .section-heading {
  margin-bottom: 4px;
}

#tab-builder .section-heading p {
  margin-bottom: 0;
}

#tab-builder .filter-bar {
  margin-top: 0;
}

.filter-bar label,
.dialog-form label,
.setting-inline label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.setting-inline {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.setting-row {
  display: inline-grid;
  grid-template-columns: 92px auto auto;
  gap: 8px;
  align-items: center;
}

.setting-row input {
  width: 92px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 9px;
  background: white;
}

.setting-row button {
  border: 1px solid var(--line);
  background: white;
  color: var(--blue);
  padding: 0 12px;
}

.mini-status {
  min-height: 18px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 750;
}

.mini-status.is-error {
  color: var(--red);
}

.session-group {
  min-width: 760px;
  border-top: 1px solid var(--line);
  padding: 12px 0 2px;
}

.session-group:first-child {
  border-top: 0;
}

.session-group-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.session-group h3 {
  margin: 0;
  color: var(--blue);
  font-size: 1rem;
}

.session-bulk-button {
  margin-top: 8px;
}

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 24, 42, 0.36);
}

.modal-host[hidden] {
  display: none;
}

.dialog {
  position: relative;
  width: min(100%, 470px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 18px 48px rgba(20, 24, 42, 0.25);
  padding: 18px;
}

.dialog.is-wide {
  width: min(100%, 640px);
}

.dialog.is-extra-wide {
  width: min(100%, 1040px);
}

.dialog h2 {
  margin: 0 0 10px;
  color: var(--blue);
}

.dialog.is-invite h2 {
  padding-right: 92px;
}

.dialog-form {
  display: grid;
  gap: 12px;
}

.dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.diagnostic-dialog {
  display: grid;
  gap: 12px;
}

.diagnostic-dialog h4 {
  margin: 4px 0 -4px;
  color: var(--ink);
  font-size: 0.88rem;
}

.diagnostic-list {
  max-height: min(56vh, 520px);
  overflow: auto;
  margin: 0;
  padding-left: 22px;
}

.diagnostic-list li {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.invite-options {
  display: grid;
  gap: 0;
}

.invite-language-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  box-shadow: 0 8px 20px rgba(36, 40, 59, 0.08);
}

.invite-language-toggle button {
  min-width: 34px;
  min-height: 26px;
  border: 0;
  background: transparent;
  color: rgba(36, 40, 59, 0.62);
  font-size: 0.68rem;
  font-weight: 850;
  cursor: pointer;
}

.invite-language-toggle button.is-active {
  background: var(--blue);
  color: white;
}

.invite-expiry {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 850;
}

.invite-option {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.invite-option h3 {
  margin: 0;
  color: var(--blue);
  font-size: 0.98rem;
}

.invite-option p {
  margin: 0;
  color: var(--muted);
}

.invite-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 8px;
  align-items: stretch;
}

.invite-copy-button {
  width: 118px;
}

.invite-code,
.invite-url-field {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(47, 127, 122, 0.08);
  color: var(--blue);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.96rem;
  font-weight: 850;
  word-break: break-word;
}

.invite-code {
  display: flex;
  align-items: center;
  min-height: 40px;
  letter-spacing: 0.03em;
}

.invite-url-field {
  min-height: 66px;
  resize: none;
  line-height: 1.35;
  color: var(--ink);
}

.notice {
  color: var(--muted);
}

.invite-qr {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.invite-qr img {
  width: min(260px, 100%);
  height: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

@media (max-width: 850px) {
  .admin-header,
  .section-heading,
  .stacked-actions,
  .setting-inline,
  .filter-bar,
  .dialog-grid,
  .invite-copy-row {
    grid-template-columns: 1fr;
  }

  .admin-header {
    display: grid;
  }

  .header-actions,
  .section-heading,
  .stacked-actions,
  .setting-inline {
    justify-content: flex-start;
    justify-items: start;
  }

  .filter-bar {
    display: grid;
  }

  .invite-copy-button {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }

  body.printing-date-report {
    display: block;
    background: white;
    color: #24283b;
  }

  body.printing-date-report > :not(.date-report-print-view) {
    display: none !important;
  }

  body.printing-date-report > .date-report-print-view {
    display: block !important;
  }

  .date-report-print-view h1 {
    margin: 0 0 7mm;
    color: #1e3f94;
    font-size: 20pt;
  }

  .date-report-print-intro,
  .date-report-print-meta {
    margin: 0 0 4mm;
    font-size: 9.5pt;
  }

  .date-report-print-meta {
    font-weight: 700;
  }

  .date-report-print-view .table-wrap,
  .date-report-print-view .date-diagnostics-table {
    max-height: none;
    margin: 0;
    overflow: visible;
  }

  .date-report-print-view table {
    min-width: 0;
    table-layout: fixed;
  }

  .date-report-print-view thead {
    display: table-header-group;
  }

  .date-report-print-view tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .date-report-print-view th,
  .date-report-print-view td {
    padding: 2.2mm 1.8mm;
    border-color: #bcc3d1;
    color: #24283b;
    font-size: 8.5pt;
    overflow-wrap: anywhere;
  }

  .date-report-print-view th {
    font-size: 7.5pt;
  }

  .date-report-print-view th:nth-child(1),
  .date-report-print-view td:nth-child(1) {
    width: 25%;
  }

  .date-report-print-view th:nth-child(2),
  .date-report-print-view td:nth-child(2) {
    width: 12%;
  }

  .date-report-print-view th:nth-child(3),
  .date-report-print-view td:nth-child(3) {
    width: 14%;
  }

  .date-report-print-view th:nth-child(4),
  .date-report-print-view td:nth-child(4) {
    width: 31%;
  }

  .date-report-print-view th:nth-child(5),
  .date-report-print-view td:nth-child(5) {
    width: 18%;
  }

  .date-report-print-view a {
    color: #24283b;
    text-decoration: none;
  }
}
