:root {
  --primary: #4682b4;
  --primary-dark: #38678f;
  --primary-darker: #294d6b;
  --primary-color: #fff;
  --secondary: #af46b4;
  --border: #c5c5c5;
  --alt: #fff;
  --modal-margin-top: 12vh;
  --success: #4bb446;
  --success-dark: #368532;
  --info: #b2cce1;
  --warning: #b47846;
  --warning-dark: #995f36;
  --danger: #b4464b;
  --danger-dark: #8f383b;
  --inverse: #333;
  --secondary-dark: #943f99;
  --secondary-darker: #77337a;
  --neutral: #f5f5f5;
  --modal-danger: #cc0000;
  --modal-danger-dark: #990000;
  --overlay-bg: #eee;
  --modal-textarea-bg: #fdf5e6;
  --row-odd-bg: #f3f3f3;
  --row-hover-bg: #fdfdea;
}

/* -------------------------------------------
   Base & Typography
------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: Tahoma, Geneva, sans-serif;
  margin: 0;
  padding: 0;
  color: #555;
  font-size: 1rem;
}

h1 {
  margin-top: 0;
  font-size: 4em;
  margin-bottom: 0.2em;
}

h2 { font-size: 2em; }
p { line-height: 1.5; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

/* -------------------------------------------
   Forms
------------------------------------------- */
form { width: 100%; }

/* Target all text-like inputs, selects, and textareas cleanly */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"])),
select,
textarea {
  padding: 0.6em;
  font-size: 1em;
  font-family: inherit; /* Syncs font with body automatically */
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}

:where(input:not([type="checkbox"]):not([type="radio"])):focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

textarea {
  height: 100%;
  line-height: 1.6;
}

label {
  margin: 1.4em 0 0.4em 0;
  clear: both;
  display: block;
  text-align: left;
}

label span { color: green; }

input[type="checkbox"] {
  margin: 1.4em;
  top: 0.3em;
  position: relative;
  width: 1.4em;
  height: 1.4em;
}

input[type="radio"] { margin: 1.6em 0 2em 1em; }

/* -------------------------------------------
   Buttons
------------------------------------------- */
button,
.button {
  background-color: var(--primary);
  border: 1px solid var(--primary-dark);
  margin: 1em 0.1em 0 0;
  padding: 0.6em 1.2em;
  color: var(--primary-color);
  font-size: 0.9em;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  line-height: normal;
  border-radius: 6px;
  display: inline-block;
  text-align: center;
}

button:hover,
.button:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-darker);
  color: var(--primary-color);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Button & Alert Variants */
.danger { background-color: var(--danger); border-color: var(--danger-dark); color: var(--primary-color); }
.danger:hover { background-color: var(--danger-dark); border-color: var(--danger-dark); }

.warning { background-color: var(--warning); border-color: var(--warning); color: var(--primary-color); }
.warning:hover { background-color: var(--warning-dark); border-color: var(--warning-dark); }

.success { background-color: var(--success); border-color: var(--success-dark); color: var(--primary-color); }
.success:hover { background-color: var(--success-dark); border-color: var(--success-dark); }

.inverse { background-color: var(--inverse); border-color: #222; color: var(--primary-color); }
.inverse:hover { background-color: #222; border-color: #111; }

.alt { background-color: transparent; border-color: var(--primary); color: #333; }
.alt:hover { background-color: transparent; border-color: var(--primary); color: var(--primary); }

/* -------------------------------------------
   Lists & Tables
------------------------------------------- */
ul { margin: 2em 0; list-style-type: circle; }
li { line-height: 1.8; }

table {
  border-collapse: collapse;
  width: 100%;
}

th {
  background-color: var(--primary);
  color: var(--primary-color);
}

th, td {
  border: 1px var(--primary-darker) solid;
  padding: 0.7em;
}

td:hover { cursor: auto; }
tr:hover, tr:nth-child(odd):hover { background-color: var(--row-hover-bg); }
tr:nth-child(odd) { background-color: var(--row-odd-bg); }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2em 0;
}

/* -------------------------------------------
   Pagination
------------------------------------------- */
.pagination {
  display: inline-block;
  margin-top: 1em;
  font-size: 0.8em;
}
.pagination:first-of-type { margin: 0 0 1em 0; }

.pagination a {
  color: black;
  float: left;
  padding: 8px 16px;
  text-decoration: none;
  border: 1px solid #ddd;
  background-color: #ffffffcc;
  cursor: pointer;
}

.pagination a.active {
  background-color: var(--primary);
  color: var(--primary-color);
  border-color: var(--primary);
}

.pagination a:hover:not(.active) {
  background-color: #ddd;
  color: var(--primary);
}

.pagination a:first-child { border-radius: 5px 0 0 5px; }
.pagination a:last-child { border-radius: 0 5px 5px 0; }

/* -------------------------------------------
   Cards
------------------------------------------- */
.card {
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2), 0 4px 20px 0 rgba(0, 0, 0, 0.19);
  margin-bottom: 1em;
  display: flex;
  flex-direction: column;
}

.card-heading {
  font-size: 1.2em;
  background-color: var(--primary);
  color: var(--primary-color);
  padding: 12px;
  border: 1px solid var(--primary-darker);
}
.card-heading.danger { background-color: var(--danger); border-color: var(--danger-dark); }
.card-heading.success { background-color: var(--success); border-color: var(--success-dark); }
.card-heading.warning { background-color: var(--warning); border-color: var(--warning-dark); }

.card-body {
  padding: 20px;
  background-color: var(--alt);
  flex-grow: 1;
}

/* -------------------------------------------
   Modals
------------------------------------------- */
#overlay {
  background-color: rgba(0, 0, 0, 0.7);
  position: fixed;
  inset: 0; /* Shorthand for top, right, bottom, left: 0 */
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#modal-container {
  position: fixed;
  inset: 0;
  z-index: 1010;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none; /* Allows clicking background when closed */
}

.modal {
  width: 90%;
  max-width: 570px;
  max-height: 85vh;
  z-index: 1020;
  background-color: var(--alt);
  opacity: 0;
  position: relative;
  margin-top: -160px;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  display: flex;
  flex-direction: column;
  pointer-events: auto; /* Re-enable clicks on the actual modal */
}

.modal.open {
  opacity: 1;
  margin-top: var(--modal-margin-top);
}

.modal-heading {
  font-size: 1.2em;
  background-color: var(--primary);
  padding: 12px;
  color: var(--primary-color);
  border: 1px solid var(--primary-darker);
  text-transform: uppercase;
}
.modal-heading.danger { background-color: var(--danger); border-color: var(--danger-dark); }
.modal-heading.success { background-color: var(--success); border-color: var(--success-dark); }
.modal-heading.warning { background-color: var(--warning); border-color: var(--warning-dark); }

.modal-body {
  flex: 1 1 auto;
  padding: 20px;
  border-inline: 1px solid var(--primary-darker);
  overflow-y: auto;
}

.modal-body h5 {
  margin: 0 auto;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
}

.modal p { text-align: center; }
#delete-modal p:nth-child(1) { margin: 0; font-size: 18px; font-weight: bold; }
.modal p:nth-child(3) { margin: 0; }

.modal-footer {
  font-size: 1.2em;
  background-color: var(--overlay-bg);
  padding: 12px;
  color: #555;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  border: 1px solid var(--border);
  border-inline-color: var(--primary-darker);
}

.modal-footer button { margin: 2px 0 0 0.3em; font-size: 16px; }
.modal-footer button.alt { background-color: #fefefe; }

.modal-danger {
  background-color: var(--modal-danger);
  border: 1px solid var(--modal-danger-dark);
}

.modal textarea {
  font: inherit;
  font-size: 15px;
  margin: 0;
  padding: 8px;
  display: block;
  border: 1px solid var(--border);
  color: #000;
  background-color: var(--modal-textarea-bg);
  min-height: 7em;
  resize: none;
  line-height: 1.5;
}

/* -------------------------------------------
   Video Container (Modern Aspect-Ratio)
------------------------------------------- */
.video-container {
  width: 100%;
  aspect-ratio: 16 / 9;
}
.video-container.aspect-4-3 { aspect-ratio: 4 / 3; }
.video-container.aspect-1-1 { aspect-ratio: 1 / 1; }

.video {
  width: 100%;
  height: 100%;
  border: 0;
}

/* -------------------------------------------
   Form Validation & Utility Animations
------------------------------------------- */
form .form-field-validation-error,
form .form-field-validation-error:focus {
  border: 3px solid var(--danger);
  background-color: rgba(255, 0, 0, 0.07);
}

.validation-errors {
  margin: 0.5em 0 1em 0;
  padding: 0.3em 1em;
  border: 1px solid var(--danger);
  background-color: rgba(255, 0, 0, 0.07);
  color: var(--danger);
  border-radius: 6px;
  font-size: 0.9em;
}

.validation-errors li { margin-left: 1.2em; padding-left: 0; }

.shake { animation: form-shake 0.35s ease-in-out; }
.blink { animation: blinker 0.5s ease-in-out infinite alternate; }

@keyframes form-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes blinker {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* -------------------------------------------
   Spinner
------------------------------------------- */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  position: relative;
  margin: 0.6em;
}

.spinner::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  border-right-color: transparent;
  border-top-color: transparent;
  animation: spinning 0.5s infinite linear;
}

.spinner-lhs { justify-content: flex-start; }
.spinner-rhs { justify-content: flex-end; }

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

/* -------------------------------------------
   SVG Indicators (Tick / Cross)
------------------------------------------- */
.mx-indicator-hidden { display: none; }

#mx-tick, #mx-cross {
  max-width: 200px;
  min-width: 160px;
  margin: 33px auto;
}

.mx-circ { opacity: 0; stroke-dasharray: 130; stroke-dashoffset: 130; transition: all 1s; }
.mx-tick { stroke-dasharray: 50; stroke-dashoffset: 50; transition: stroke-dashoffset 1s 0.5s ease-out; }
.mx-cross { stroke-dasharray: 50; stroke-dashoffset: 50; transition: stroke-dashoffset 1s 0.7s ease-out; }

.mx-trigger.mx-drawn .path,
.mx-drawn + svg .path {
  opacity: 1;
  stroke-dashoffset: 0;
}

/* -------------------------------------------
   Utility Classes (Layout, Typography, Margins)
------------------------------------------- */
.float-right { float: right; position: relative; }
.float-left { float: left; position: relative; }

.text-left { text-align: left; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.xl { font-size: 1.5em; }
.lg { font-size: 1.3em; }
.sm { font-size: 0.85em; }
.xs { font-size: 0.7em; }

.cloak { display: none; }
.gold { background: linear-gradient(to right, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C); color: var(--primary-color); border: 1px #ded4c2 solid; }
.silver { background: linear-gradient(to right, #8faab7, #f1f8ff, #9eb2c1, #f0f6f9, #96a2a9); color: var(--primary-color); border: 1px #c0cbd1 solid; }
.tg-showing-statement { color: #666; margin-bottom: 1em; }

/* Global Border-Box Utility Injection */
.flex-row, .flex-column { display: flex; }
.flex-row    { flex-direction: row; }
.flex-column { flex-direction: column; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }
.justify-center  { justify-content: center; }
.justify-start   { justify-content: flex-start; }
.justify-end     { justify-content: flex-end; }
.align-center  { align-items: center; }
.align-start   { align-items: flex-start; }
.align-end     { align-items: flex-end; }
.align-stretch { align-items: stretch; }
.flex-grow   { flex-grow: 1; }
.flex-wrap   { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

/* Layout Containers */
:where(.container, .container-xxs, .container-xs, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl) {
  width: 90%;
  margin: 0 auto;
  padding: 1em;
}
.container     { max-width: 940px; }
.container-xxs { max-width: 450px; }
.container-xs  { max-width: 640px; }
.container-sm  { max-width: 760px; }
.container-md  { max-width: 820px; }
.container-lg  { max-width: 960px; }
.container-xl  { max-width: 1100px; }
.container-xxl { max-width: 1300px; }

/* Generated classes for margins via !important payload */
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 1em !important; } .mt-2 { margin-top: 2em !important; } .mt-3 { margin-top: 3em !important; } .mt-4 { margin-top: 4em !important; } .mt-5 { margin-top: 5em !important; } .mt-6 { margin-top: 6em !important; } .mt-7 { margin-top: 7em !important; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 1em !important; } .mb-2 { margin-bottom: 2em !important; } .mb-3 { margin-bottom: 3em !important; } .mb-4 { margin-bottom: 4em !important; } .mb-5 { margin-bottom: 5em !important; } .mb-6 { margin-bottom: 6em !important; } .mb-7 { margin-bottom: 7em !important; }
.ml-1 { margin-left: 1em !important; } .ml-2 { margin-left: 2em !important; } .ml-3 { margin-left: 3em !important; } .ml-4 { margin-left: 4em !important; } .ml-5 { margin-left: 5em !important; } .ml-6 { margin-left: 6em !important; } .ml-7 { margin-left: 7em !important; }
.mr-1 { margin-right: 1em !important; } .mr-2 { margin-right: 2em !important; } .mr-3 { margin-right: 3em !important; } .mr-4 { margin-right: 4em !important; } .mr-5 { margin-right: 5em !important; } .mr-6 { margin-right: 6em !important; } .mr-7 { margin-right: 7em !important; }

/* -------------------------------------------
   Responsive Breakpoints
------------------------------------------- */
@media screen and (max-width: 550px) {
  .pagination a { padding: 10px 14px; }

  button, button.button, a.button, .button {
    width: 100%;
    display: block;
    margin: 0.5em 0;
  }

  .modal-footer { flex-direction: column-reverse; }
  .modal-footer button:last-child { margin: 0 0 0 0.3em; }
  p.button-container { display: flex; flex-direction: column-reverse; }
}

/* Accessibility: Respect users who turn off animations */
@media (prefers-reduced-motion: reduce) {
  .shake, .blink, .spinner::after, .mx-tick, .mx-cross {
    animation: none !important;
    transition: none !important;
  }
}