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

:root {
    --impact-color: #0d1e3f;
}

/* =========================
   GENERAL
========================= */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: var(--body-bg);
    color: var(--body-text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 20px 0;
}

h1 {
    color: var(--title-text-color);
}

h2 {
    color: var(--title-text-color);
}

h3,
h4 {
    color: var(--subtitle-text);
}

.main-content {
    flex: 1 0 auto;
    overflow-y: auto;
    padding-bottom: 40px;
}

.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo-wrapper {
    display: flex;
    justify-content: center;
    padding: 10px 0;
}

.logo {
    max-height: 168px;
    width: auto;
}

footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 10px 20px;
    text-align: center;
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
}

/* =========================
   BUTTON BASE (GLOBAL)
========================= */
button,
a.btn-main,
.btn-main,
a.action-btn {
    border: none;
    outline: none;
    text-decoration: none;
    transition: background 0.15s ease-in-out, color 0.15s ease-in-out;
}

button,
a.btn-main,
.btn-main,
a.action-btn {
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

/* =========================
   PRIMARY BUTTON (.btn-main)
========================= */
.btn-main {
    display: inline-block;
    width: 188px;
    padding: 12px 20px;
    font-weight: 600;
    text-align: center;
    border-radius: 6px;
    box-sizing: border-box;

    background: var(--btn-main-bg);
    color: var(--btn-main-text);
}

button.btn-main {
    appearance: none;
    -webkit-appearance: none;
}

/* HOVER — SINGLE SOURCE OF TRUTH */
.btn-main:hover,
a.btn-main:hover,
button.btn-main:hover {
    /*filter: brightness(1.15);*/
    background: var(--btn-main-bg-hover, var(--btn-main-bg));
    color: var(--btn-main-bg-hover-text, var(--btn-main-text));
}

/* ACTIVE */
button:active {
    transform: scale(0.97);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
}

/* DISABLED */
.btn-main:disabled,
.btn-main.disabled-btn {
    background: #999 !important;
    color: #eee !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    pointer-events: none;
}

/* =========================
   ACTION BUTTONS (TOP BAR)
========================= */
.action-btn {
    display: inline-block;
    min-width: 120px;
    padding: 6px 14px;
    border-radius: 4px;
    font-weight: bold;
    text-align: center;
}

/* BACK */
.action-btn.back {
    background: var(--btn-main-bg);
    color: var(--btn-main-text);
}

.action-btn.back:hover {
    background: var(--btn-main-bg-hover, var(--btn-main-bg));
    color: var(--btn-main-text-hover, var(--btn-main-text));
}

/* LOGOUT */
.action-btn.logout {
    background: #c00;
    color: #fff;
}

.action-btn.logout:hover {
    background: #e00;
}

/* =========================
   HEADER BEAM
========================= */
.header-beam {
    background-color: var(--beam-bg);
    padding: 16px 0;
}

.header-beam .impact-heading {
    font-family: Impact, sans-serif;
    font-size: 1.2rem;
    color: var(--impact-color);
    margin: 0;
    text-align: center;
}

/* =========================
   SESSION BAR
========================= */
.user-session-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    margin-top: 8px;
}

.divider-line {
    border: none;
    border-top: 1px solid var(--footer-bg);
    margin: 6px 0 18px 0;
}

/* =========================
   COOKIE BANNER
========================= */
#cookie-banner {
    position: fixed;
    bottom: -100px;
    left: 0;
    width: 100%;
    background-color: rgba(0,0,0,0.9);
    color: #fff;
    text-align: center;
    padding: 14px 12px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.6s ease-out;
}

#cookie-banner.show {
    bottom: 0;
    opacity: 1;
}

#accept-cookies {
    background-color: #ff8800;
    color: #fff;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
}

/* =========================
   ONBOARD MANAGEMENT
========================= */
.doc-toggle-row {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.doc-toggle-btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    background: var(--btn-main-bg);
    color: var(--btn-main-text);
    cursor: pointer;
}

.doc-toggle-btn.active {
    outline: 2px solid var(--beam-bg);
    font-weight: bold;
}

.doc-actions-row {
    display: flex;
    gap: 10px;
    margin: 10px 0 20px 0;
    flex-wrap: wrap;
}

.doc-btn-small {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    background: var(--btn-main-bg);
    color: var(--btn-main-text);
    cursor: pointer;
}

/* =========================
   ONBOARD MANAGEMENT – STRUCTURE FIX
========================= */

.doc-section {
    display: none;
}

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

.doc-structure {
    margin-top: 10px;
}

.doc-folder-card {
    border: 1px solid var(--footer-bg);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: #ffffff10;
}

/* HEADER MUST BE FLEX */
.doc-folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    gap: 10px;
}

.doc-folder-title {
    font-weight: bold;
    font-size: 12px;
    white-space: nowrap;
}

/* COLLAPSE MECHANISM */
.doc-file-list {
    margin-left: 15px;
    margin-top: 6px;
    display: none;
}

.doc-file-list.open {
    display: block;
}

/* FILE ROW ALIGNMENT */
.doc-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 2px 0;
    gap: 10px;
}

.doc-file-name {
    flex: 1;
    overflow-wrap: anywhere;
}

.doc-file-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

/* =====================================================
   GLOBAL HOVER & ACTIVE NORMALIZATION (FINAL OVERRIDE)
   ===================================================== */

/* ALL BUTTON TYPES — SAME HOVER LOGIC */
button:hover,
.btn-main:hover,
.doc-btn-small:hover,
.doc-toggle-btn:hover,
.action-btn:hover {
    background: var(--btn-main-bg-hover, var(--btn-main-bg)) !important;
    color: var(--btn-main-text-hover, var(--btn-main-text)) !important;
    filter: none !important;
}

/* ACTIVE — SAME PRESS FEEL EVERYWHERE */
button:active,
.btn-main:active,
.doc-btn-small:active,
.doc-toggle-btn:active,
.action-btn:active {
    transform: scale(0.97);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3);
}

/* REMOVE BROWSER DEFAULT FOCUS RINGS (CONSISTENT LOOK) */
button:focus,
.btn-main:focus,
.doc-btn-small:focus,
.doc-toggle-btn:focus,
.action-btn:focus {
    outline: none !important;
}

/* =========================
   CATEGORY BUTTON – ALIGN ACTIVE WITH HOVER
========================= */

.btn-cat {
    padding:6px 12px;
    border-radius:5px;
    background:var(--btn-main-bg);
    color:var(--btn-main-text);
    cursor:pointer;

    /* REMOVE BORDER ONLY */
    border:none !important;
    box-shadow:none !important;
}

.btn-cat.active {
    background:var(--btn-main-bg-hover);
    font-weight:bold;

    /* REMOVE BORDER ONLY */
    border:none !important;
    box-shadow:none !important;
}

#load-sequence-btn,
#clear-sequence-btn,
#load-measurement-btn,
#clear-measurement-btn {
    height: 34px;
    width: 88px;
    padding: 0 14px;
    font-size: 12px;
    font-weight: 600;
}

#task-popup-list,
#audit-list,
#sequence-list,
#measurement-list {
    font-size: 12px;
}

#task-popup-list div,
#audit-list div,
#sequence-list div,
#measurement-list div {
    font-size: 12px;
}


/* ===============================
   ADMIN SECTION HEADERS (BLACK)
   =============================== */

main .section > h3 {
  background-color: #28353B;/* #1f1f1f*/
  color: #ffffff;
  padding: 10px 14px;
  margin: -16px -16px 14px -16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

/* SECTION FRAME */
.section {
  padding: 16px;
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  background: #ffffff;
}

/* BLACK SECTION HEADER (REUSE EXISTING STYLE) */
.section > h3 {
  background-color: #28353B;/* #1f1f1f*/
  color: #ffffff;
  padding: 10px 14px;
  margin: -16px -16px 14px -16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.popup-box {
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.popup-header {
    background: var(--beam-bg);
    color: var(--beam-text-color);
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 12px;
    margin: -20px -20px 16px -20px;
}

/* === STANDARD ADMIN INPUT STYLE === */

.admin-field {
    max-width: 420px;
    width: 100%;
}

.admin-field label {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
    box-sizing: border-box;
}

/* ===== SYSTEM POPUP (CENTER, WHITE) ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  background: #ffffff;
  color: #111827;
  padding: 20px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 9999;
  min-width: 320px;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* optional variants */
.toast.error { color:#991b1b; }
.toast.warn  { color:#92400e; }

.ui-overlay{
    position: fixed;
    inset: 0;
    background: transparent; 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300000;
}

.ui-popup{
    background: var(--body-bg);  
    color: var(--body-text-color);
    padding: 20px;
    border-radius: 8px;
    min-width: 360px;
    max-width: 420px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.ui-popup-text{
    font-weight:380;
    margin-bottom:16px;
    color: var(--body-text-color)
}

.ui-popup-actions{
    display:flex;
    justify-content:center;
    gap:10px;
}

.ui-popup-actions button{
    all: unset;                 /* kill browser defaults */
    cursor: pointer;
}

/* NORMAL BUTTON = existing my-button */
.ui-popup-actions .my-button{
    background: var(--btn-main-bg);
    color: var(--btn-main-text);
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
}

/* PRIMARY (orange) */
.ui-popup-actions .btn-primary{
    background: var(--btn-main-bg-hover);
    color: var(--btn-main-bg-hover-text);
}

/* HOVER */
.ui-popup-actions .my-button:hover{
    background: var(--btn-main-bg-hover);
    color: var(--btn-main-bg-hover-text);
}

/* CANCEL BUTTON (neutral / secondary) */
.ui-popup-actions .my-button.cancel{
    background: #9e9e9e;
    color: #ffffff;
}

/* CANCEL HOVER */
.ui-popup-actions .my-button.cancel:hover{
    background: #7f7f7f;
    color: #ffffff;
}

/* FIX POPUP HEADER RADIUS */
.ui-popup .popup-header{
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

/* FORCE CENTER TEXT AFTER all:unset */
.ui-popup-actions .my-button,
.ui-popup-actions .my-button.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;          /* match visual size */
    padding: 0 16px;       /* horizontal only */
    line-height: 1;
    box-sizing: border-box;
}
/* ===== FORCE POPUP BUTTON STYLE ===== */

.my-button {
    padding: 6px 14px !important;
    min-width: 90px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    border: none !important;
    cursor: pointer !important;
}

/* CANCEL = GREY */
.my-button:not(.btn-primary) {
    background: #9e9e9e !important;
    color: #ffffff !important;
}

/* SAVE = ORANGE (BRANDING) */
.my-button.btn-primary {
    background: var(--btn-main-bg) !important;
    color: var(--btn-main-text) !important;
}

/* HOVER */
.my-button:hover {
    background: var(--btn-main-bg-hover, #ff9800) !important;
    color: var(--btn-main-bg-hover-text, #ffffff) !important;
}

/* UNIVERSAL FORM LAYOUT */
.form-section {
    margin-bottom: 25px;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fafafa;
}

.form-section h3 {
    margin-top: 0;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row textarea,
.form-row select {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

/* === FORCE INPUT + TEXTAREA TO BE IDENTICAL === */
.form-row input,
.form-row textarea {
    font-family: Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
}

/* === FORCE PLACEHOLDER TO MATCH === */
.form-row input::placeholder,
.form-row textarea::placeholder {
    font-family: Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    color: #9aa3ad !important;
    opacity: 1 !important;
}

/* === FORCE INPUT + TEXTAREA TO BE IDENTICAL === */
.form-row input,
.form-row textarea {
    font-family: Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
}

/* === FORCE PLACEHOLDER TO MATCH === */
.form-row input::placeholder,
.form-row textarea::placeholder {
    font-family: Arial, sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    color: #9aa3ad !important;
    opacity: 1 !important;
}

/* ACTION BAR */
.action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* NORMALIZE ALL ITEMS */
.action-bar > * {
    flex-shrink: 0;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
}

/* BUTTONS & LINKS */
.action-bar .btn-main,
.action-bar button.btn-main,
.action-bar a.btn-main {
    height: 40px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* FILE INPUT */
.action-bar input[type="file"] {
    height: 40px;
    font-size: 12px;
}

.measurement-item {
    font-size: 12px;
    padding: 4px 8px;
}

#sequence-drop li {
    font-size: 12px;
    padding: 6px 10px;
}

/* =========================
   TABS (SINGLE / SEQUENCE)
========================= */
.tab-bar {
    display: flex;
    border-bottom: 2px solid #d0d0d0;
    margin-bottom: 20px;
    gap: 4px;
}

.tab {
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 600;
    color: var(--body-text-color);
    background: #e6e6e6;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.tab:hover {
    background: #dcdcdc;
}

.tab.active {
    background: #ffffff;
    border: 2px solid #d0d0d0;
    border-bottom: 2px solid #ffffff; 
    margin-bottom: -2px;
    color: var(--title-text-color);
    cursor: default;
}

/* REMOVE ICON INSIDE SEQUENCE ITEMS */
.seq-remove-btn{
    background: none;
    border: none;
    padding: 0 6px;
    margin-left: auto;
    font-size: 10px;        
    line-height: 1;
    cursor: pointer;
    color: #b30000;
    opacity: 0.7;
}

.seq-remove-btn:hover{
    opacity: 1;
    color: #e60000;
}

#sequence-drop li{
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    display: none;
}

.slider {
    position: relative;
    width: 36px;
    height: 18px;
    background: #ccc;
    border-radius: 18px;
    transition: background 0.2s;
}

.slider::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.switch input:checked + .slider {
    background: var(--subtitle-text);
}

.switch input:checked + .slider::after {
    transform: translateX(18px);
}

.switch-label {
    font-size: 13px;
}

/* MEASUREMENT PREVIEW TABLE */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

th, td {
    white-space: nowrap;
    padding: 6px 10px;
}

/* MEASUREMENT PREVIEW TABLE – COMPACT */
.preview-table {
    font-size: 12px;
}

.preview-table th,
.preview-table td {
    padding: 4px 6px;
    line-height: 1.2;
}