/* Root theme */

:root {
    color-scheme: dark;
    --bg: #020617;
    --bg-elevated: #050505;
    --card: #0b0b0b;
    --accent: #ff9800;
    --accent-soft: rgba(255, 152, 0, 0.18);
    --text: #f5f5f5;
    --muted: #9e9e9e;
    --danger: #ef5350;
    --border: #262626;
    --radius: 12px;
    --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.7);
}

/* Reset */

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

html,
body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #111827 0, #000000 60%);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* App shell */

.flha-body {
    display: flex;
    justify-content: center;
    align-items: stretch;
}

.flha-app {
    position: relative;
    width: 100%;
    max-width: 768px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header with centered logo */

.flha-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 768px;
    height: 130px;
    padding: 10px 16px;
    background: #050505;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.flha-header-left {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.flha-logo {
    height: 102px;
    width: auto;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* Main scroll area */

#flha-main {
    flex: 1;
    padding: 16px 16px 24px;
    margin-top: 130px;   /* header height */
    margin-bottom: 110px; /* room for bottom nav */
    overflow-y: auto;
    background: radial-gradient(circle at top, #111827 0, #020617 60%);
}

/* Sections */

.flha-section {
    display: none;
}

.flha-section.flha-section-active {
    display: block;
}

.flha-section-header {
    margin-bottom: 10px;
}

.flha-section-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.flha-section-header p {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Cards */

.flha-card {
    background: linear-gradient(145deg, #0a0a0a, #050505);
    border-radius: var(--radius);
    padding: 14px 14px 16px;
    margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow-soft);
}

.flha-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Generic label/value pairs */

.flha-field-pair {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.flha-label {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 2px;
}

.flha-value {
    font-size: 0.9rem;
}

/* Fields */

.flha-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    margin-top: 4px;
}

.flha-field .flha-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.flha-input,
.flha-textarea,
.flha-select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #050505;
    color: var(--text);
    padding: 9px 11px;
    font-size: 0.9rem;
    outline: none;
}

.flha-input:focus,
.flha-textarea:focus,
.flha-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 152, 0, 0.7);
}

.flha-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Toggle buttons (environment) */

.flha-toggle-group {
    display: inline-flex;
    padding: 3px;
    background: #020617;
    border-radius: 999px;
    border: 1px solid #111827;
    margin-top: 4px;
}

.flha-toggle-btn {
    border: 0;
    padding: 6px 14px;
    font-size: 0.8rem;
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.flha-toggle-btn-active {
    background: var(--accent);
    color: #020617;
}

/* Weather layout */

.flha-weather {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flha-weather-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.flha-weather-icon {
    width: 40px;
    height: 40px;
}

.flha-weather-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flha-weather-text {
    font-size: 0.9rem;
}

.flha-weather-temp {
    font-size: 1rem;
    font-weight: 600;
}

.flha-weather-feels {
    font-size: 0.8rem;
    color: var(--muted);
}

/* Tags / pills */

.flha-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.flha-tag-pill {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
    background: #050505;
    transition: background 0.15s, border 0.15s, color 0.15s;
}

.flha-tag-pill-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* Status / helper text */

.flha-status {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 2px;
    margin-bottom: 6px;
}

/* Hazards rendered by JS */

.flha-card-inner {
    background: #070707;
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 10px;
    margin-bottom: 8px;
}

.flha-card-inner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.flha-card-inner-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.flha-card-inner-text {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.flha-card-inner-steps {
    font-size: 0.78rem;
    margin-top: 4px;
}

.flha-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid var(--border);
}

.flha-chip-low {
    border-color: #66bb6a;
    color: #a5d6a7;
}

.flha-chip-medium {
    border-color: #ffa726;
    color: #ffcc80;
}

.flha-chip-high {
    border-color: #ef5350;
    color: #ef9a9a;
}

/* Docs / attachments */

.flha-docs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flha-doc-card {
    border-radius: 12px;
    border: 1px dashed var(--border);
    padding: 8px 10px;
    background: #050505;
}

.flha-doc-title {
    font-size: 0.88rem;
    font-weight: 500;
}

.flha-doc-meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 2px;
}

.flha-hint {
    font-size: 0.78rem;
    color: var(--muted);
}

/* Inline actions inside cards (not fixed) */

.flha-actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.flha-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* QR / join */

.flha-qrcode-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.flha-qrcode {
    padding: 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #050505;
}

/* Signature */

.flha-signature-wrapper {
    border-radius: 10px;
    border: 1px dashed var(--border);
    background: #050505;
    height: 150px;
    margin-top: 6px;
    overflow: hidden;
}

.flha-signature-pad {
    width: 100%;
    height: 100%;
    display: block;
}

/* Attendee list */

.flha-attendee-list {
    font-size: 0.85rem;
}

/* Errors and success */

.flha-error {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--danger);
}

.flha-success {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #81c784;
}

/* Buttons: base */

.flha-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 16px;
    border-radius: 999px;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    background: var(--accent);
    color: #000000;
    box-shadow: 0 6px 18px rgba(255, 152, 0, 0.5);
    transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.15s ease, opacity 0.1s ease;
    white-space: nowrap;
}

.flha-btn:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.flha-btn-primary {
    background: var(--accent);
    color: #000000;
}

.flha-btn-primary:disabled {
    opacity: 0.55;
    cursor: default;
    box-shadow: none;
}

.flha-btn-secondary {
    background: #2b2b2b;
    color: var(--text);
    box-shadow: none;
    border: 1px solid #3a3a3a;
}

.flha-btn-secondary:active {
    background: #353535;
}

.flha-btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    box-shadow: none;
}

/* Fixed bottom nav: Back left, Next right */

.flha-actions {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 768px;
    padding: 8px 5px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 45;
    background: linear-gradient(to top, rgba(5, 5, 5, 0.98), rgba(5, 5, 5, 0.9), rgba(5, 5, 5, 0));
}

/* Ensure only the active section's actions show */
.flha-section:not(.flha-section-active) .flha-actions {
    display: none;
}

/* Layout inside bottom bar */
.flha-actions .flha-btn {
    border-radius: 10px;           /* more squared at the bottom bar */
    flex: 0 0 auto;
    min-width: 120px;
}

/* Back button: bottom left, lighter color */
.flha-actions .flha-btn-secondary {
    margin-right: auto;            /* push others to the right */
}

/* Next button: bottom right */
.flha-actions .flha-btn-primary:last-child {
    margin-left: auto;
}

/* Middle action (like Calculate Risk) fills the middle space */
.flha-actions .flha-btn-outline {
    flex: 1 1 auto;
    justify-content: center;
}

/* Small screens tweaks */

@media (max-width: 480px) {
    #flha-main {
        padding-inline: 12px;
        margin-bottom: 120px;
    }

    .flha-card {
        padding-inline: 12px;
    }

    .flha-actions .flha-btn {
        min-width: 110px;
        font-size: 0.85rem;
        padding-inline: 12px;
    }
}


.flha-btn-loading {
    opacity: 0.9;
}

.flha-btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    animation: flhaSpin 0.8s linear infinite;
}

@keyframes flhaSpin {
    to {
        transform: rotate(360deg);
    }
}







/* Modal base */
.flha-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 9999;
}

.flha-modal.is-open {
    display: block;
}

.flha-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.flha-modal-panel {
    position: relative;
    width: calc(100% - 32px);
    max-width: 520px;
    margin: 60px auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

/* Modal header */
.flha-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.flha-modal-title {
    font-size: 16px;
    font-weight: 700;
}

.flha-modal-close {
    border: 0;
    background: transparent;
    font-size: 22px;
    line-height: 22px;
    cursor: pointer;
    padding: 4px 8px;
}

/* Modal body */
.flha-modal-body {
    padding: 16px;
}

.flha-field {
    display: block;
    margin-bottom: 12px;
}

.flha-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    opacity: 0.8;
}

.flha-input,
.flha-textarea {
    width: 100%;
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

.flha-textarea {
    resize: vertical;
}

/* Modal actions */
.flha-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.08);
}

.flha-help-text {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 6px;
}

/* Card edit button (top right on cards) */
.flha-card-edit-btn {
    border: 1px solid rgba(0,0,0,0.14);
    background: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* Section title row with Add button */
.flha-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-bottom: 8px;
}

.flha-inline-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.flha-inline-row .flha-input {
    flex: 1;
}

.flha-checklist {
    margin-bottom: 14px;
}

.flha-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.14);
    border-radius: 10px;
    margin-bottom: 10px;
}


/* FLHA Modals */
.flha-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 9999;
    padding: 24px;
}

.flha-modal.is-open {
    display: block;
}

.flha-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(2px);
}

.flha-modal-panel {
    position: relative;
    z-index: 2;
    width: min(760px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    margin: 6vh auto;
    border-radius: 18px;
    background: #0f0f12;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 22px 70px rgba(0,0,0,0.65);
}

.flha-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.flha-modal-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.flha-modal-close {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.04);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    line-height: 20px;
    padding: 6px 10px;
}

.flha-modal-body {
    padding: 18px;
}

.flha-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 18px 18px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* Inputs inside modal */
.flha-field {
    display: block;
    margin-bottom: 14px;
}

.flha-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    opacity: 0.8;
    margin-bottom: 8px;
}

.flha-input,
.flha-textarea {
    width: 100%;
    background: #0b0b0d;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

.flha-input:focus,
.flha-textarea:focus {
    border-color: rgba(255, 165, 0, 0.55);
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.12);
}

.flha-textarea {
    resize: vertical;
}

/* Checklist rows for PPE / Permits */
.flha-checklist {
    margin-bottom: 14px;
}

.flha-check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.03);
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.flha-check-row:hover {
    border-color: rgba(255,165,0,0.28);
    background: rgba(255,165,0,0.06);
}

.flha-check-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Add row */
.flha-inline-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.flha-inline-row .flha-input {
    flex: 1;
}

/* Help text */
.flha-help-text {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 6px;
}

/* Mobile tweaks */
@media (max-width: 640px) {
    .flha-modal {
        padding: 14px;
    }

    .flha-modal-panel {
        width: calc(100vw - 28px);
        max-height: calc(100vh - 28px);
        margin: 3vh auto;
        border-radius: 16px;
    }

    .flha-modal-actions {
        flex-wrap: wrap;
    }

    .flha-modal-close {
        padding: 6px 10px;
    }
}


/* Tight, mobile friendly header layout inside prepare cards */
.flha-card-inner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.flha-card-inner-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    margin: 0;
}

/* Right side controls area for pill + edit */
.flha-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Severity pill placement */
.flha-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
}

/* Keep your existing color classes, just make them punchier */
.flha-chip-low {
    border-color: rgba(46, 204, 113, 0.45);
    background: rgba(46, 204, 113, 0.14);
}

.flha-chip-medium {
    border-color: rgba(241, 196, 15, 0.50);
    background: rgba(241, 196, 15, 0.16);
}

.flha-chip-high {
    border-color: rgba(231, 76, 60, 0.55);
    background: rgba(231, 76, 60, 0.18);
}

/* Pro icon button for edit/add */
.flha-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,165,0,0.55);
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
    cursor: pointer;
    padding: 0;
}

.flha-icon-btn:hover {
    background: rgba(255,165,0,0.08);
    border-color: rgba(255,165,0,0.75);
}

.flha-icon-btn:active {
    transform: translateY(1px);
}

/* The icon itself */
.flha-icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #ffb347;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Small helper so section titles can have an add button later */
.flha-section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 18px;
    margin-bottom: 10px;
}

/* Mobile tweaks */
@media (max-width: 520px) {
    .flha-chip {
        height: 20px;
        padding: 0 8px;
        font-size: 10px;
    }

    .flha-icon-btn {
        width: 36px;
        height: 36px;
    }
}

input#docs-file.flha-file-hidden {
  display: none !important;
}


.flha-file-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}


/* Signature modal only */
#sig-modal {
  padding: 0 !important; /* override modal padding so we can truly go full screen */
}

#sig-modal .flha-modal-backdrop {
  background: rgba(0, 0, 0, 0.82);
}

#sig-modal .flha-modal-panel {
  width: 100vw !important;
  height: 100vh;
  height: 100dvh;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  overflow: hidden !important;
  background: #0a0a0a; /* match your dark cards */
  border: 0 !important;
  box-shadow: none !important;

  display: flex;
  flex-direction: column;
}

/* Top bar inside signature modal */
#sig-modal .flha-sig-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));

  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(to bottom, rgba(10,10,10,0.98), rgba(10,10,10,0.92));
}

#sig-modal .flha-sig-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.95;
}

/* Tiny X button */
#sig-modal .flha-sig-x {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.04);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 18px;
}

/* Clear button styled to match your scheme */
#sig-modal .flha-sig-clear {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 152, 0, 0.10);
  color: var(--accent);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

#sig-modal .flha-sig-clear:active,
#sig-modal .flha-sig-x:active {
  transform: scale(0.99);
}

/* Canvas area */
#sig-modal .flha-sig-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

#sig-modal .flha-sig-canvas-wrap {
  flex: 1 1 auto;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: #050505;
  overflow: hidden;
}

#sig-modal canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none; /* helps prevent scroll while signing */
}

/* Optional rotate hint overlay (JS can toggle .sig-need-rotate on #sig-modal) */
#sig-modal .flha-sig-rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  text-align: center;
  background: rgba(0,0,0,0.86);
  backdrop-filter: blur(3px);
}

#sig-modal.sig-need-rotate .flha-sig-rotate-hint {
  display: flex;
}

#sig-modal .flha-sig-rotate-card {
  width: min(520px, 92vw);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,10,10,0.92);
  padding: 14px 14px 16px;
  box-shadow: 0 22px 70px rgba(0,0,0,0.65);
}

#sig-modal .flha-sig-rotate-card h3 {
  margin: 0 0 6px 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

#sig-modal .flha-sig-rotate-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}



/*----------------------------------------

/* Override Sig modal

/* Signature modal: move buttons into a right-side vertical rail so canvas gets more height */
#sig-modal .flha-modal-panel {
  position: relative; /* ensure absolute children anchor correctly */
}

/* Turn the topbar into an overlay rail on the right */
#sig-modal .flha-sig-topbar {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 10;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 10px;

  padding: 0;
  border: 0;
  background: transparent;
}

/* Hide title inside the rail so it doesn't steal space */
#sig-modal .flha-sig-title {
  display: none;
}

/* Optional: make the rail buttons feel consistent in a stack */
#sig-modal #sig-modal-save,
#sig-modal #sig-modal-clear,
#sig-modal #sig-modal-close {
  width: max-content;
}

#sig-modal .flha-sig-body {
  /* keep your existing lines, only replace padding-right */
  padding-right: calc(12px + env(safe-area-inset-right) + 90px);
}


/* Join FLHA page styles, scoped to join.php markup */
#join-app {
  position: relative;
  width: 100%;
  max-width: 768px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Each view takes the full app area */
#join-app .join-view {
  flex: 1 1 auto;
}

/* Header */
#join-app .app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 14px 16px;
  background: #050505;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#join-app .app-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Badge */
#join-app .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Card */
#join-app .card {
  margin: 16px;
  background: linear-gradient(145deg, #0a0a0a, #050505);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

#join-app .card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

#join-app .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}

#join-app .card-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
}

#join-app .muted {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 10px;
  margin-bottom: 12px;
}

/* Fields */
#join-app .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 12px;
}

#join-app .field label {
  font-size: 0.8rem;
  color: var(--muted);
}

#join-app .field input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #050505;
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.9rem;
  outline: none;
}

#join-app .field input::placeholder {
  color: rgba(158, 158, 158, 0.7);
}

#join-app .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 152, 0, 0.7);
}

/* Signature canvas */
#join-app .signature-pad {
  width: 100%;
  height: 150px;
  display: block;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #ffffff;
  overflow: hidden;
  touch-action: none;
}

/* Button */
#join-app .btn {
  width: 100%;
  margin-top: 14px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  color: #000000;
  box-shadow: 0 6px 18px rgba(255, 152, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.15s ease, opacity 0.1s ease;
}

#join-app .btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

#join-app .btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

/* Small screens */
@media (max-width: 480px) {
  #join-app .card {
    margin: 12px;
    padding: 12px;
  }

  #join-app .app-header {
    padding: 12px;
  }
}

/* Signature modal canvas surface */
#sig-modal .flha-sig-canvas-wrap {
  background: #ffffff; /* was #050505 */
  border: 1px solid rgba(0,0,0,0.12); /* optional: looks cleaner on white */
}

/* Make sure the actual canvas looks white too */
#sig-modal canvas {
  background: #ffffff;
}

/* Join FLHA signature canvas surface */
#join-app .signature-pad {
  background: #ffffff; /* was #050505 */
  border: 1px dashed rgba(0,0,0,0.25); /* optional */
}


/* Terms page only
   Add <body class="flha-body flha-terms"> in terms.php
*/

.flha-terms {
  background: radial-gradient(circle at top, #111827 0, #000000 60%);
  color: var(--text);
}

/* Shell matches the app container */
.flha-terms .app-shell {
  position: relative;
  width: 100%;
  max-width: 768px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header matches the main app header sizing and centering */
.flha-terms .app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 768px;
  height: 130px;
  padding: 10px 16px;
  background: #050505;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.flha-terms .terms-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.flha-terms .terms-logo img {
  height: 102px;
  width: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* Hide the little badge and title so the header looks like the rest of the app */
.flha-terms .app-title,
.flha-terms .badge {
  display: none;
}

/* Main scroll area matches #flha-main behavior */
.flha-terms .app-content {
  flex: 1 1 auto;
  padding: 16px 16px 24px;
  margin-top: 130px;
  margin-bottom: 110px;
  overflow-y: auto;
  background: radial-gradient(circle at top, #111827 0, #020617 60%);
}

/* Card styling that matches .flha-card */
.flha-terms .app-content > .card {
  background: linear-gradient(145deg, #0a0a0a, #050505);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

.flha-terms .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.flha-terms .muted {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Scrollable terms box */
.flha-terms .terms-scroll {
  margin-top: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #050505;
}

/* Bottom action bar like the rest of the app */
.flha-terms .terms-actions {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 768px;
  padding: 8px 5px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 45;
  background: linear-gradient(
    to top,
    rgba(5, 5, 5, 0.98),
    rgba(5, 5, 5, 0.9),
    rgba(5, 5, 5, 0)
  );
}

.flha-terms .terms-actions .btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}

/* Back */
.flha-terms .terms-actions .btn:not(.btn-primary) {
  background: #2b2b2b;
  color: var(--text);
  border: 1px solid #3a3a3a;
  box-shadow: none;
  margin-right: auto;
}

/* Accept */
.flha-terms .terms-actions .btn-primary {
  background: var(--accent);
  color: #000000;
  box-shadow: 0 6px 18px rgba(255, 152, 0, 0.5);
  margin-left: auto;
}

.flha-terms .terms-actions .btn:active {
  transform: translateY(1px) scale(0.99);
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .flha-terms .app-content {
    padding-inline: 12px;
    margin-bottom: 120px;
  }

  .flha-terms .terms-actions .btn {
    min-width: 110px;
    font-size: 0.85rem;
    padding-inline: 12px;
  }
}

/* Terms page styles, cloned from Join page styles */
#terms-app {
  position: relative;
  width: 100%;
  max-width: 768px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#terms-app .terms-view {
  flex: 1 1 auto;
}

/* Header */
#terms-app .app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 14px 16px;
  background: #050505;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#terms-app .app-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Badge */
#terms-app .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Card */
#terms-app .card {
  margin: 16px;
  background: linear-gradient(145deg, #0a0a0a, #050505);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-soft);
}

#terms-app .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}

#terms-app .muted {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 10px;
  margin-bottom: 12px;
}

/* Scroll box */
#terms-app .terms-scroll {
  margin-top: 12px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #050505;
}

/* Button */
#terms-app .btn {
  width: 100%;
  margin-top: 14px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--accent);
  color: #000000;
  box-shadow: 0 6px 18px rgba(255, 152, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.1s ease, background 0.15s ease, opacity 0.1s ease;
}

#terms-app .btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

@media (max-width: 480px) {
  #terms-app .card {
    margin: 12px;
    padding: 12px;
  }

  #terms-app .app-header {
    padding: 12px;
  }
}

/* Terms page: prevent page scroll, only the terms box scrolls */
html, body {
  height: 100%;
}

#terms-app {
  height: 100vh;
  overflow: hidden;              /* kills the outer scrollbar */
  display: flex;
  flex-direction: column;
}

/* Make the section fill the remaining height under the header */
#terms-app .terms-view {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header stays visible, content below it stays inside the viewport */
#terms-app .app-header {
  flex: 0 0 auto;
}

/* Main card becomes a fixed height container with its own internal layout */
#terms-app .card {
  margin: 16px;
  flex: 1 1 auto;
  overflow: hidden;              /* important */
  display: flex;
  flex-direction: column;
}

/* The scroll area takes the available space and becomes the only scroller */
#terms-app .terms-scroll {
  flex: 1 1 auto;
  overflow: auto;
  max-height: none;              /* remove the 52vh clamp */
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #050505;
}

/* Button stays pinned at bottom of the card, no page scrolling needed */
#terms-app #tos-accept-btn {
  flex: 0 0 auto;
  margin-top: 14px;
}
