/*
  GH Bank retheme of the Baker Tilly shell.
  Orange is the primary action colour; yellow and green are secondary accents
  only (status tags, rules, badges) and never carry a primary action.
*/
:root {
  --gh-orange: #E7431F;
  --gh-orange-dark: #C6360F;
  --gh-orange-soft: rgba(231, 67, 31, .10);
  --gh-orange-border: rgba(231, 67, 31, .40);

  --gh-yellow: #FFD400;
  --gh-yellow-soft: rgba(255, 212, 0, .16);
  --gh-yellow-border: rgba(255, 212, 0, .40);
  --gh-yellow-ink: #5C3E00;

  --gh-green: #8DC63F;
  --gh-green-soft: rgba(141, 198, 63, .15);
  --gh-green-border: rgba(141, 198, 63, .40);
  --gh-green-ink: #5A8A1F;

  --gh-sidebar: #3A4358;
  --gh-sidebar-muted: #8B93A7;
  --gh-sidebar-text: #C7CCD8;
  --gh-sidebar-hover: #454F68;

  --gh-page: #F4F5F7;
  --gh-ink: #222222;
  --gh-ink-muted: #777777;
  --gh-ink-faint: #999999;
  --gh-border: #E9E9E9;

  --gh-sidebar-width: 280px;
  --gh-radius: 8px;
  --gh-shadow-card: 0 1px 4px rgba(0, 0, 0, .05);

  /* Bootstrap overrides so stock components inherit the theme. */
  --bs-primary: var(--gh-orange);
  --bs-primary-rgb: 231, 67, 31;
  --bs-link-color: var(--gh-orange);
  --bs-link-color-rgb: 231, 67, 31;
  --bs-link-hover-color: var(--gh-orange-dark);
  --bs-body-bg: var(--gh-page);
  --bs-body-color: #444444;
  --bs-border-radius: var(--gh-radius);
}

/* ---------- Buttons ---------- */

.btn-gh {
  background: var(--gh-orange);
  border: 1px solid var(--gh-orange);
  color: #fff;
  font-weight: 600;
}
.btn-gh:hover,
.btn-gh:focus { background: var(--gh-orange-dark); border-color: var(--gh-orange-dark); color: #fff; }

.btn-gh-outline {
  background: #fff;
  border: 1px solid var(--gh-orange);
  color: var(--gh-orange);
  font-weight: 600;
}
.btn-gh-outline:hover { background: var(--gh-orange-soft); color: var(--gh-orange-dark); }

/* Every interactive control clears the 44px touch target on small screens. */
@media (max-width: 991.98px) {
  .btn, .form-control, .form-select { min-height: 44px; }
}

/* ---------- Status pills ---------- */

.gh-tag {
  display: inline-flex;
  align-items: center;
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.gh-tag-open     { background: var(--gh-green-soft);  color: var(--gh-green-ink);  border: 1px solid var(--gh-green-border); }
.gh-tag-closed   { background: #f1f1f1;               color: #666;                 border: 1px solid #ddd; }
.gh-tag-pending  { background: var(--gh-yellow-soft); color: var(--gh-yellow-ink); border: 1px solid var(--gh-yellow-border); }
.gh-tag-approved { background: var(--gh-green-soft);  color: var(--gh-green-ink);  border: 1px solid var(--gh-green-border); }
.gh-tag-category { background: #f5f6f8;               color: #555;                 border: 1px solid #e3e5ea; }
.gh-tag-account  { background: var(--gh-orange-soft); color: var(--gh-orange-dark); border: 1px solid var(--gh-orange-border);
                   font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Sidebar ---------- */

.gh-sidebar {
  background: var(--gh-sidebar);
  color: #fff;
  width: var(--gh-sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
}

.gh-sidebar-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 0 1.5rem 1.75rem;
  color: #fff;
  text-decoration: none;
}
.gh-sidebar-brand:hover { color: #fff; }
.gh-sidebar-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: #fff;
  color: var(--gh-sidebar);
  font-weight: 800;
  font-size: .8125rem;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.gh-sidebar-wordmark { font-size: 1.0625rem; font-weight: 600; }

/* Baker Tilly lockup. Width-constrained so it never crowds the 280px rail;
   height follows the artwork's aspect ratio. */
.gh-sidebar-logo {
  width: 168px;
  max-width: 100%;
  height: auto;
  display: block;
}

.gh-nav-section {
  font-size: .6875rem;
  letter-spacing: .08em;
  color: var(--gh-sidebar-muted);
  padding: 1.25rem 1.5rem .375rem;
  text-transform: uppercase;
}
.gh-nav-section:first-of-type { padding-top: .5rem; }

.gh-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  color: var(--gh-sidebar-text);
  font-size: .875rem;
  text-decoration: none;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  min-height: 44px;
}
.gh-nav-link:hover { background: var(--gh-sidebar-hover); color: #fff; }
.gh-nav-link.active { background: var(--gh-orange); color: #fff; font-weight: 600; }
.gh-nav-link .gh-nav-icon { width: 1.125rem; flex: none; text-align: center; opacity: .9; }
.gh-nav-link .gh-nav-count { margin-left: auto; }

.gh-nav-count {
  background: var(--gh-green);
  color: #1F3A0D;
  font-size: .6875rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .0625rem .4375rem;
}
.gh-nav-link.active .gh-nav-count { background: var(--gh-yellow); color: var(--gh-yellow-ink); }

.gh-sidebar-footer { margin-top: auto; display: flex; justify-content: center; padding-top: 1.25rem; }
.gh-version-pill {
  font-size: .6875rem;
  background: var(--gh-yellow-soft);
  color: var(--gh-yellow);
  border: 1px solid var(--gh-yellow-border);
  padding: .1875rem .625rem;
  border-radius: 999px;
}

/* Sub-menu (Admin) */
.gh-nav-sub { background: rgba(0, 0, 0, .12); }
.gh-nav-sub .gh-nav-link { padding-left: 3rem; font-size: .8125rem; }

/* ---------- Shell layout ---------- */

.gh-shell { display: flex; min-height: 100vh; }

.gh-sidebar-fixed {
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 1030;
}

.gh-main {
  flex: 1;
  min-width: 0;                 /* lets wide tables scroll instead of stretching the page */
  margin-left: var(--gh-sidebar-width);
  display: flex;
  flex-direction: column;
}

@media (max-width: 991.98px) {
  .gh-main { margin-left: 0; }
  .offcanvas .gh-sidebar { width: 100%; height: 100%; }
}

.gh-topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 2rem;
}
@media (max-width: 991.98px) {
  .gh-topbar { min-height: 68px; padding: .75rem 1rem; }
}

.gh-bank-logo { max-height: 70px; max-width: 250px; width: auto; }
@media (max-width: 575.98px) { .gh-bank-logo { max-height: 44px; max-width: 160px; } }

/* Placeholder while the real GH Bank lockup is dropped in. */
.gh-bank-logo-slot {
  display: flex; align-items: center; justify-content: center;
  width: 250px; height: 70px;
  border: 1px dashed #cfd3da;
  border-radius: var(--gh-radius);
  color: var(--gh-ink-faint);
  font-size: .75rem;
  background: #fff;
}
@media (max-width: 575.98px) { .gh-bank-logo-slot { width: 150px; height: 44px; } }

.gh-content { padding: 0 2rem 3rem; flex: 1; }
@media (max-width: 991.98px) { .gh-content { padding: 0 1rem 2rem; } }

/* ---------- Page heading ---------- */

.gh-page-eyebrow { font-size: .8125rem; color: var(--gh-ink-muted); margin-bottom: .625rem; }
.gh-page-rule { height: 3px; width: 64px; background: var(--gh-yellow); border-radius: 2px; margin-bottom: .625rem; }
.gh-breadcrumb { font-size: .8125rem; color: var(--gh-ink-faint); margin-bottom: 1.5rem; }
.gh-breadcrumb a { color: var(--gh-ink-faint); text-decoration: none; }
.gh-breadcrumb a:hover { color: var(--gh-orange); }
.gh-breadcrumb .active { color: #333; font-weight: 600; }

/* ---------- Cards ---------- */

.gh-card {
  background: #fff;
  border-radius: var(--gh-radius);
  box-shadow: var(--gh-shadow-card);
  border: 0;
  margin-bottom: 1.5rem;
}
.gh-card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--gh-border);
}
@media (max-width: 575.98px) { .gh-card-header { padding: 1rem; } }

.gh-card-accent { width: 4px; height: 20px; background: var(--gh-orange); border-radius: 2px; flex: none; }
.gh-card-title { font-size: 1.1875rem; font-weight: 600; color: var(--gh-ink); margin: 0; }
.gh-card-body { padding: 1.75rem; }
@media (max-width: 575.98px) { .gh-card-body { padding: 1rem; } }

.gh-prose { font-size: .9375rem; line-height: 1.7; color: #444; }
.gh-prose h5 { font-size: 1rem; font-weight: 600; color: var(--gh-ink); margin-bottom: .875rem; }
.gh-prose p:last-child { margin-bottom: 0; }

/* ---------- Filter bar ---------- */

.gh-filters { display: flex; gap: .875rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.gh-filters .gh-filter-search { flex: 1 1 260px; min-width: 0; }
.gh-filters .gh-filter-select { flex: 0 1 230px; min-width: 0; }
@media (max-width: 767.98px) {
  .gh-filters { gap: .625rem; }
  .gh-filters > * { flex: 1 1 100% !important; }
}

.form-control:focus, .form-select:focus {
  border-color: var(--gh-orange);
  box-shadow: 0 0 0 3px var(--gh-orange-soft);
}

/* ---------- Searchable select (combobox) ---------- */

.gh-combobox { position: relative; }
.gh-combobox-input { padding-right: 2.25rem; }

/* Bootstrap's form-select chevron, copied because Bootstrap only defines
   --bs-form-select-bg-img on .form-select itself. */
.gh-combobox-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 2.25rem;
  border: 0;
  background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") no-repeat center / 16px 12px;
  cursor: pointer;
}

.gh-combobox-list {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: .25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--gh-border);
  border-radius: var(--gh-radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .10);
}

.gh-combobox-option {
  padding: .45rem .75rem;
  cursor: pointer;
  color: var(--gh-ink);
  word-break: break-word;
}
.gh-combobox-option[aria-selected="true"] { font-weight: 600; }
.gh-combobox-option.is-active,
.gh-combobox-option:hover { background: var(--gh-orange-soft); color: var(--gh-orange-dark); }

.gh-combobox-empty { padding: .45rem .75rem; color: var(--gh-ink-faint); font-style: italic; }

@media (max-width: 991.98px) {
  .gh-combobox-option { padding: .7rem .75rem; }
}

/* ---------- Q&A table ---------- */

.gh-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.gh-table thead tr { border-bottom: 2px solid var(--gh-border); }
.gh-table th {
  padding: .5rem .625rem;
  color: var(--gh-ink);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.gh-table td { padding: .875rem .625rem; vertical-align: top; color: #444; }
.gh-table tbody tr { border-bottom: 1px solid #F0F0F0; }
.gh-table tbody tr:hover { background: #FAFAFB; }
.gh-table .gh-col-ref { width: 72px; }
.gh-table .gh-col-date { width: 120px; white-space: nowrap; }
.gh-table .gh-col-docs { width: 160px; }

.gh-ref-link { color: var(--gh-orange); font-weight: 600; text-decoration: none; }
.gh-ref-link:hover { text-decoration: underline; }

/* Reference rendered as a button (admin approval queue), where the plain link
   was not obviously the way to open a question. */
.gh-table .gh-col-ref-button { width: 108px; }

.gh-ref-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.gh-ref-button-icon { opacity: .7; flex: none; }

.gh-doc-line { display: block; color: var(--gh-orange); text-decoration: none; font-size: .8125rem; padding: .125rem 0; }
.gh-doc-line:hover { text-decoration: underline; }

/*
  Below md the six-column table of Thai prose is unreadable, so each row
  collapses into a stacked card labelled from data-label attributes.
*/
@media (max-width: 767.98px) {
  .gh-table thead { display: none; }
  .gh-table, .gh-table tbody, .gh-table tr, .gh-table td { display: block; width: 100%; }
  .gh-table tbody tr {
    background: #fff;
    border: 1px solid var(--gh-border);
    border-radius: var(--gh-radius);
    margin-bottom: .875rem;
    padding: .5rem .25rem;
  }
  .gh-table td { padding: .5rem .75rem; }
  .gh-table td::before {
    content: attr(data-label);
    display: block;
    font-size: .6875rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gh-ink-faint);
    font-weight: 600;
    margin-bottom: .1875rem;
  }
  .gh-table td:empty { display: none; }
}

/* ---------- Pagination ---------- */

.gh-pager { display: flex; gap: .375rem; flex-wrap: wrap; align-items: center; }
.gh-pager .page-link { color: #666; border: 0; background: none; padding: .375rem .75rem; border-radius: 5px; }
.gh-pager .page-item.active .page-link { background: var(--gh-orange); color: #fff; font-weight: 600; }
.gh-pager .page-item.disabled .page-link { color: #ccc; }

.gh-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* ---------- Login ---------- */

.gh-login { min-height: 100vh; display: flex; background: #241A12; }
.gh-login-visual { width: 56%; position: relative; display: none; }
@media (min-width: 992px) { .gh-login-visual { display: block; } }

.gh-login-visual-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gh-login-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(200deg, rgba(36,26,18,.15) 0%, rgba(36,26,18,.75) 55%, #241A12 100%);
}
.gh-login-copy { position: absolute; left: 3.5rem; right: 3.5rem; bottom: 4.375rem; color: #fff; }
.gh-login-rule { width: 60px; height: 4px; background: var(--gh-yellow); border-radius: 2px; margin-bottom: 1.125rem; }
.gh-login-title { font-size: 2.125rem; font-weight: 700; margin-bottom: .875rem; }
.gh-login-lede { font-size: .9375rem; line-height: 1.6; color: #E8DED4; max-width: 520px; }

.gh-login-panel {
  flex: 1;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}
.gh-login-form { width: 100%; max-width: 340px; }
.gh-login-badge {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--gh-orange-soft);
  color: var(--gh-orange);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.375rem;
  margin-bottom: 1rem;
}

/* ---------- PDF viewer ---------- */

.gh-viewer { background: #2B2B2B; min-height: 100vh; display: flex; flex-direction: column; }
.gh-viewer-bar {
  background: var(--gh-sidebar);
  color: #fff;
  padding: .625rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.gh-viewer-title { font-size: .875rem; font-weight: 600; margin-right: auto; min-width: 0;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-viewer-pages { flex: 1; overflow: auto; padding: 1rem; text-align: center; }
.gh-viewer-pages canvas {
  max-width: 100%;
  height: auto;
  margin: 0 auto 1rem;
  display: block;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
  /* Deterrence only — see the security note in STACK-AND-GUIDE.md §8. */
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Nothing from the viewer should reach a printer. */
@media print {
  .gh-viewer, .gh-viewer-pages { display: none !important; }
  body::after {
    content: "Printing is disabled for this document.";
    display: block; padding: 2rem; font-size: 1rem;
  }
}

/* ---------- Utility ---------- */

.gh-empty { padding: 3rem 1rem; text-align: center; color: var(--gh-ink-faint); }
.gh-thai { word-break: break-word; }
.gh-onetime-password {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  background: var(--gh-yellow-soft);
  border: 1px solid var(--gh-yellow-border);
  padding: .25rem .5rem;
  border-radius: 4px;
  user-select: all;
}

.htmx-request .gh-busy { opacity: .5; transition: opacity .15s ease; }

/* ---------- Busy / progress ---------- */

/* Not [disabled]: disabling a submit button before the browser serialises the
   form drops its name/value and formaction from the post. */
.btn.is-busy {
  pointer-events: none;
  opacity: .75;
}

.gh-spinner {
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-right: .5em;
  vertical-align: -.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: gh-spin .7s linear infinite;
}

@keyframes gh-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .gh-spinner { animation-duration: 2s; }
}

.gh-upload-progress .progress {
  height: .6rem;
  background: #ECEDEF;
}

.gh-upload-progress .progress-bar {
  background: var(--gh-orange);
  transition: width .2s ease;
}
