/* ===========================================================================
   HALSYS PRODUCT HUB - BRAND STYLESHEET
   ---------------------------------------------------------------------------
   Palette taken from the Halsys Brand Guidelines (V1, November 2021).
   The previous portal used #C8102E, which was never a guideline colour.

     Red       #d13139    Charcoal  #4a4a4a
     Grey      #bcbcbc    Paper     #f9f9f9
     Blush     #fde5da    Lime      #95c11e    Mist  #e2e8ea

   Two working reds, not one. Pure #d13139 on white measures 4.99:1 for
   contrast, which only just clears the accessibility floor and is tiring at
   small sizes. The brand red does the large areas; the deeper #b82a31 does
   links and small text, where it measures 6.15:1. They are hard to tell apart.
   =========================================================================== */

:root {
  --red:         #d13139;
  --red-deep:    #b82a31;
  --red-darker:  #9c2228;
  --charcoal:    #4a4a4a;
  --grey:        #bcbcbc;
  --paper:       #f9f9f9;
  --blush:       #fde5da;
  --lime:        #95c11e;
  --mist:        #e2e8ea;

  --ink:         #4a4a4a;
  --surface:     #ffffff;
  --border:      #e3e0df;
  --muted:       #7a7a7a;
  --muted-dark:  #5c5c5c;
  --ok:          #2e7d32;
  --radius:      8px;
  --shadow:      0 8px 24px rgba(74, 74, 74, .10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.6;
  min-height: 100vh;
  font-size: 15px;
}

a { color: var(--red-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }

.hidden { display: none !important; }
.muted  { color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  background: var(--red); color: #fff; border: none;
  font-weight: 700; font-size: .95rem;
  padding: .8rem 1.5rem; border-radius: var(--radius); cursor: pointer;
  transition: background .15s; text-decoration: none;
}
.btn-primary:hover { background: var(--red-darker); color: #fff; text-decoration: none; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-primary.block { display: flex; width: 100%; }
.btn-primary.sm { padding: .5rem 1.1rem; font-size: .88rem; }

.btn-outline {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem; background: none;
  border: 1.5px solid var(--border); color: var(--muted-dark);
  border-radius: 6px; font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-outline:hover { border-color: var(--red); color: var(--red-deep); text-decoration: none; }

.btn-download {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.25rem; background: var(--red); color: #fff;
  border: none; border-radius: 6px; font-weight: 700; font-size: .88rem;
  cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-download:hover:not(:disabled) { background: var(--red-darker); color: #fff; text-decoration: none; }
.btn-download:disabled { opacity: .6; cursor: default; }

/* ── Banners ─────────────────────────────────────────────────────────────── */
.error-banner, .success-banner, .info-banner {
  padding: .8rem 1rem; border-radius: 6px; font-size: .88rem; margin-bottom: 1rem;
  border-left: 4px solid;
}
.error-banner   { background: #fdf4f4; border-color: var(--red);  color: #8a1f24; }
.success-banner { background: #f2f9f3; border-color: var(--ok);   color: #1d5720; }
.info-banner    { background: var(--paper); border-color: var(--grey); color: var(--muted-dark); }

/* ── Header ──────────────────────────────────────────────────────────────── */
.halsys-header {
  background: var(--red);
  color: #fff;
  padding: 1.5rem 1.5rem 2.4rem;
}
.head-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.wordmark {
  font-weight: 900; font-size: clamp(1.5rem, 4vw, 1.9rem);
  letter-spacing: .05em; line-height: 1;
}
.tagline {
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  opacity: .9; margin-top: .3rem;
}
.head-right { display: flex; align-items: center; gap: .75rem; margin-left: auto; flex-wrap: wrap; }
.user-badge { font-size: .82rem; color: rgba(255,255,255,.85); }
.btn-logout {
  padding: .35rem .9rem; background: rgba(255,255,255,.18); color: #fff;
  border-radius: 6px; font-size: .82rem; font-weight: 600;
}
.btn-logout:hover { background: rgba(255,255,255,.3); color: #fff; text-decoration: none; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card-wrap { padding: 0 1.5rem 3rem; }
.card {
  max-width: 880px; margin: -1.4rem auto 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: clamp(1.4rem, 4vw, 2.5rem);
}
.card-wide { max-width: 1100px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .35rem; }
.field small { display: block; color: var(--muted); font-size: .78rem; margin-top: .25rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .6rem .85rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  outline: none; background: var(--surface); color: var(--ink);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-body { background: var(--paper); display: flex; flex-direction: column; min-height: 100vh; }
.login-card-title { font-weight: 800; font-size: clamp(1.3rem, 3vw, 1.6rem); margin-bottom: .3rem; color: var(--charcoal); }
.login-card-sub { font-size: .92rem; color: var(--muted-dark); margin-bottom: 1.4rem; }
.login-footer { text-align: center; padding: 1.2rem; font-size: .82rem; color: var(--muted); margin-top: auto; }
.login-footer a { color: var(--muted); }

.sent-state { text-align: center; padding: 1rem 0; }
.sent-state h3 { font-weight: 700; font-size: 1.15rem; margin-bottom: .5rem; color: var(--charcoal); }
.sent-state p { color: var(--muted-dark); font-size: .92rem; }
.state-icon { font-size: 2.4rem; margin-bottom: .8rem; display: block; }

.secondary-link, .back-link, .danger-link {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; background: none; border: none; cursor: pointer;
  font-family: inherit; transition: color .15s;
}
.secondary-link {
  margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--muted-dark);
}
.secondary-link:hover { color: var(--red-deep); }
.back-link { margin-top: 1rem; font-size: .85rem; color: var(--muted); }
.back-link:hover { color: var(--red-deep); }
.danger-link { margin-top: .6rem; font-size: .78rem; color: var(--grey); }
.danger-link:hover { color: var(--red-deep); }

/* ── Portal ──────────────────────────────────────────────────────────────── */
.portal-body { display: flex; flex-direction: column; min-height: 100vh; background: var(--paper); }

.section-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 1.6rem; overflow-x: auto;
}
.stab {
  padding: .7rem 1.1rem; background: none; border: none; cursor: pointer;
  font-weight: 600; font-size: .9rem; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.stab.active { color: var(--red-deep); border-bottom-color: var(--red); }
.stab:hover { color: var(--red-deep); }

.section-switcher { display: flex; gap: .5rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.sec-chip {
  padding: .4rem 1rem; border: 1.5px solid var(--border); border-radius: 100px;
  background: none; cursor: pointer; font-size: .85rem; font-weight: 600;
  color: var(--muted-dark); transition: all .15s;
}
.sec-chip.active { background: var(--red); border-color: var(--red); color: #fff; }

.loading-state, .empty-state { text-align: center; padding: 2.5rem; color: var(--muted); font-size: .92rem; }

.product-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem; margin-bottom: 1rem;
}
.product-header { display: flex; align-items: flex-start; gap: .9rem; margin-bottom: 1.2rem; }
.product-name { font-weight: 800; font-size: 1.1rem; margin-bottom: .15rem; color: var(--charcoal); }
.product-desc { font-size: .86rem; color: var(--muted-dark); }

.latest-download {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: .9rem;
}
.latest-badge {
  background: var(--lime); color: #263000; font-size: .68rem; font-weight: 800;
  padding: .18rem .65rem; border-radius: 100px;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
.latest-info { display: flex; align-items: center; gap: .7rem; flex: 1; flex-wrap: wrap; }

.version-tag {
  background: var(--charcoal); color: #fff; font-size: .76rem; font-weight: 700;
  padding: .18rem .55rem; border-radius: 4px; font-family: ui-monospace, monospace;
}
.version-tag.small { font-size: .7rem; }
.release-date { color: var(--muted); font-size: .84rem; }
.release-label { color: var(--muted-dark); font-size: .84rem; font-style: italic; }
.file-size { color: var(--muted); font-size: .8rem; }

.archive-list { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.archive-row {
  display: flex; align-items: center; gap: .7rem; padding: .75rem 1rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface);
}
.archive-row:last-child { border-bottom: none; }
.archive-row .btn-outline { margin-left: auto; }

/* Release notes */
.rn-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.3rem; margin-bottom: .85rem;
}
.rn-header { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; flex-wrap: wrap; }
.rn-product { font-weight: 700; font-size: .88rem; color: var(--charcoal); }
.rn-content {
  font-size: .9rem; color: var(--muted-dark); line-height: 1.75;
  border-top: 1px solid var(--border); padding-top: .85rem; white-space: pre-wrap;
}

/* Documents */
.doc-category { margin-bottom: 1.6rem; }
.cat-title {
  font-size: .74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); margin-bottom: .7rem;
}
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .7rem; }
.doc-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .4rem;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 1.1rem; cursor: pointer; text-align: left;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit; width: 100%;
}
.doc-card:hover { border-color: var(--red); box-shadow: var(--shadow); }
.doc-title { font-weight: 700; font-size: .88rem; color: var(--charcoal); }
.doc-meta { font-size: .76rem; color: var(--muted); }

/* Videos */
.videos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.video-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s;
}
.video-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.video-thumb { position: relative; aspect-ratio: 16/9; background: var(--charcoal); overflow: hidden; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.play-btn {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 44px; height: 44px; background: rgba(209,49,57,.9); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 15px; padding-left: 3px;
}
.video-info { padding: .85rem 1rem; }
.video-title { display: block; font-weight: 700; font-size: .88rem; color: var(--charcoal); }
.video-desc { display: block; font-size: .82rem; color: var(--muted); margin-top: .2rem; }

/* Docs launcher */
.docs-launch {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--red); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin-bottom: 1rem;
}
.docs-launch .grow { flex: 1; min-width: 200px; }
.docs-launch h3 { font-size: 1rem; font-weight: 800; color: var(--charcoal); margin-bottom: .2rem; }
.docs-launch p { font-size: .86rem; color: var(--muted-dark); }

.portal-footer {
  text-align: center; font-size: .82rem; color: var(--muted);
  padding: 1.2rem 1rem 2rem; border-top: 1px solid var(--border); margin-top: auto;
}
.portal-footer a { color: var(--muted); }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-body { background: var(--paper); min-height: 100vh; }
.admin-header {
  background: var(--red); color: #fff; padding: 0 1.25rem; height: 54px;
  display: flex; align-items: center; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.admin-header-inner { display: flex; align-items: center; width: 100%; gap: .6rem; }
.admin-title { font-weight: 800; font-size: .95rem; letter-spacing: .02em; flex: 1; }

.btn-sm {
  padding: .32rem .8rem; border-radius: 5px; font-size: .8rem; font-weight: 600;
  background: rgba(255,255,255,.18); color: #fff; border: none; cursor: pointer;
  transition: background .15s; text-decoration: none; display: inline-block;
}
.btn-sm:hover { background: rgba(255,255,255,.3); color: #fff; text-decoration: none; }
.btn-sm.danger { background: rgba(0,0,0,.22); }

.admin-main { display: flex; min-height: calc(100vh - 54px); }
.admin-nav {
  width: 195px; background: var(--surface); border-right: 1px solid var(--border);
  padding: .9rem .45rem; display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 54px; height: calc(100vh - 54px); overflow-y: auto; flex-shrink: 0;
}
.anav-btn {
  display: block; width: 100%; text-align: left; padding: .6rem .8rem;
  border: none; background: none; border-radius: 6px; cursor: pointer;
  font-size: .87rem; font-weight: 600; color: var(--muted); transition: all .15s;
}
.anav-btn:hover { background: var(--paper); color: var(--ink); }
.anav-btn.active { background: var(--blush); color: var(--red-darker); }

.admin-content { flex: 1; padding: 1.6rem; overflow-x: auto; }
.panel { display: none; }
.panel.active { display: block; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; gap: 1rem; flex-wrap: wrap; }
.panel-header h2 { font-weight: 800; font-size: 1.25rem; color: var(--charcoal); }

.admin-table {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; font-size: .84rem;
}
.admin-table th {
  background: var(--charcoal); color: #fff; padding: .6rem .9rem;
  text-align: left; font-weight: 700; font-size: .73rem;
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
}
.admin-table td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--paper); }

.badge {
  display: inline-block; padding: .12rem .6rem; border-radius: 100px;
  font-size: .71rem; font-weight: 700; white-space: nowrap;
}
.badge.approved { background: #e8f5e9; color: #2e7d32; }
.badge.pending  { background: var(--blush); color: var(--red-darker); }
.badge.denied   { background: var(--grey); color: #333; }
.badge.removed  { background: var(--mist); color: var(--muted-dark); }
.badge.section  { background: var(--mist); color: var(--muted-dark); margin-right: .25rem; }

.user-pending td { background: #fffdf5; }

.btn-del {
  padding: .25rem .65rem; background: none; border: 1px solid var(--grey);
  color: var(--muted-dark); border-radius: 5px; cursor: pointer; font-size: .77rem;
  transition: all .15s;
}
.btn-del:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-approve, .btn-deny {
  padding: .25rem .7rem; border: none; border-radius: 5px; cursor: pointer;
  font-size: .77rem; font-weight: 700; margin-right: .25rem;
}
.btn-approve { background: #e8f5e9; color: #2e7d32; }
.btn-deny    { background: var(--blush); color: var(--red-darker); }

.sec-checks { display: flex; gap: .9rem; flex-wrap: wrap; padding: .3rem 0; }
.sec-checks label { display: flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; cursor: pointer; }
.sec-checks input { width: auto; }

.settings-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.4rem; max-width: 520px; margin-bottom: 1.2rem;
}
.settings-block h3 { font-size: .95rem; margin-bottom: .9rem; color: var(--charcoal); }
.toggle-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; }
.toggle-desc { font-size: .83rem; color: var(--muted); margin-bottom: 1rem; }
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 23px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--grey); border-radius: 23px; transition: .2s; }
.toggle-slider:before { content: ''; position: absolute; width: 17px; height: 17px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
input:checked + .toggle-slider { background: var(--red); }
input:checked + .toggle-slider:before { transform: translateX(19px); }
.pending-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff; border-radius: 10px; font-size: .68rem;
  font-weight: 800; padding: 0 .35rem; min-width: 18px; height: 18px; margin-left: .35rem;
}

/* Toast */
.toast {
  position: fixed; top: 66px; right: 1.4rem; z-index: 9999;
  padding: .7rem 1.1rem; border-radius: 6px; font-size: .87rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.14); color: #fff;
}
.toast.ok  { background: var(--ok); }
.toast.err { background: var(--red); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(74,74,74,.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1.4rem;
}
.modal {
  background: var(--surface); border-radius: 12px; padding: 1.8rem;
  width: 100%; max-width: 470px; box-shadow: 0 18px 50px rgba(0,0,0,.2);
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-weight: 800; font-size: 1.05rem; margin-bottom: 1.2rem; color: var(--charcoal); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: .5rem;
  margin-top: 1.2rem; padding-top: .9rem; border-top: 1px solid var(--border);
}
.modal-actions .btn-sm { background: var(--paper); color: var(--ink); border: 1px solid var(--border); }
.modal-actions .btn-sm:hover { background: var(--border); color: var(--ink); }

@media (max-width: 720px) {
  .admin-nav { width: 54px; }
  .anav-btn { font-size: 0; padding: .6rem .4rem; text-align: center; }
  .admin-content { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
