:root {
  --brand: #feae13;
  --brand-hover: #e49c0c;
  --brand-soft: #fff6e0;
  --brand-ink: #1a1a1a;
  --ink: #1a1a1a;
  --muted: #546670;
  --line: #ececec;
  --paper: #f4f5f6;
  --card: #ffffff;
  --aside: #ffffff;
  --aside-text: #3f4254;
  --aside-hover: #f7f7f7;
  --pass: #50cd89;
  --pass-ink: #0a7a45;
  --fail: #f1416c;
  --hold: #feae13;
  --hold-ink: #8a6d00;
  --info: #009ef7;
  --shadow: 0 0 20px 0 rgba(76, 87, 125, 0.06);
  --radius: 0.475rem;
}

[x-cloak] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-family: Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 13.5px;
}

.font-mono-num,
.ht-mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ht-app {
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
}

.ht-main,
#ht-page,
#ht-main-slot {
  min-width: 0;
  max-width: 100%;
}

.ht-sidebar {
  width: min(265px, 88vw);
  background: var(--aside);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  box-shadow: none;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.ht-sidebar.is-open {
  transform: translateX(0);
}

.ht-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.ht-brand-logo {
  height: 44px;
  width: auto;
  max-width: 210px;
  display: block;
  object-fit: contain;
}

.ht-brand-meta {
  min-width: 0;
}

.ht-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.ht-brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.ht-nav-title {
  padding: 16px 22px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #a1a5b7;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ht-main {
  padding-left: 0;
}

.ht-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 14px;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--aside-text);
}

.ht-nav-link:hover {
  background: var(--aside-hover);
  color: var(--brand);
}

.ht-nav-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  box-shadow: inset 3px 0 0 var(--brand);
}

.ht-aside-foot {
  margin: 12px 16px 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9f9f9;
}

.ht-scrim {
  display: none;
}

.ht-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 62px;
  padding: 8px 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px 0 rgba(82, 63, 105, 0.05);
}

.ht-header-title {
  min-width: 0;
}

.ht-header-title .ht-crumb {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ht-header-title h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
}

.ht-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 0;
  background: #f5f8fa;
  color: #7e8299;
}

.ht-icon-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.ht-ready {
  display: none;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  background: #e8fff3;
  color: var(--pass-ink);
  font-size: 12px;
  font-weight: 600;
}

@media (min-width: 640px) {
  .ht-ready {
    display: inline-flex;
  }

  .ht-header {
    min-height: 70px;
    padding: 0 24px;
  }

  .ht-header-title h1 {
    font-size: 1.25rem;
  }
}

@media (min-width: 768px) {
  .ht-sidebar {
    width: 265px;
    transform: translateX(0);
  }

  .ht-main {
    padding-left: 265px;
  }

  .ht-menu-btn {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .ht-scrim.is-open {
    display: block;
  }
}

.ht-card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.ht-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 6px;
  padding: 0.58rem 1rem;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  min-height: 40px;
  transition: 0.15s ease;
}

.ht-btn-primary {
  background: var(--brand);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.ht-btn-primary:hover {
  background: var(--brand-hover);
}

.ht-btn-ghost {
  background: #f5f8fa;
  color: #3f4254;
  border: 0;
}

.ht-btn-ghost:hover {
  background: #eef0f4;
}

.ht-btn-danger {
  background: var(--fail);
  color: #fff;
}

.ht-btn-danger:hover {
  background: #d9214e;
}

.ht-btn-amber {
  background: #ffc700;
  color: #3f4254;
}

.ht-btn-amber:hover {
  background: #e6b400;
}

.ht-btn:disabled,
.ht-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.ht-input,
.ht-select,
.ht-textarea {
  width: 100%;
  border: 1px solid #e4e6ef;
  background: #fff;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}

.ht-input:focus,
.ht-select:focus,
.ht-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(254, 174, 19, 0.28);
}

.ht-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 12px;
  font-weight: 600;
  color: #3f4254;
}

.ht-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 4px;
  padding: 0.22rem 0.5rem;
  font-size: 11px;
  font-weight: 600;
}

.ht-badge-pass,
.ht-badge-ready {
  background: #e8fff3;
  color: var(--pass-ink);
}

.ht-badge-fail {
  background: #fff5f8;
  color: #d9214e;
}

.ht-badge-hold {
  background: #fff8dd;
  color: var(--hold-ink);
}

.ht-badge-live {
  background: #f1faff;
  color: #0095e8;
}

.ht-badge-draft {
  background: #f5f8fa;
  color: #7e8299;
}

.ht-badge-void {
  background: #f5f8fa;
  color: #a1a5b7;
}

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

.ht-table th {
  text-align: left;
  font-size: 12px;
  color: #a1a5b7;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.ht-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}

.ht-table tr:hover td {
  background: #f9f9f9;
}

.ht-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  margin: 0 !important;
  background: rgba(24, 28, 50, 0.35);
}

.ht-overlay:not(.grid) {
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}

.ht-drawer {
  height: 100%;
  max-height: 100dvh;
  margin: 0;
  background: #fff;
  box-shadow: 0 0 50px 0 rgba(82, 63, 105, 0.15);
}

.ht-modal {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 50px 0 rgba(82, 63, 105, 0.15);
}

.login-page {
  min-height: 100vh;
  background: #f5f8fa;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.ht-live-desk {
  background: #fff;
  color: var(--ink);
  border: 0;
  box-shadow: var(--shadow);
}

.paper-sheet {
  width: min(210mm, 100%);
  background: #fff;
  box-shadow: var(--shadow);
}

.cert-page {
  width: 210mm;
  min-width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-shadow: var(--shadow);
  margin: 0 auto 24px;
  overflow: hidden;
}

.cert-page-inner {
  margin: 8px;
  min-height: calc(297mm - 16px);
  border: 1px solid #1a1a1a;
  display: flex;
  flex-direction: column;
}

.pt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.pt-table th,
.pt-table td {
  border: 1px solid #1a1a1a;
  padding: 5px 7px;
  vertical-align: top;
  text-align: left;
}

.pt-table th {
  background: #f7f7f7;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #546670;
}

.pt-kv {
  width: 100%;
  border-collapse: collapse;
}

.pt-kv th,
.pt-kv td {
  border: 1px solid #1a1a1a;
  padding: 6px 8px;
  font-size: 11.5px;
}

.pt-kv th {
  width: 28%;
  background: #f7f7f7;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #546670;
}

.sig-canvas {
  width: 100%;
  height: 140px;
  border: 1px dashed #d8d8e5;
  border-radius: 6px;
  background: #fafbfe;
  cursor: crosshair;
  touch-action: none;
}

.ht-test-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 1.25rem;
  padding: 0 0 0.75rem;
  border-bottom: 1px solid var(--line);
}

.ht-test-tab {
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 13px;
  font-weight: 600;
  color: #546670;
  text-decoration: none;
}

.ht-test-tab:hover {
  background: #f7f7f7;
  color: var(--ink);
}

.ht-test-tab.is-active {
  background: var(--brand);
  color: #1a1a1a;
}

.ht-test-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ht-test-tabs::-webkit-scrollbar {
  display: none;
}

.ht-test-tab {
  flex: 0 0 auto;
}

.ht-drawer {
  width: 100%;
  max-width: 28rem;
}

.ht-mono-hero {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.85rem, 9vw, 3.75rem);
  line-height: 1.05;
}

#ht-toasts {
  left: 12px;
  right: 12px;
  width: auto;
  max-width: 20rem;
  margin-left: auto;
}

.cert-fit {
  width: 100%;
  overflow: hidden;
}

.cert-page {
  transform: scale(var(--cert-scale, 1));
  transform-origin: top left;
}

@media (max-width: 639px) {
  .ht-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ht-table-stack thead {
    display: none;
  }

  .ht-table-stack,
  .ht-table-stack tbody {
    display: block;
    width: 100%;
  }

  .ht-table-stack tr {
    display: block;
    margin: 0 12px 12px;
    padding: 6px 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .ht-table-stack td {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    border-bottom: 0;
    padding: 0.5rem 1rem;
  }

  .ht-table-stack td::before {
    content: attr(data-label);
    flex: none;
    max-width: none;
    font-size: 11px;
    font-weight: 600;
    color: #a1a5b7;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .ht-table-stack td:last-child {
    justify-content: flex-end;
    flex-direction: row;
    padding-top: 0.7rem;
  }

  .ht-table-stack td:last-child::before {
    content: none;
  }

  .ht-table-stack tr:hover td {
    background: transparent;
  }

  .ht-modal .mt-5.flex,
  .ht-modal .mt-6.flex {
    flex-wrap: wrap;
  }

  .ht-modal .mt-5.flex .ht-btn,
  .ht-modal .mt-6.flex .ht-btn,
  .ht-modal .mt-5.flex a.ht-btn,
  .ht-modal .mt-6.flex a.ht-btn {
    flex: 1 1 8rem;
  }

  .ht-live-actions {
    position: sticky;
    bottom: 0;
    z-index: 12;
    margin-left: -4px;
    margin-right: -4px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, var(--paper) 18%);
  }
}

@media (max-width: 479px) {
  .login-card {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
    overflow: visible;
  }

  .paper-sheet {
    box-shadow: none;
    width: 100%;
  }

  .cert-fit {
    overflow: visible !important;
    height: auto !important;
  }

  .cert-page {
    transform: none !important;
    box-shadow: none;
    margin: 0;
    width: 100%;
    min-width: 0;
  }

  .ht-main {
    padding-left: 0 !important;
  }
}
