/* ===========================
   Base / Reset
   =========================== */
:root {
  --brand-red: #b22222;
  --brand-blue: #253397;
  --brand-gold: #f7c641;
  --ink: #232946;
  --bg: #f6f8fb;

  /* iOS safe areas */
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
  width: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden; /* Prevent accidental horizontal scroll or right-side gaps */
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ===========================
   Desktop/Laptop (default)
   =========================== */

/* Header */
.main-header-bg {
  background: #fff;
  border-bottom: 1px solid #eee;
  box-shadow: 0 4px 16px 0 #0057ff06;
  position: relative;
  z-index: 110;
  width: 100%;
}

.main-header {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 80px;
  padding: 0 0.8rem;
  gap: 1.1rem;
  width: 100%;
}

.logo-block {
  flex-shrink: 0;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.logo-img {
  width: 130px;
  height: 130px;
  object-fit: contain;
  margin-left: -20px;
}

.header-titles {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: 0.2rem;
}

.header-titles h1 {
  margin: 0 0 2px 0;
  color: var(--brand-red);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.28;
}

.header-titles h2 {
  margin: 0;
  color: var(--brand-red);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.25;
}

.new-badge {
  display: inline-block;
  background: var(--brand-red);
  color: #fff;
  font-size: 0.93em;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 7px;
  margin-left: 7px;
  line-height: 1.1;
  vertical-align: middle;
  letter-spacing: 0.01em;
  position: relative;
  top: -1px;
  box-shadow: 0 2px 6px #0001;
  text-transform: uppercase;
  font-family: inherit;
}

/* Marquee */
.marquee-wrap {
  width: 100%;
  background: #f7c641cf;
  border-bottom: 1px solid #e7ab37;
  position: relative;
  font-size: 1rem;
  font-weight: 500;
  color: var(--brand-red);
  overflow: hidden;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

.flash-text {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  font-size: 1.14rem;
  font-weight: 600;
  color: blue;
  letter-spacing: 0.01em;
  animation: fadeInFlash 0.8s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.7s;
}

@keyframes fadeInFlash {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navigation */
nav {
  width: 100%;
  background: #ae2424d9;
  border-bottom: 2.5px solid var(--brand-gold);
  box-shadow: 0 6px 28px 0 #00000008;
  z-index: 100;
  font-size: 1rem;
  position: sticky;
  top: 0;
}

.navbar {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}

.menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
  padding: 0 1.5rem 0 0;
  width: 100%;
  height: 45px;
  list-style: none;
}

.menu > li {
  position: relative;
  user-select: none;
}

.menu > li > button,
.menu > li > a {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  padding: 1.1rem 0.4rem;
  border-radius: 3.5px;
  letter-spacing: 0.04em;
  transition: background 0.16s, color 0.16s;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.menu > li > button:hover,
.menu > li > button.active,
.menu > li > a:hover,
.menu > li > a.active {
  background: var(--brand-gold);
  color: var(--brand-red);
}

.arrow-down {
  display: inline-block;
  margin-left: 0.18em;
  font-size: 0.9em;
  pointer-events: none;
  vertical-align: middle;
  transition: transform 0.18s;
}

.submenu .arrow-down,
.subsubmenu .arrow-down {
  margin-left: 2.5em !important;
}

.menu > li > button.active .arrow-down,
.menu > li:focus-within > button .arrow-down,
.menu > li:hover > button .arrow-down {
  transform: rotate(180deg);
}

/* Submenus */
.submenu,
.subsubmenu {
  display: none;
  position: absolute;
  left: 0;
  min-width: 190px;
  background: #f7f8ef;
  border-radius: 0 0 7px 7px;
  box-shadow: 0 8px 32px 0 #b222221a;
  z-index: 20;
  padding: 0.5rem 0;
  margin-top: 0;
  animation: fadeIn 0.18s;
  list-style: none;
}

.submenu a,
.submenu > li > button,
.subsubmenu a {
  text-decoration: none !important;
}

.submenu > li { margin-bottom: 0.10rem; }
.submenu > li:last-child { margin-bottom: 0; }

.subsubmenu > li { margin-bottom: 0.46rem; }
.subsubmenu > li:last-child { margin-bottom: 0; }

.menu > li > button.active + .submenu,
.submenu.open {
  display: block;
}

.submenu > li > button,
.submenu > li > a {
  width: 250px;
  background: none;
  border: none;
  color: #253397;
  font-size: 1.1rem;
  padding: 0.77rem 1.1rem;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.33em;
}

.submenu > li > button:hover,
.submenu > li > button.active,
.submenu > li > a:hover,
.submenu > li > a.active {
  background: #c9c9e8;
  color: var(--brand-red);
  font-weight: 600;
}

.subsubmenu {
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 300px;
  border-radius: 0 7px 7px 7px;
  margin-left: 0;
  animation: fadeInRight 0.18s;
  box-shadow: 0 8px 32px 0 #b2222212;
  background: #f7f8ef;
  padding: 0.4rem 0;
  z-index: 100;
}

.submenu > li { position: relative; }

.submenu > li:hover > .subsubmenu,
.submenu > li:focus-within > .subsubmenu,
.submenu > li > button.active + .subsubmenu,
.subsubmenu.open {
  display: block;
}

.subsubmenu li a {
  display: block;
  padding: 0.54rem 1.1rem;
  color: #862d66;
  text-decoration: none !important;
  border-radius: 4px;
  font-size: 0.99rem;
  font-weight: 600;
  transition: background 0.13s, color 0.13s;
  outline: none;
}

.subsubmenu li a:hover,
.subsubmenu li a.active {
  background: var(--brand-gold);
  color: var(--brand-red);
}

/* Hamburger */
.hamburger {
  display: none;
  width: 39px;
  height: 39px;
  background: transparent;
  border: none;
  cursor: pointer;
  margin-right: 0.7rem;
  position: relative;
  z-index: 210;
}

.hamburger span,
.hamburger span:before,
.hamburger span:after {
  content: '';
  display: block;
  height: 4px;
  width: 26px;
  background: var(--brand-red);
  border-radius: 2px;
  margin: 0 auto;
  transition: 0.3s;
  position: absolute;
  left: 6px;
}

.hamburger span { top: 18px; }
.hamburger span:before { top: -8px; position: absolute; }
.hamburger span:after { top: 8px; position: absolute; }
.hamburger.active span { background: transparent; }
.hamburger.active span:before { transform: rotate(45deg) translate(5px,5px); }
.hamburger.active span:after { transform: rotate(-45deg) translate(6px,-7px); }

/* Main */
main {
  flex: 1;
  padding: 2.3rem 1.5rem 2.5rem 1.5rem;
  background: var(--bg);
  min-height: 320px;
  animation: fadeIn 0.5s;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

#main-flash-h2 {
  color: #0014a8;
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: -80px;
  margin-bottom: -30px;
  letter-spacing: 0.03em;
  transition: opacity 0.7s;
  min-height: 2.7em;
  animation: fadeInFlash 0.7s;
  line-height: 1.2;
}

#main-flash-p {
  color: #454d5e;
  font-size: 1.11rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 auto 0.5em auto;
  line-height: 1.6;
  transition: opacity 0.7s;
  animation: fadeInFlash 0.7s;
  text-align: center;
  font-style: italic;
}

/* Footer */
.footer {
  background: var(--brand-blue);
  color: #fff;
  text-align: center;
  padding: 0;
  height: 35px;
  line-height: 35px;
  font-size: 1rem;
  letter-spacing: 0.5px;
  box-shadow: 0 -3px 16px #0057ff0b;
  margin-top: auto;
  min-height: 35px;
  max-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

/* View count section (centered) */
.view-count-div {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 40px auto 0 auto;
  width: 100%;
}

.view-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.view-count h7 {
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 5px;
  display: block;
}

.view-count table {
  margin: 0 auto;
  font-size: 1.2rem;
  text-align: center;
}

.view-count td {
  min-width: 22px;
  height: 22px;
  font-size: 1rem;
  text-align: center;
  font-weight: 700;
  border-radius: 4px;
  background: #17a2b8;
  color: #fff;
  border: 1px solid yellow;
}

/* Online users and district popup */
.online-users {
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  border-radius: 8px;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 40px;
  margin-bottom: -40px;
}

.online-users span {
  color: #198754;
}

.district-popup {
  position: absolute;
  top: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1.5px solid var(--brand-red);
  border-radius: 8px;
  box-shadow: 0 6px 18px #0002;
  min-width: 240px;
  z-index: 40000;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 8px;
}

.district-popup-content { position: relative; }

.close-btn {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 1.5em;
  color: var(--brand-red);
  cursor: pointer;
}

.centered-heading { text-align: center; }

.district-popup ul {
  margin: 0;
  padding-left: 0.8em;
}

.district-popup li {
  list-style: disc;
  margin-bottom: 0.18em;
}

/* Form footer button (centered) */
.form-group.mb-3 {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 32px auto;
  padding-left: max(0.75rem, var(--safe-left));
  padding-right: max(0.75rem, var(--safe-right));
}

.btnBottom {
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  background: #eaf7dc;
  color: #227317;
  border: none;
  border-radius: 8px;
  padding: 10px 5px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(52,117,196,0.08);
  cursor: pointer;
  max-width: 98vw;
  width: 98%;
  display: block;
  white-space: normal;
  word-break: break-word;
}

/* Slideshow frames */
.slideshow-frame-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 3vw;
  margin: 2.2rem 0 2.3rem 0;
  width: 100%;
  flex-wrap: wrap;
}

.slideshow-frame {
  background: #fff;
  border: 1px solid #B22222;
  border-radius: 1.4rem;
  box-shadow: 0 4px 24px #0002;
  width: 330px;
  height: 220px;
  min-width: 0;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.18s;
}

.crossfade-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 1.2rem;
  box-shadow: 0 2px 13px #0001;
  opacity: 0;
  position: absolute;
  left: 0;
  top: 0;
  transition: opacity 0.8s;
  background: #f8fff8;
  min-width: 0;
  min-height: 0;
  display: block;
}

.crossfade-img:first-child { z-index: 1; }
.crossfade-img:last-child { z-index: 2; }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Safety: predictable sizing and no accidental overflow */
.kar-dashboard-flex, .kar-dashboard-flex * { box-sizing: border-box; }

/* Container */
.kar-dashboard-flex {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 25px auto 18px auto;
  margin-top:1px;
  max-width: 900px;
  width: 99vw;
  background: #f6f8fb;
  border-radius: 12px;
  box-shadow: 0 4px 24px #f6f8fb;
  padding: 30px 10px;
  position: relative;
  overflow: hidden;
}

/* Title */
.kar-dashboard-circle {
  background: #b22222d1;
  color: #f3f7fa;
  font-size: clamp(1.02rem, 2.6vw, 1.22rem);
  font-weight: 800;
  border-radius: 10px;
  padding: 8px 38px;
  box-shadow: 0 2px 12px #25339723;
  border: 1.2px solid #e1b117;
  text-align: center;
  letter-spacing: 0.02em;
  width: fit-content;
  min-width: 170px;
  max-width: 95vw;
  white-space: nowrap;
}

/* Circle totals row */
.kar-summary-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  flex-wrap: nowrap;
  margin-top: 10px;
  margin-bottom: 4px;
}

.kar-summary-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  letter-spacing: .5px;
  border: 2px solid #2a2a2a22;
  box-shadow: 0 2px 12px #0001;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .06s ease, box-shadow .2s ease;
}
.kar-summary-box:hover { box-shadow: 0 3px 16px #0002; }
.kar-summary-box:active { transform: translateY(1px); }

/* Summary color themes */
.kar-sum-division { background:#c75918; border-color:#7e3a11; }
.kar-sum-subdiv   { background:#2a8a3a; border-color:#1e5f29; }
.kar-sum-ho       { background:#1f4464; border-color:#172f46; }
.kar-sum-so       { background:#b88703; border-color:#7b5f02; }
.kar-sum-bo       { background:#c26d8e; color:#fff; border-color:#b88c80; }
.kar-sum-total    { background:#695761; border-color:#6d620a; }

/* Arrow line (desktop/tablet) */
.kar-dashboard-hline {
  width: 100%;
  height: 40px;
  position: relative;
  margin-top: 8px;
  pointer-events: none;
}

/* Regions wrapper (desktop/tablet) */
.kar-dashboard-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 50px;
  justify-content: center;
  width: 100%;
  margin-top: 16px;
  align-items: flex-start;
}

/* One region group */
.kar-region-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 160px;
  max-width: 260px;
  position: relative;
  contain: layout;
}

/* Region title */
.kar-region-title {
  font-size: clamp(1.02rem, 2.4vw, 1.12rem);
  font-weight: 700;
  margin-bottom: 8px;
  margin-top:-20px;
  letter-spacing: 0.5px;
  text-align: center;
  padding: 9px 14px;
  border-radius: 14px;
  box-shadow: 0 1px 6px #25339722;
  background: #f7c641;
  color: #1862a0;
  min-width: 112px;
  width: fit-content;
}
.kar-region-title.bg { background:#cc83df; color:#fff; border-radius: 10px; padding: 6px 24px; }
.kar-region-title.nk { background:#229d97; color:#fff; border-radius: 10px; padding: 6px 24px;}
.kar-region-title.sk { background:#caaf12; color:#fff; border-radius: 10px; padding: 6px 24px;}

/* Rows inside a region (desktop defaults) */
.kar-region-toprow,
.kar-region-bottomrow {
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
  width: 100%;
}

/* Metric boxes */
.kar-region-box {
  width: 100px;
  height: 40px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 7px #25339732;
  padding: 7px 6px 5px 6px;
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1.2px solid #e1b117;
  color: #1862a0;
  justify-content: center;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease;
}
.kar-region-box:hover { box-shadow: 0 2px 14px #25339733; }
.kar-region-box:active { transform: translateY(1px); }

.kar-region-box.bg { background:#b27652; border-color:#ec9d7e; color:#fff; }
.kar-region-box.nk { background:#54a354; border-color:#80b980; color:#fff; }
.kar-region-box.sk { background:#1862a0; border-color:#1862a0; color:#fff; }

.kar-region-label { font-weight: 700; font-size: 0.96em; line-height: 1.15; }
.kar-region-count { font-weight: 800; font-size: 0.97em; letter-spacing: 1px; line-height: 1.2; }

/* NEW: Total POs box under each region */
.kar-region-total {
  margin-top: 2px;
  width: 160px;
  min-height: 38px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  letter-spacing: .4px;
  border: 2px solid #2a2a2a22;
  box-shadow: 0 2px 12px #0001;
  cursor: pointer;
  user-select: none;
}
.kar-region-total.bg { background:#695761; border-color:#6d620a; color:#fff; }
.kar-region-total.nk { background:#695761; border-color:#6d620a; color:#fff; }
.kar-region-total.sk { background:#695761; border-color:#6d620a; color:#fff; }

/* Modal */
.kar-dashboard-modal-bg {
  position: fixed; left:0; top:0; width:100vw; height:100vh; background:rgba(0,0,0,0.17);
  z-index:99999; display:none; justify-content:center; align-items:center;
}
.kar-dashboard-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 48px #0002;
  padding: 16px 10px 12px 10px;
  max-width: 1000px;
  width: 97vw;
  max-height: 85vh;
  overflow: auto;
  position: relative;
}
.kar-dashboard-modal table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.kar-dashboard-modal th, .kar-dashboard-modal td {
  border: 1px solid #e1e1e1; padding: 7px 9px; text-align: left; font-size: 1rem;
}
.kar-dashboard-modal th { background: #f7c641; color: #1862a0; }
.kar-dashboard-modal th.serial-col, .kar-dashboard-modal td.serial-col {
  width: 1%; white-space: nowrap; text-align: center;
}
.kar-dashboard-modal #kar-modal-content { overflow-x: auto; max-width: 97vw; }
.kar-dashboard-modal .close-btn {
  position:absolute; top:7px; right:10px; font-size:1.35em; color:#b22222; cursor:pointer; font-weight:bold;
}
.kar-dashboard-modal .export-btn {
  background:#f7c641; color:#1862a0; border:none; border-radius:6px; padding:7px 18px; font-weight:700; cursor:pointer;
  font-size:1rem; box-shadow:0 2px 8px #0001; margin-bottom:10px;
}


@media screen and (min-width: 1400px) {
  body { padding: 0 24px 28px; }
}



@media screen and (min-width: 1400px) {
  .kar-dashboard-flex {
    max-width: 1600px;
    width: 98vw;
    padding: 36px 32px;
  }
  .kar-dashboard-row  { gap: 80px; }
  .kar-region-group   { min-width: 220px; max-width: 320px; }
  .kar-region-box     { width: 130px; height: 50px; font-size: 1rem; }
  .kar-region-total   { width: 210px; min-height: 46px; }
  .kar-summary-box    { padding: 12px 28px; font-size: 1.08rem; }
  .kar-dashboard-circle { font-size: 1.35rem; padding: 10px 52px; }
}




@media screen and (min-width: 1400px) {
  .main-header { max-width: 1700px; }
  .navbar      { max-width: 1700px; }
  main         { max-width: 1700px; padding: 2.5rem 2.5rem; }
}




/* Replace the existing =1280px block with this: */
@media screen and (max-width: 1380px) {
  .kar-dashboard-flex { max-width: 1100px; }
  main         { max-width: 100%; }
  .main-header { max-width: 100%; }
  .navbar      { max-width: 100%; }
}














/* Tablet */
@media (max-width: 1000px) {
  .kar-dashboard-row { gap: 28px; }
  .kar-region-group { min-width: 180px; max-width: 200px; }
}

/* Mobile portrait (<=700px) */
@media (max-width: 700px) {
  .kar-dashboard-hline { display: none; }

  /* UPDATED: mobile summary layout
     Row 1: Division | Sub Dn (same line)
     Row 2: HO | SO | BO      (same line)
     Row 3: Total POs         (full width)
  */
  .kar-summary-row{
    display:grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap:12px;
    width:100%;
    margin-top:12px;
    padding:0 4px;
  }

  /* Division + SubDn (same row) */
  .kar-summary-box.kar-sum-division{ grid-column: 1 / 4; }
  .kar-summary-box.kar-sum-subdiv  { grid-column: 4 / 7; }

  /* HO / SO / BO (same row) */
  .kar-summary-box.kar-sum-ho{ grid-column: 1 / 3; }
  .kar-summary-box.kar-sum-so{ grid-column: 3 / 5; }
  .kar-summary-box.kar-sum-bo{ grid-column: 5 / 7; }

  /* Total POs full width */
  .kar-summary-box.kar-sum-total{ grid-column: 1 / -1; }

  /* Safety */
  .kar-summary-box { width: 100%; min-height: 48px; }
  .kar-summary-span-2 { grid-column: 1 / -1; } /* keep working if still present */

  .kar-dashboard-row {
    flex-direction: column;
    gap: 24px;
    width: 100%;
    margin-top: 12px;
  }

  .kar-region-group {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
  }

  .kar-region-toprow,
  .kar-region-bottomrow {
    display: grid;
    width: 100%;
    gap: 10px;
    padding: 0 2px;
  }
  .kar-region-toprow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kar-region-bottomrow { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .kar-region-box {
    width: 100%;
    min-height: 40px;
    height: 50px;
    padding: 10px 8px;
    font-size: clamp(0.92rem, 3.2vw, 1.02rem);
    border-radius: 10px;
  }
  .kar-region-label { font-size: clamp(1.0rem, 3.2vw, 1.2rem); }
  .kar-region-count { font-size: clamp(1.1rem, 3.4vw, 1.06rem); }

  .kar-region-title {
    font-size: clamp(1.1rem, 2.8vw, 1.2rem);
    font-weight: 700;
    margin-bottom: 8px;
    margin-top:-5px;
  }

  /* Region Total POs full width on mobile */
  .kar-region-total {
    width: 100%;
    min-height: 46px;
    margin-top: 2px;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .kar-summary-box { min-height: 44px; padding: 8px 10px; }
  .kar-region-box { min-height: 50px; }
  .kar-region-label { font-size: 0.95rem; }
  .kar-region-count { font-size: 0.98rem; }
}


/* ===========================
   Tablet (<= 991px)
   =========================== */
@media (max-width: 991px) {
  .main-header { max-width: 100%; }

  .navbar {
    max-width: 100%;
    padding-left: max(0.75rem, var(--safe-left));
    padding-right: max(0.75rem, var(--safe-right));
  }

  /* Off-canvas menu for tablet: keep fixed width drawer */
  .menu {
    flex-direction: column;
    position: fixed;
    left: -300px;
    top: 148px;
    width: 245px;
    min-width: 245px;
    max-width: 245px;
    height: calc(100vh - 148px);
    background: #fff;
    overflow-y: auto;
    box-shadow: 5px 0 18px #2329460d;
    z-index: 180;
    transition: left 0.28s;
    gap: 0.1rem;
    padding: 0.5rem 0.1rem 0 0.1rem;
    border-radius: 0 13px 13px 0;
    align-items: flex-start;
  }
  .menu.open { left: 0; }

  .menu > li,
  .menu > li > button,
  .menu > li > a {
    width: 100%;
    min-width: 245px;
    max-width: 245px;
  }

  .menu > li > button,
  .menu > li > a {
    padding: 0.9rem 1.2rem;
    margin-bottom: 0.1rem;
    text-align: left;
    color: var(--brand-red); /* ensure readability on white bg */
  }

  .submenu,
  .subsubmenu {
    position: static;
    left: 0;
    min-width: 0;
    width: 100%;
    max-width: none;
    box-shadow: none;
    border-radius: 0 0 7px 7px;
    background: #f9faff;
    padding: 0.3rem 0.1rem 0.3rem 1.1rem;
  }

  .submenu > li > button,
  .submenu > li > a {
    padding: 0.7rem 1.3rem;
    border-radius: 0 7px 7px 0;
    width: 100%;
  }

  .subsubmenu {
    background: #f7fafc;
    padding: 0.2rem 0.1rem 0.2rem 1.3rem;
  }

  .subsubmenu li a { padding: 0.47rem 1.2rem; }

  .hamburger { display: block; }
  nav { position: static; }

  main {
    padding: 1.15rem 0.7rem 1.5rem 0.7rem;
    max-width: 100%;
  }

  #main-flash-h2 { font-size: 1.4rem; min-height: 2.4em; }
  #main-flash-p { font-size: 1rem; max-width: 95vw; padding: 0 8vw; }

  .slideshow-frame-container { gap: 1vw; }
  .slideshow-frame {
    width: 28vw;
    min-width: 180px;
    height: 18vw;
    min-height: 120px;
  }
}





/* ===========================
   Mobile (<= 600px)
   =========================== */
@media (max-width: 600px) {
  /* Header sizing */
  .main-header {
    height: 66px;
    padding: 0.22rem 0.18rem 0.14rem 0.16rem;
    width: 100%;
  }
  .logo-block { width: 90px; height: 90px; }
  .logo-img {
    width: 100px;
    height: 100px;
    margin-left: 5px;
  }
  .flash-text { font-size: 0.9rem; }
  .header-titles h1 { font-size: 1.1rem; margin-left: -20px; }
  .header-titles h2 { font-size: 1.1rem; margin-left: -10px; }

  /* Ensure full-width backgrounds extend to safe areas */
  .navbar, nav {
    width: 100%;
    max-width: 100%;
    background: #ae2424d9;
  }

  /* Mobile menu: full-width drawer */
  .menu,
  .menu > li,
  .menu > li > button,
  .menu > li > a {
    min-width: 100%;
    max-width: 100%;
    width: 100%;
    font-size: 1.1rem;
    color: var(--brand-red);
  }

  .menu {
    position: fixed;
    left: -100%;
    top: 50px; /* below header+marquee */
    height: calc(100vh - 50px);
    background: #fff;
    box-shadow: 5px 0 18px #2329460d;
    z-index: 180;
    transition: left 0.28s;
    gap: 0.1rem;
    padding: 0.5rem 0.1rem 1rem 0.1rem;
    border-radius: 0 13px 13px 0;
    align-items: flex-start;
    overflow-y: auto;
  }
  .menu.open { left: 0; }

  #main-flash-h2 {
    font-size: 1.2rem;
    min-height: 2.1em;
    margin-bottom: 20px;
    padding: 0 0.3em;
  }
  #main-flash-p {
    font-size: 0.96rem;
    padding: 0 0.4em;
    max-width: 100%;
    text-align: justify;
    font-family: Arial, sans-serif;
    line-height: 1.5;
  }

  .district-popup {
    min-width: 160px;
    font-size: 1em;
    padding: 8px 4px 8px 8px;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Slideshow: stacked and full width */
  .slideshow-frame-container {
    flex-direction: column;
    align-items: center;
    gap: 2.3rem;
    width: 100%;
  }
  .slideshow-frame {
    width: 100%;
    max-width: 100%;
    height: 54vw; /* responsive height */
    min-width: 0;
    min-height: 60px;
    border-radius: 1rem;
  }
  .slideshow-frame img.crossfade-img {
    border-radius: 1rem;
    height: 100%;
    width: 100%;
    object-fit: cover;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
  }
}

/* ===========================
   Small Phones (<= 480px)
   =========================== */
@media (max-width: 480px) {
  .slideshow-frame-container { gap: 1.2rem; }
  .slideshow-frame {
    width: 100%;
    max-width: 100%;
    height: 54vw;
  }
}