/* Internal pages only (stats, portal-admin, portal, reset-password). Loads after styles.css. */
/* ==========================================================================
   Round 2 — internal pages (stats, portal-admin, portal, reset-password)
   ========================================================================== */
/* The HTML `hidden` attribute must always win over component display rules */
[hidden] { display: none !important; }

/* Text-style buttons (forgot password, back, remove) */
button.btn-link {
  background: none; border: 0; padding: .35rem 0; font: inherit; font-weight: 800;
  color: var(--blue); cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px;
  transition: color .2s, text-decoration-color .2s;
}
button.btn-link:hover { color: var(--blue-deep); text-decoration-color: currentColor; }
.ed-remove { color: #b91c1c !important; }

/* Compact hero for internal tools */
.page-hero--compact { padding: 7.5rem 0 2.25rem; }
.page-hero--compact h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); }
.page-hero--compact .lead { font-size: 1.05rem; }
.page-hero .admin-links a { color: #8fcaff; }
.page-hero .admin-links a:hover { color: #fff; }

/* Page body */
.inner-page-body .portal-layout > * + * { margin-top: 1.25rem; }
.portal-layout .muted { font-size: .95rem; }
.portal-layout h2 { font-size: clamp(1.4rem, 2.4vw, 1.75rem); }
.portal-layout h3 { font-size: 1.2rem; }
.panel-title { font-size: 1.4rem; margin: 0; }
.panel-sub { margin: .35rem 0 0; }
.contact-form-panel > h3 + .muted { margin: .4rem 0 0; }
.contact-form-panel hr.portal-hr { margin: 1.75rem 0; }
#product-detail, #ticket-admin-detail, #editor { margin-top: 1.25rem; }
#product-detail > .btn-link { margin-bottom: 1rem; }
#renewal-text, #renewal-list { margin-top: .4rem; }
#tab-subs .product-list, #tab-downloads .product-list { margin-top: 1.25rem; }
#tab-tickets > h2, #tab-downloads > h2, #tab-activations > h2, #tab-tools > h2 { margin-bottom: .4rem; }
#tab-tickets > .muted, #tab-downloads > .muted, #tab-activations > .muted { margin: 0 0 1.25rem; }
#ed-products { margin-bottom: .75rem; }
.ed-product-row { background: var(--bg-muted); border-radius: 1rem; }
.ed-product-row .form-row + .form-row, .ed-product-row .form-row + .field,
.ed-product-row .field + input + .btn-link { margin-top: .75rem; }
.ed-product-row .field { margin-bottom: .75rem; }
.ed-product-row .form-row .field { margin-bottom: 0; }

/* Sign-in / auth cards */
.auth-card { max-width: 28rem; margin-inline: auto; padding: 2rem; }
.auth-card h2 { font-size: 1.6rem; }
.auth-card .lead, .auth-card > .muted { margin: .5rem 0 0; font-size: 1rem; color: var(--ink-soft); }
.auth-card .contact-form { margin-top: 1.5rem; }
.auth-card .contact-form .btn-primary { width: 100%; padding: .95rem 1.2rem; }
.auth-card .btn-ghost { width: 100%; }
.auth-card #forgot-form .btn-link { justify-self: center; }
.auth-alt { margin: 1.1rem 0 0; text-align: center; }
.auth-card #forgot-form { margin-top: 1.25rem; }
.auth-card .form-status { margin: 0; padding: .7rem .9rem; border-radius: .75rem; font-size: .95rem; }
.auth-card .form-status.err { background: #fef2f2; border: 1px solid #fecaca; }
.auth-card .form-status.ok { background: #ecfdf5; border: 1px solid #a7f3d0; }
#after { text-align: center; }
#after .btn-link { display: inline-block; font-size: 1.05rem; }

/* "Checking session" state (shown until the page script reveals sign-in or the dashboard) */
.session-check {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .35rem .75rem;
  padding: 3.5rem 1rem; color: var(--ink-soft); font-weight: 700;
  background: #fff; border: 1px solid var(--line); border-radius: 1.25rem;
  max-width: 28rem; margin-inline: auto;
}
.session-check::before {
  content: ""; width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2.5px solid #b7c9e6; border-top-color: var(--blue);
  animation: sc-spin .8s linear infinite;
}
.session-check .sc-slow { flex-basis: 100%; text-align: center; font-weight: 600; font-size: .9rem; opacity: 0; animation: sc-show .01s 8s forwards; }
body:has(#auth-panel:not([hidden])) .session-check,
body:has(#login-panel:not([hidden])) .session-check,
body:has(#admin-body:not([hidden])) .session-check,
body:has(#dash-panel:not([hidden])) .session-check,
body:has(#stats-results:not([hidden])) .session-check { display: none; }
@keyframes sc-spin { to { transform: rotate(360deg); } }
@keyframes sc-show { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .session-check::before { animation-duration: 3s; } }

/* Signed-in bar, notices */
.session-bar {
  align-items: center; margin-bottom: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 1rem;
  padding: .75rem 1.1rem; box-shadow: 0 8px 24px #0b193008;
}
.session-bar .muted { margin: 0; }
.session-bar .btn { padding: .6rem 1rem; }
#admin-body > .session-bar { margin-bottom: 1.25rem; }
#stats-toolbar { margin-bottom: 1.25rem; }
.notice-warn { background: #fffbeb; border-color: #f59e0b; margin-bottom: 1.25rem; padding: 1rem 1.25rem; }
.notice-warn strong { color: #92400e; }

/* Form polish */
.field span { font-size: .8rem; }
.field span span { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: .85rem; }
.field input[type="checkbox"] {
  width: 1.15rem; height: 1.15rem; padding: 0; flex: none; accent-color: var(--blue);
}
.field input[type="file"] { padding: .65rem .8rem; }
.field select { appearance: auto; }
/* (.form-row grid is defined above) */
.contact-form .btn { justify-self: start; }
.contact-form .btn-primary:disabled { opacity: .6; cursor: progress; }
.portal-layout pre {
  background: var(--bg-muted); border: 1px solid var(--line); border-radius: .85rem;
  padding: .9rem 1rem; overflow: auto; font-size: .9rem; margin: 1rem 0 0; white-space: pre-wrap;
}
.portal-layout pre:empty { display: none; }
.portal-layout p code, .portal-layout .muted code {
  background: var(--bg-muted); border: 1px solid var(--line); border-radius: .4rem;
  padding: .1rem .35rem; font-size: .88em; color: var(--ink); word-break: break-word;
}

/* Tabs */
.portal-tabs { gap: .5rem; margin-bottom: 1.25rem; }
.portal-tab { font-size: .95rem; transition: background .2s, border-color .2s, color .2s; }
.portal-tab:not(.active):hover { border-color: #b7c9e6; color: var(--blue); }
@media (max-width: 720px) {
  .portal-tabs {
    flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity;
    margin-inline: calc(-1 * 1.25rem); padding: .25rem 1.25rem .6rem; scrollbar-width: thin;
    -webkit-overflow-scrolling: touch; scroll-padding-inline: 1.25rem;
  }
  .portal-tab { flex: none; white-space: nowrap; scroll-snap-align: start; }
}

/* List cards */
.product-list { gap: .75rem; }
.product-card { position: relative; font: inherit; color: inherit; }
button.product-card, a.product-card { padding-right: 2.75rem; }
button.product-card::after, a.product-card::after {
  content: "→"; position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%);
  color: var(--blue); font-weight: 800; transition: transform .2s;
}
a.product-card[href*="file=1"]::after { content: "↓"; }
button.product-card:hover::after, a.product-card:hover::after { transform: translate(3px, -50%); }
a.product-card[href*="file=1"]:hover::after { transform: translate(0, -35%); }
div.product-card { cursor: default; }
div.product-card:hover { transform: none; border-color: var(--line); }
.product-card-title { font-size: 1.02rem; }
.product-card-meta { font-size: .92rem; }
.product-list > p.muted {
  margin: 0; padding: 1.5rem 1rem; text-align: center; color: var(--ink-soft);
  border: 1px dashed #c9d5e6; border-radius: 1rem; background: #fff;
}
.status-active { background: #ecfdf5; color: #047857; }
.status-open, .status-in_progress { background: var(--blue-soft); color: var(--blue); }
.status-waiting { background: #fff7ed; color: #c2410c; }
.status-resolved, .status-closed { background: #f1f5f9; color: #475569; }
.status-pill { font-size: .75rem; }
.detail-dl dt { font-size: .9rem; }
.detail-dl dd { overflow-wrap: anywhere; }
#thread-msgs p, #tkt-a-msgs p {
  margin: .6rem 0 0; padding: .8rem 1rem; background: var(--bg-muted);
  border: 1px solid var(--line); border-radius: .85rem; color: var(--ink); font-size: .95rem;
}
#ticket-thread, #ticket-admin-detail h3 + * { margin-top: 1rem; }
#ticket-thread h4 { margin: 0; font-size: 1.05rem; }
.portal-toolbar h2 { margin: 0; }
.portal-toolbar { margin-bottom: 1.25rem; }
#tab-orgs > .portal-toolbar { align-items: center; }

/* Stats */
.stats-grid { margin-top: 0; gap: 1rem; }
.stats-grid .stats-card { padding: 1.25rem 1.4rem; }
.stats-grid .stats-card:first-child { border-top: 3px solid var(--blue); }
.stats-grid .stats-card:nth-child(2) { border-top: 3px solid var(--sky); }
.stats-grid .stats-card:nth-child(3) { border-top: 3px solid var(--mint); }
.stat-num { font-size: clamp(1.9rem, 4vw, 2.4rem); line-height: 1.1; margin-top: .35rem; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .9rem; }
#stats-results > .stats-card { margin-top: 1.25rem; padding: 1.4rem 1.5rem; }
.stats-card-title { font-size: 1.2rem; margin: 0; }
#updated { margin: 1rem 0 0; font-size: .9rem; }
#updated:empty { display: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.contact-form-panel.table-scroll { padding: 1rem 1.25rem; }
.stats-table { margin-top: .6rem; font-size: 1rem; }
.stats-table th, .stats-table td { padding: .7rem .6rem; vertical-align: top; }
.stats-table th { font-size: .8rem; white-space: nowrap; border-bottom-color: #d7dfec; }
.stats-table tbody tr:last-child td { border-bottom: 0; }
.stats-table tbody tr:hover td { background: var(--bg-muted); }
.stats-table td:first-child { font-weight: 600; overflow-wrap: anywhere; }
.stats-table--num th:not(:first-child), .stats-table--num td:not(:first-child) {
  text-align: right; font-variant-numeric: tabular-nums;
}
.stats-table td[colspan] { text-align: center !important; padding: 1.75rem .6rem; color: var(--ink-soft); font-weight: 600; }
.stats-table--wide { min-width: 46rem; }

/* Footer for internal pages */
.footer-copy.footer-internal { margin: 0 auto; padding: 0; border: 0; }
.footer-copy.footer-internal a { font-weight: 700; margin: 0 .35rem; }
.footer-copy.footer-internal span a:first-child { margin-left: 0; }

@media (max-width: 639px) {
  .inner-page-body { padding: 1.75rem 0 3.5rem; }
  .contact-form-panel, .auth-card { padding: 1.25rem; }
  .page-hero--compact { padding: 6.5rem 0 1.75rem; }
  .detail-dl { grid-template-columns: 1fr; gap: .1rem; }
  .detail-dl dd { margin-bottom: .6rem; }
  .session-bar { padding: .7rem .9rem; }
  .portal-toolbar > .btn { width: auto; }
  .footer-copy.footer-internal { flex-direction: column; align-items: flex-start; }
  .stats-table th, .stats-table td { padding: .6rem .4rem; }
  .key-copy-row .btn { width: 100%; }
}
label.field:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: .6rem; }
#editor .muted { margin: .4rem 0 1rem; }
#editor #pw-hint, #editor .field span .muted { margin: 0; }
#tab-tools > h2 { margin-bottom: 1rem; }
.contact-form-panel > .muted + .btn, .contact-form-panel > .muted + button { margin-top: 1rem; }
.contact-form-panel .product-card { background: var(--bg-muted); box-shadow: none; }
.contact-form-panel .product-card:hover { background: #fff; }
.auth-card:has(#forgot-form:not([hidden])) .auth-alt { display: none; }
