:root {
  --bg: #070b14;
  --card: rgba(17, 24, 39, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #7dd3fc;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(
      1200px 800px at 20% 0%,
      rgba(59, 130, 246, 0.18),
      transparent 55%
    ),
    radial-gradient(
      1000px 700px at 80% 10%,
      rgba(16, 185, 129, 0.14),
      transparent 55%
    ),
    var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    sans-serif;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 980px;
  margin: 18px auto;
  padding: 0 14px 40px;
}

/* Typography */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.header h1 {
  margin: 0;
  font-size: 24px;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
  color: #eaf2ff;
}

.title {
  margin: 0 0 8px;
  font-size: 20px;
}

.muted {
  color: var(--muted);
  margin: 6px 0 0;
}
.tiny {
  font-size: 12px;
}
.link {
  color: #e7ecff;
  text-decoration: none;
}
.link:hover {
  transform: scale(1.05);
}
a:hover {
  transition: 0.12s;
  text-decoration: underline !important;
}
/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  width: 100% !important;
}

/* Forms */
.label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  background: #111827;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(125, 211, 252, 0.7);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.12);
}

input[readonly] {
  opacity: 0.9;
  cursor: not-allowed;
}

/* Layout grids */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

@media (max-width: 760px) {
  .grid,
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }
}

/* Key/Value rows */
.kv .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.kv .row:last-child {
  border-bottom: none;
}

.highlight {
  color: var(--accent);
  font-weight: 700;
}

/* Buttons */
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn.primary {
  background: rgba(125, 211, 252, 0.14);
  border-color: rgba(125, 211, 252, 0.35);
}
.btn.ghost {
  background: transparent;
}
.btn:hover {
  filter: brightness(1.1);
}

/* Divider */
.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 14px 0;
}

/* ===== Overlay (Auth) ===== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);

  /* Responsive centering */
  margin: 0 auto 0;
  margin-top: 30vh;
  position: relative;
}

.auth-card input,
.auth-card button {
  width: 100%;
}

/* Message */
.msg {
  margin-top: 10px;
  min-height: 18px;
  color: var(--accent);
}

/* ===== DataTables buttons ===== */
.dt-btn {
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-right: 6px;
}
.dt-btn.danger {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.1);
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 9998; /* below auth overlay, above app */
}

.modal-card {
  width: min(560px, 96vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-body {
  margin: 12px 0;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* Checkboxes */
.checkrow {
  margin-top: 10px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}
.check input {
  width: 18px;
  height: 18px;
}

/* Reconciliation */
.reconcile {
  flex: 1 1 260px;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
}

.reconcile.neutral {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #9ca3af;
}
.reconcile.ok {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}
.reconcile.warn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}
.reconcile.bad {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* Rates drawer */
.rates {
  margin-top: 10px;
  font-size: 13px;
}
details summary {
  cursor: pointer;
  color: var(--muted);
}
/* ===========================
   AUTH OVERLAY + LOCK GATE
   =========================== */

body.locked {
  overflow: hidden;
}

body.locked #app {
  pointer-events: none;
  user-select: none;
  filter: blur(6px);
  opacity: 0.35;
}

/* OVERLAY IS THE ONLY THING THAT CONTROLS POSITION */
#authOverlay {
  position: fixed;
  inset: 0;
  z-index: 100000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: clamp(12px, 3vw, 28px);
  background: rgba(0, 0, 0, 0.55);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* THIS IS THE KEY LINE */
body:not(.locked) #authOverlay {
  display: none !important;
}

#authOverlay .auth-card {
  width: min(460px, 92vw);
  max-height: 90vh;
  overflow: auto;

  margin: 0; /* NO PUSH DOWN */
}

/* ===== FINAL AUTH OVERLAY OVERRIDES (paste at END of styles.css) ===== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: clamp(12px, 3vw, 28px);
  background: rgba(0, 0, 0, 0.55);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.overlay.hidden {
  display: none !important;
}

.auth-card {
  width: min(460px, 92vw);
  max-height: calc(100vh - (clamp(12px, 3vw, 28px) * 2));
  overflow: auto;

  margin: 0 !important; /* IMPORTANT: prevents shifting */
  padding: 22px;

  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
}

/* Optional: blur app behind while locked */
body.locked {
  overflow: hidden;
}
body.locked #app {
  pointer-events: none;
  user-select: none;
  filter: blur(6px);
  opacity: 0.35;
}
div.dt-container {
  position: relative;
  clear: both;
  justify-self: start;
  transform: scale(0.9);
}
/* ===== Two Column Layout ===== */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
}

.main-col {
  min-width: 0;
}
.main-col .card {
  width: 100%;
}
.side-col {
  min-width: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ===== Flow Card ===== */

.flow-card {
  position: sticky;
  top: 16px;
}

.flow {
  margin-top: 8px;
}

.step {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.arrow {
  text-align: center;
  color: var(--accent);
  font-weight: bold;
  padding: 4px 0;
}
/* =========================
   FINAL LAYOUT FIX
   ========================= */

/* 2-column grid that cannot overlap */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

/* Left column must be allowed to shrink (prevents overlap) */
.main-col {
  min-width: 0;
  overflow-x: auto;
}
.side-col {
  min-width: 0;
}

/* Make cards fill their grid cell */
.main-col .card,
.side-col .card {
  width: 100%;
}

/* DataTables: never use transform scale (breaks layout math) */
div.dt-container,
.dataTables_wrapper {
  width: 100% !important;
  max-width: 100%;
  transform: none !important;
}

/* Ensure table doesn't escape the card */
table.dataTable {
  width: 100% !important;
}

/* Sticky sidebar (optional) */
.flow-card {
  position: sticky;
  top: 16px;
}

/* Responsive: stack columns */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .flow-card {
    position: static;
  }
}
.main-col .dataTables_wrapper {
  font-size: 0.95rem;
}
/* ===== NAVBAR ===== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(17, 24, 39, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 14px;
}

.nav-brand {
  font-weight: 700;
  letter-spacing: 0.4px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 8px;
}

.nav-item {
  position: relative;
}

.nav-item a {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}

.nav-item a:hover {
  background: rgba(125, 211, 252, 0.08);
}

.nav-item.active > a {
  background: rgba(125, 211, 252, 0.14);
  border: 1px solid rgba(125, 211, 252, 0.25);
}

/* Sub menu */
.sub {
  position: absolute;
  top: 100%;
  left: 0;
  background: rgba(17, 24, 39, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  list-style: none;
  padding: 6px;
  min-width: 200px;

  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: 0.12s;
  z-index: 2000;
}

.has-sub:hover .sub {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.sub a {
  font-size: 13px;
  padding: 7px 10px;
}

/* Mobile */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--text);
}

@media (max-width: 900px) {
  .nav-menu {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(17, 24, 39, 0.98);
    border-bottom: 1px solid var(--border);
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .sub {
    position: static;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    border: none;
    padding-left: 10px;
  }
}
/* ===== NAVBAR ===== */
.main-nav {
  background: #0e1420;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-brand {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
}

.nav-link {
  color: #e5e7eb;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.has-sub {
  position: relative;
}

.sub {
  position: absolute;
  top: 100%;
  left: 0;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  list-style: none;
  padding: 6px;
  min-width: 180px;

  display: none;
  z-index: 200;
}

.has-sub:hover .sub {
  display: block;
}

.sub a {
  display: block;
  padding: 6px 8px;
  color: #e5e7eb;
  text-decoration: none;
  border-radius: 8px;
}

.sub a:hover {
  background: rgba(125, 211, 252, 0.12);
}

/* mobile */
.nav-toggle {
  display: none;
  margin-left: auto;
}

@media (max-width: 900px) {
  .nav-menu {
    display: none;
    flex-direction: column;
    background: #0e1420;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    padding: 10px;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }
}
/* Make Monthly Totals span across layout area if needed */
.fullwidth{
  width: 100%;
}

/* Your grid already does this, but keep it clean */
.layout{
  display:grid;
  grid-template-columns: 1fr 300px;
  gap:16px;
  align-items:start;
}

@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
}
.side-col {
  display: grid;
  gap: 12px;
  align-content: start;
}
/* =========================
   DataTables fixes (Ledger)
   ========================= */

/* Prevent the DataTables wrapper from overflowing weirdly */
.dt-container,
.dataTables_wrapper {
  width: 100%;
}

/* Put Length + Search on one line and align nicely */
.dt-layout-row,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dataTables_wrapper .dataTables_filter {
  margin-left: auto;
}

.dataTables_wrapper .dataTables_filter input {
  width: min(420px, 50vw);
  max-width: 100%;
}

/* Horizontal scroll container (DataTables scrollX) */
div.dt-scroll-body {
  border-radius: 12px;
}

/* Keep header labels on one line */
table.dataTable thead th {
  white-space: nowrap;
}

/* Keep key cells from wrapping (fixes the date splitting) */
#paymentsTable td,
#paymentsTable th {
  white-space: nowrap;
}

/* Memo can wrap nicely instead of making the table huge */
#paymentsTable td:nth-child(9) {
  white-space: normal;
  min-width: 220px;
}

/* Actions column stays readable */
#paymentsTable td:last-child,
#paymentsTable th:last-child {
  min-width: 140px;
}

/* Make the overall table area scroll on small screens */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}
.paidBadge {
    margin-left: auto;
    align-self: center;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(50, 255, 160, 0.35);
    background: rgba(50, 255, 160, 0.14);
    color: #32ffa0; /* lime */
    font-weight: 700;
    letter-spacing: 0.01em;
    display: none; /* hidden until paid */
    white-space: nowrap;
  }

  .item.isPaid .paidBadge {
    display: inline-flex;
  }
   /* Badge base */
  .statusBadge{
    margin-left: auto;
    align-self: center;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.06);
    color: #e7ecff;
    font-weight: 800;
    letter-spacing: 0.02em;
    display: none;
    white-space: nowrap;
  }

  /* Paid (lime) */
  .item.isPaid .statusBadge{
    display: inline-flex;
    border-color: rgba(50, 255, 160, 0.35);
    background: rgba(50, 255, 160, 0.14);
    color: #32ffa0;
  }

  /* Upcoming (red) */
  .item.isUpcoming .statusBadge{
    display: inline-flex;
    border-color: rgba(255, 90, 120, 0.55);
    background: rgba(255, 90, 120, 0.18);
    color: #ff5a78;
  }
  .statusBadge{
  margin-left:auto;
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.12);
  display:none;
}
label.item.isPaid .statusBadge{
  display:inline-flex;
  background: rgba(50,255,160,0.14);
  border-color: rgba(50,255,160,0.30);
  color:#32ffa0;
}
label.item.isUpcoming .statusBadge{
  display:inline-flex;
  background: rgba(255,90,120,0.16);
  border-color: rgba(255,90,120,0.35);
  color:#ff5a78;
}
footer {
  margin-top: 80px;   /* pushes footer lower from page content */
}

.footer-text {
  color: #434343;
  font-weight: 300;
  text-align: center;
}
.footer-divider {
  width: calc(100% - 120px); /* 30px left + 30px right */
  border-bottom: 1px solid #434343;
  margin: 0 auto;           /* centers the line */
  margin-bottom: 10px;
}

.footer-text {
  color: #434343;
  font-weight: 300;
  text-align: center;
  margin-top: 10px;
  margin-bottom: 10px;
  padding-bottom: 20px !important;
}
/* ===== UI polish ===== */
.wrap {
  max-width: 1300px;
  margin: 18px auto;
  padding: 0 14px 48px;
}

header {
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:flex-end;
  margin-bottom: 14px;
}

.brand h1 { margin: 0; font-size: 28px; letter-spacing: .2px; }
.brand .subtitle { margin: 6px 0 0; color: var(--muted); max-width: 820px; }

.status {
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 10px 12px;
  display:flex;
  align-items:center;
  gap:10px;
  min-width: 220px;
}

.status .dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
}

.card {
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  overflow: hidden;
}

.card .hd {
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.card .bd { padding: 14px 16px 16px; }

.grid {
  display:grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 980px){
  .grid { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: stretch; }
  .status { width: 100%; }
}

/* Make carousel less tall + cleaner */
.carousel .bd { padding: 0; }
.carouselViewport { overflow:hidden; }
.carouselTrack { display:flex; transition: transform .35s ease; }
.slide { min-width: 100%; }
.slideInner { padding: 12px; }
.slideInner iframe {
  width: 100%;
  height: 420px;
  border: 0;
  border-radius: 14px;
  background: rgba(0,0,0,.2);
}
@media (max-width: 980px){ .slideInner iframe { height: 360px; } }

.carouselControls .iconBtn{
  width:34px; height:34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor:pointer;
}
.carouselControls .dots { display:flex; gap:7px; align-items:center; }
.dotBtn{
  width:9px; height:9px; border-radius:999px;
  border: 0;
  background: rgba(255,255,255,.22);
  cursor:pointer;
}
.dotBtn.active { background: rgba(125, 211, 252, .85); }

.watchStatus {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.watchGrid {
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 980px){ .watchGrid { grid-template-columns: 1fr; } }

.watchTile{
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  border-radius: 16px;
  padding: 12px;
}
.watchHead{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.watchSym{ font-size: 18px; font-weight: 900; letter-spacing: .3px; }
.stateBadge{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
}
.stateBadge.CONFIRMED { border-color: rgba(110,231,183,.35); background: rgba(110,231,183,.10); }
.stateBadge.RECONSIDER { border-color: rgba(252,211,77,.35); background: rgba(252,211,77,.10); }
.stateBadge.SUSPENDED { opacity: .65; }

.kvRow{
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.kvRow .k{ color: var(--muted); margin-right: 6px; }
.kvRow .v{ font-weight: 700; }

.vwapRow{ display:flex; flex-wrap:wrap; gap: 8px; margin-bottom: 10px; }
.vpill{
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}
.reasonLine{
  color: var(--muted);
  font-size: 12.5px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* =========================================================
   RESPONSIVE LAYER (paste at END of your CSS)
   ========================================================= */

/* 1) Safer defaults for fluid layouts + text */
:root {
  --pad: clamp(12px, 3vw, 24px);
  --radius: clamp(12px, 2vw, 18px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden; /* prevents tiny horizontal scroll on mobile */
}

img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
}

a.link {
  display: inline-block; /* makes transform hover not cause weird reflow */
}

.header h1,
.brand h1 {
  font-size: clamp(20px, 2.4vw, 28px);
}

h2 {
  font-size: clamp(14px, 1.6vw, 16px);
}

.tiny {
  font-size: clamp(11px, 1.2vw, 12px);
}

/* 2) Containers: prevent “almost fits” overflow */
.container,
.wrap {
  width: min(1300px, 100%);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* 3) Cards: fluid padding */
.card {
  border-radius: var(--radius);
  padding: clamp(14px, 2.2vw, 22px) clamp(14px, 2.6vw, 24px);
}

/* 4) Grids: replace rigid columns with auto-fit (works everywhere) */
.grid,
.grid2,
.grid3,
.watchGrid,
.kvRow {
  display: grid;
  gap: 12px;
}

/* Forms / 2-3 column sections */
.grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* Two-column sections */
.grid2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Three-up small tiles */
.grid3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

/* Watch tiles */
.watchGrid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Key/Value row (your 4 columns) */
.kvRow {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* 5) Layout (main + sidebar): make sidebar fluid and non-overlapping */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: clamp(12px, 2vw, 20px);
  align-items: start;
}

.main-col,
.side-col {
  min-width: 0;
}

.main-col {
  overflow-x: auto; /* IMPORTANT: prevents DataTables overlap */
}

/* Stack at tablet/mobile */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .flow-card {
    position: static !important;
    top: auto !important;
  }
}

/* If viewport height is short, disable sticky (prevents awkward lock) */
@media (max-height: 720px) {
  .flow-card {
    position: static !important;
  }
}

/* 6) Header rows: wrap cleanly on small screens */
header,
.header {
  flex-wrap: wrap;
}

.status {
  width: min(420px, 100%);
}

/* 7) DataTables: make it scroll on small screens (no scaling) */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* If you use DataTables scrollX, keep it contained */
div.dt-scroll-body,
div.dataTables_scrollBody {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Never transform-scale DataTables containers */
div.dt-container,
.dataTables_wrapper {
  width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
}

/* Keep the table from forcing the layout wider than the card */
table.dataTable {
  width: 100% !important;
  max-width: 100%;
}

/* Make filter input usable on phones */
.dataTables_wrapper .dataTables_filter input {
  width: min(420px, 65vw);
}

@media (max-width: 560px) {
  .dt-layout-row,
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dataTables_wrapper .dataTables_filter {
    margin-left: 0;
    width: 100%;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
  }
}

/* 8) Long text: stop accidental overflow */
.reasonLine {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .reasonLine {
    white-space: normal;      /* allow wrap on phones */
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }
}

/* KV rows in flex areas: don’t squeeze to unreadable */
.kv .row {
  gap: 10px;
}
.kv .row > * {
  min-width: 0;
}

/* 9) Overlay + modal: always fit viewport safely */
.overlay,
#authOverlay,
.modal {
  padding: var(--pad) !important;
}

.auth-card,
.modal-card {
  width: min(560px, 96vw);
  max-height: calc(100vh - (var(--pad) * 2));
  overflow: auto;
}

/* 10) Carousel iframe height: fluid */
.slideInner iframe {
  height: clamp(280px, 55vh, 420px);
}

/* 11) Navbar: avoid hover-only traps on touch */
@media (hover: none) and (pointer: coarse) {
  .has-sub:hover .sub {
    display: none; /* hover doesn't exist on touch */
  }
}

/* Mobile nav should not overflow viewport */
@media (max-width: 900px) {
  .nav-menu {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 12) Footer: keep divider adaptive */
.footer-divider {
  width: min(calc(100% - 60px), 1100px);
}

/* 13) Reduced motion (nice polish) */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}