:root {
  --navy: #081528;
  --navy2: #0d2138;
  --panel: #122a44;
  --panel2: #173657;
  --cyan: #22c7e8;
  --gold: #ffc400;
  --red: #ff3864;
  --green: #1fd180;
  --text: #f5f8fb;
  --muted: #9fb2c5;
  --line: rgba(255, 255, 255, 0.12);
  --white: #fff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 20px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--navy);
  color: var(--text);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.login-body {
  min-height: 100vh;
  background: radial-gradient(
    circle at top right,
    #16486a 0,
    #081528 42%,
    #050b16 100%
  );
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.35fr 0.75fr;
  gap: 24px;
  align-items: stretch;
}
.login-hero,
.login-card {
  background: rgba(13, 33, 56, 0.82);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px;
  backdrop-filter: blur(12px);
}
.brand-row {
  display: flex;
  gap: 18px;
  align-items: center;
}
.brand-logo {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  padding: 6px;
}
.side-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  padding: 4px;
}
.eyebrow {
  color: var(--cyan);
  letter-spacing: 0.04em;
  font-weight: 700;
  margin: 0 0 6px;
}
.login-hero h1,
.title-block h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 36px);
}
.hero-panel {
  margin-top: 90px;
  max-width: 680px;
}
.hero-label {
  display: inline-block;
  background: rgba(34, 199, 232, 0.13);
  border: 1px solid rgba(34, 199, 232, 0.3);
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--cyan);
  font-weight: 700;
}
.hero-panel h2 {
  font-size: clamp(28px, 5vw, 54px);
  line-height: 1.1;
  margin: 16px 0;
}
.hero-panel p:last-child {
  color: #c8d5e1;
  font-size: 18px;
  line-height: 1.7;
}
.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-card h2 {
  font-size: 30px;
  margin: 20px 0 4px;
}
.login-card label {
  display: block;
  margin: 18px 0 8px;
  color: #d7e4ee;
}
.login-card input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.filter-panel select,
.settings-panel select,
.modal-card input,
.modal-card textarea {
  width: 100%;
  background: #08172a;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}
.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font-weight: 800;
}
.primary-btn {
  background: linear-gradient(135deg, var(--cyan), #4c86ff);
  color: #06101e;
}
.ghost-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--text);
}
.login-card .primary-btn {
  width: 100%;
  margin-top: 22px;
}
.form-error {
  color: #ff8fa6;
  min-height: 22px;
}
.lang-switch-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  color: #c7d6e4;
  font-weight: 700;
}
.compact {
  font-size: 13px;
}
.lang-switch input {
  display: none;
}
.lang-switch span {
  display: block;
  width: 58px;
  height: 30px;
  background: #203a58;
  border-radius: 999px;
  position: relative;
  border: 1px solid var(--line);
}
.lang-switch span:before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 2px;
  border-radius: 50%;
  background: var(--cyan);
  transition: 0.2s;
}
.lang-switch input:checked + span:before {
  left: 29px;
  background: var(--gold);
}
.app-body {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #06101e;
  border-right: 1px solid var(--line);
  padding: 18px;
  z-index: 20;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.sidebar-brand small {
  display: block;
  color: var(--muted);
}
.side-nav {
  display: grid;
  gap: 10px;
}
.nav-item {
  border: 0;
  background: transparent;
  color: #d7e7f6;
  border-radius: 16px;
  padding: 13px;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
}
.nav-item:hover,
.nav-item.active {
  background: linear-gradient(
    135deg,
    rgba(34, 199, 232, 0.18),
    rgba(76, 134, 255, 0.14)
  );
  box-shadow: inset 3px 0 0 var(--cyan);
}
.main {
  min-width: 0;
  padding: 18px 22px 40px;
  background: linear-gradient(180deg, #0b182a, #071120);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 14px;
  background: rgba(8, 21, 40, 0.88);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(10px);
}
.title-block {
  min-width: 0;
}
.title-block h1 {
  font-size: 22px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-pill {
  background: #10243b;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
  white-space: nowrap;
}
.hamburger {
  display: none;
  background: #10243b;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}
.view {
  display: none;
  margin-top: 18px;
}
.view.active {
  display: block;
}
.filter-panel,
.kpi-grid,
.chart-grid,
.form-grid {
  display: grid;
  gap: 14px;
}
.filter-panel {
  grid-template-columns: 1.2fr repeat(3, 1fr) 1fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.filter-panel label,
.form-grid label,
.settings-panel label {
  display: block;
  color: #c8d6e4;
  margin-bottom: 7px;
  font-weight: 700;
}
.executive-summary {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: linear-gradient(135deg, #102947, #0d1e34);
  border: 1px solid rgba(34, 199, 232, 0.25);
  border-radius: 24px;
  padding: 22px;
}
.summary-text h2 {
  margin: 0 0 8px;
  font-size: 28px;
}
.summary-text p:last-child {
  margin: 0;
  color: #c5d5e4;
}
.summary-badge {
  min-width: 190px;
  text-align: center;
  background: rgba(255, 196, 0, 0.12);
  border: 1px solid rgba(255, 196, 0, 0.4);
  border-radius: 22px;
  padding: 14px;
}
.summary-badge span {
  display: block;
  font-size: 46px;
  font-weight: 900;
  color: var(--gold);
}
.summary-badge small {
  color: #e8d28a;
}
.kpi-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 14px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}
.kpi-card span {
  color: #c2d0df;
}
.kpi-card b {
  display: block;
  font-size: 34px;
  margin: 8px 0;
}
.kpi-card small {
  color: var(--muted);
}
.kpi-card.gold b {
  color: var(--gold);
}
.kpi-card.danger b {
  color: var(--red);
}
.equipment-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.equipment-card {
  background: #0d223a;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  min-width: 0;
}
.equipment-card img {
  width: 100%;
  height: 82px;
  object-fit: cover;
  background: #172f4d;
}
.equipment-card .body {
  padding: 10px;
}
.equipment-card b {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}
.equipment-card .num {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 8px;
}
.equipment-card .num strong {
  font-size: 28px;
  color: var(--red);
}
.equipment-card .bar {
  height: 5px;
  background: #203752;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.equipment-card .bar i {
  display: block;
  height: 100%;
  background: var(--cyan);
}
.chart-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}
.chart-card,
.table-card,
.settings-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}
.chart-card h3,
.table-card h3 {
  margin: 0 0 12px;
}
.chart-card.wide {
  grid-column: span 1;
}
.pareto-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  gap: 10px;
  align-items: center;
  margin: 11px 0;
}
.pareto-bar {
  height: 20px;
  background: #203752;
  border-radius: 999px;
  overflow: hidden;
}
.pareto-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
}
.donut-wrap {
  min-height: 220px;
  display: grid;
  place-items: center;
}
.donut {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: conic-gradient(
    var(--green) 0 42%,
    var(--gold) 42% 72%,
    var(--red) 72% 100%
  );
  display: grid;
  place-items: center;
}
.donut:before {
  content: "";
  width: 112px;
  height: 112px;
  background: var(--panel);
  border-radius: 50%;
  position: absolute;
}
.donut span {
  position: relative;
  text-align: center;
  font-weight: 900;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
}
.table-scroll {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: #0a1b30;
  color: #bfeeff;
  position: sticky;
  top: 0;
}
td {
  color: #d8e4ef;
}
.camera-btn {
  background: rgba(34, 199, 232, 0.12);
  border: 1px solid rgba(34, 199, 232, 0.3);
  border-radius: 12px;
  color: #bff4ff;
  padding: 8px 10px;
}
.news-feed {
  display: grid;
  gap: 16px;
}
.news-card {
  background: linear-gradient(180deg, #fbfdff, #eef5fb);
  color: #11233a;
  border-radius: 20px;
  padding: 22px;
  border-left: 6px solid var(--cyan);
  box-shadow: var(--shadow);
}
.news-card .date {
  color: #436078;
  font-weight: 800;
}
.news-card h3 {
  margin: 8px 0;
}
.news-card p {
  line-height: 1.7;
}
.tag {
  display: inline-block;
  background: #dff5fb;
  color: #03566e;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  margin-right: 6px;
}
.form-grid {
  grid-template-columns: repeat(4, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.full {
  grid-column: 1/-1;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal-card {
  width: min(780px, 100%);
  background: #0d2138;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  position: relative;
}
.close-modal {
  position: absolute;
  right: 14px;
  top: 12px;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 34px;
}
.media-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.media-gallery img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 14px;
  background: #1a334f;
}
.permission-table {
  min-width: 620px;
}
@media (max-width: 1180px) {
  .equipment-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .filter-panel {
    grid-template-columns: repeat(3, 1fr);
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 860px) {
  .login-shell {
    grid-template-columns: 1fr;
  }
  .hero-panel {
    margin-top: 40px;
  }
  .app-body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: -290px;
    transition: 0.25s;
  }
  .sidebar.open {
    left: 0;
  }
  .hamburger {
    display: block;
  }
  .topbar {
    align-items: flex-start;
  }
  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .chart-grid,
  .form-grid,
  .filter-panel {
    grid-template-columns: 1fr;
  }
  .equipment-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .executive-summary {
    flex-direction: column;
    align-items: stretch;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .title-block h1 {
    font-size: 18px;
  }
}
/* V2 additions */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-pill img,
.mini-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.user-pill small {
  color: var(--gold);
  font-weight: 800;
}
.nav-item[style*="display: none"] {
  display: none !important;
}
.equipment-card {
  cursor: pointer;
}
.equipment-card img {
  height: 118px;
  object-fit: contain;
  background: linear-gradient(180deg, #e9f4fb, #c8d7e5);
  padding: 4px;
}
.clickable {
  cursor: pointer;
}
.chart-hint {
  color: var(--cyan);
  font-weight: 700;
}
.pareto-row {
  grid-template-columns: minmax(150px, 220px) 1fr 76px;
}
.news-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  overflow: hidden;
}
.news-cover {
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 16px;
  background: #d6e1ec;
}
.news-content {
  min-width: 0;
}
.ghost-btn.small {
  padding: 7px 10px;
  margin-top: 12px;
  color: #0a263d;
  background: #dceaf5;
  border-color: #c5d7e5;
}
.insight-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.insight-kpis div {
  background: #07182a;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.insight-kpis b {
  display: block;
  font-size: 30px;
  color: var(--gold);
}
.insight-kpis span {
  color: #bdd0df;
}
.media-gallery video {
  width: 100%;
  height: 190px;
  border-radius: 14px;
  background: #000;
}
.file-link {
  display: block;
  color: #bff4ff;
  background: #07182a;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-decoration: none;
}
.form-grid small {
  display: block;
  margin-top: 6px;
  line-height: 1.45;
}
.permission-table input {
  transform: scale(1.25);
}
@media (max-width: 860px) {
  .news-card {
    grid-template-columns: 1fr;
  }
  .news-cover {
    height: 210px;
  }
  .insight-kpis {
    grid-template-columns: 1fr;
  }
  .equipment-card img {
    height: 150px;
  }
  .pareto-row {
    grid-template-columns: 1fr;
  }
  .pareto-row span {
    text-align: right;
  }
  .top-actions {
    width: 100%;
  }
  .user-pill {
    max-width: 100%;
    white-space: normal;
  }
  .filter-panel,
  .form-grid {
    padding: 14px;
  }
  .modal-card {
    max-height: 90vh;
    overflow: auto;
  }
}
/* ===== Responsive overflow fix ===== */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.app-body,
.main,
.view,
.topbar,
.filter-panel,
.executive-summary,
.kpi-grid,
.equipment-grid,
.chart-grid,
.table-card,
.chart-card,
.form-grid {
  max-width: 100%;
  min-width: 0;
}

.main {
  overflow-x: hidden;
}

.chart-card canvas {
  width: 100% !important;
  max-width: 100% !important;
}

.equipment-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.chart-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.filter-panel {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 1180px) {
  .app-body {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .main {
    padding: 14px;
  }

  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
  .app-body {
    display: block;
  }

  .main {
    width: 100%;
    padding: 12px;
  }

  .topbar {
    position: relative;
    border-radius: 16px;
  }

  .title-block {
    width: 100%;
  }

  .filter-panel,
  .chart-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .equipment-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .kpi-card b {
    font-size: 28px;
  }

  table {
    min-width: 760px;
  }
}

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

  .summary-text h2 {
    font-size: 20px;
  }

  .summary-badge span {
    font-size: 34px;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

/* ===== Popup final theme + scroll fix ===== */
.modal:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
  padding: 18px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 9999 !important;
  background: rgba(0, 0, 0, 0.68) !important;
}

.modal-card {
  width: min(980px, 96vw) !important;
  max-height: calc(100vh - 48px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  margin: 12px auto 40px auto !important;
  border-radius: 22px !important;
  background: linear-gradient(180deg, #ffffff 0%, #eef7ff 100%) !important;
  color: #102030 !important;
  border: 1px solid #b9d9ef !important;
  box-shadow: 0 24px 70px rgba(0, 70, 120, 0.28) !important;
}

.modal-card.media {
  max-height: calc(100vh - 48px) !important;
  overflow-y: auto !important;
}

.modal-card h3 {
  color: #064b76 !important;
  border-bottom: 2px solid #8fc9ee;
  padding-bottom: 12px;
  margin: 0 0 16px 0;
}

.close-modal {
  color: #064b76 !important;
  z-index: 2;
}

.insight-body,
.media-gallery {
  max-width: 100%;
  overflow-x: hidden;
  color: #102030;
}

.insight-body p,
.insight-body .muted {
  color: #41576b;
}

.insight-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.insight-kpis div {
  background: #ffffff !important;
  border: 1px solid #c4def0 !important;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(0, 90, 140, 0.1);
}

.insight-kpis b {
  display: block;
  font-size: 30px;
  color: #006aa6 !important;
}

.insight-kpis span {
  color: #526a7d !important;
}

.insight-body .table-scroll,
.modal-card .table-scroll {
  max-height: 55vh !important;
  overflow: auto !important;
  border-radius: 14px;
  border: 1px solid #c4def0;
}

.insight-body table,
.modal-card table {
  width: 100%;
  min-width: 680px;
  background: #ffffff;
  color: #102030;
}

.insight-body th,
.modal-card th {
  background: #d9efff !important;
  color: #064b76 !important;
  position: sticky;
  top: 0;
  z-index: 1;
}

.insight-body td,
.modal-card td {
  color: #102030 !important;
  border-color: #d7e8f4 !important;
}

.insight-body .camera-btn,
.modal-card .camera-btn {
  background: #0077b6 !important;
  color: #ffffff !important;
}

.media-gallery img {
  border: 1px solid #c4def0;
}

.media-gallery video {
  width: 100%;
  height: 190px;
  border-radius: 14px;
  background: #000;
}

.file-link {
  color: #064b76 !important;
  background: #ffffff !important;
  border-color: #c4def0 !important;
}

@media (max-width: 860px) {
  .modal:not(.hidden) {
    padding: 10px !important;
  }

  .modal-card {
    width: 96vw !important;
    max-height: calc(100vh - 28px) !important;
    margin: 8px auto 30px auto !important;
    border-radius: 18px !important;
  }

  .insight-body .table-scroll,
  .modal-card .table-scroll {
    max-height: 60vh !important;
  }

  .insight-body table,
  .modal-card table {
    min-width: 620px;
  }
}
/* ===== News board: multi-image gallery ===== */
.news-feed {
  gap: 22px;
}

.news-card.news-card-gallery {
  display: grid;
  grid-template-columns: minmax(420px, 1.25fr) minmax(320px, 0.75fr);
  gap: 22px;
  padding: 22px;
  align-items: stretch;
  border-left: 8px solid var(--cyan);
}

.news-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 170px;
  gap: 10px;
  min-height: 350px;
}

.news-gallery.single {
  grid-template-columns: 1fr;
  grid-auto-rows: 360px;
}

.news-gallery.empty {
  display: grid;
  place-items: center;
  background: #d6e1ec;
  border-radius: 18px;
  color: #436078;
  font-weight: 800;
}

.news-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  background: #d6e1ec;
  box-shadow: 0 8px 18px rgba(0,0,0,.12);
}

.news-gallery img.main-news-img {
  grid-row: span 2;
}

.news-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.news-content h3 {
  font-size: clamp(22px, 2vw, 34px);
  line-height: 1.25;
  margin: 12px 0;
}

.news-content p {
  font-size: 16px;
  line-height: 1.85;
  color: #20364f;
}

@media (max-width: 1100px) {
  .news-card.news-card-gallery {
    grid-template-columns: 1fr;
  }

  .news-gallery {
    min-height: 280px;
  }
}

@media (max-width: 620px) {
  .news-gallery {
    grid-template-columns: 1fr;
    grid-auto-rows: 220px;
  }

  .news-gallery img.main-news-img {
    grid-row: span 1;
  }

  .news-content h3 {
    font-size: 22px;
  }
}
/* ===== News board: fixed 50/50 layout, max 5 images ===== */
.news-feed {
  display: grid;
  gap: 26px;
}

.news-card.news-card-gallery {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  gap: 26px !important;
  align-items: start !important;
  width: 100%;
  padding: 24px !important;
  overflow: hidden !important;
}

.news-media-side {
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.news-gallery {
  width: 100%;
  min-height: 360px;
  display: grid;
  gap: 12px;
  overflow: hidden;
}

/* 1 รูป */
.news-gallery.news-count-1 {
  grid-template-columns: 1fr;
}
.news-gallery.news-count-1 img {
  height: 420px;
}

/* 2 รูป */
.news-gallery.news-count-2 {
  grid-template-columns: 1fr 1fr;
}
.news-gallery.news-count-2 img {
  height: 360px;
}

/* 3 รูป */
.news-gallery.news-count-3 {
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-rows: 180px 180px;
}
.news-gallery.news-count-3 img:first-child {
  grid-row: span 2;
}

/* 4 รูป */
.news-gallery.news-count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 180px 180px;
}

/* 5 รูป */
.news-gallery.news-count-5 {
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  grid-template-rows: 180px 180px;
}
.news-gallery.news-count-5 img:first-child {
  grid-row: span 2;
}

.news-gallery img {
  width: 100%;
  height: 100%;
  min-width: 0;
  object-fit: cover;
  border-radius: 16px;
  background: #d6e1ec;
  box-shadow: 0 8px 18px rgba(0,0,0,.12);
  display: block;
}

.news-gallery.empty {
  display: grid;
  place-items: center;
  min-height: 360px;
  background: #d6e1ec;
  border-radius: 18px;
  color: #436078;
  font-weight: 800;
}

.news-content {
  min-width: 0;
  width: 100%;
  display: block !important;
  align-self: start;
}

.news-content h3 {
  font-size: clamp(24px, 2vw, 36px);
  line-height: 1.28;
  margin: 12px 0;
  color: #11233a;
}

.news-content p {
  font-size: 17px;
  line-height: 1.9;
  color: #20364f;
  white-space: pre-line;
}

.news-content small {
  display: block;
  margin-top: 18px;
  color: #436078;
}

@media (max-width: 1100px) {
  .news-card.news-card-gallery {
    grid-template-columns: 1fr !important;
  }

  .news-gallery {
    min-height: 320px;
  }
}

@media (max-width: 620px) {
  .news-gallery,
  .news-gallery.news-count-1,
  .news-gallery.news-count-2,
  .news-gallery.news-count-3,
  .news-gallery.news-count-4,
  .news-gallery.news-count-5 {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .news-gallery img,
  .news-gallery.news-count-1 img,
  .news-gallery.news-count-2 img,
  .news-gallery.news-count-3 img:first-child,
  .news-gallery.news-count-5 img:first-child {
    grid-row: auto;
    height: 230px;
  }
}
/* ===== Sidebar logo enlarge ===== */
.sidebar .brand-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.sidebar .brand-logo,
.sidebar #appLogo {
  width: 72px !important;
  height: 72px !important;
  max-width: 72px !important;
  max-height: 72px !important;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 4px;
}

.sidebar .brand-row h1,
.sidebar .brand-row .brand-title {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
  font-weight: 900;
}

.sidebar .brand-row p,
.sidebar .brand-row .brand-subtitle {
  font-size: 14px;
  line-height: 1.25;
  margin: 4px 0 0;
  color: #b8d7ee;
}
/* ===== Sidebar logo enlarge - real class fix ===== */
.sidebar-brand {
  display: grid !important;
  grid-template-columns: 92px 1fr !important;
  gap: 14px !important;
  align-items: center !important;
  margin-bottom: 32px !important;
}

.sidebar-brand .side-logo,
.sidebar-brand img.side-logo,
#appLogo.side-logo {
  width: 92px !important;
  height: 92px !important;
  max-width: 92px !important;
  max-height: 92px !important;
  min-width: 92px !important;
  min-height: 92px !important;
  object-fit: contain !important;
  border-radius: 50% !important;
  background: #fff !important;
  padding: 5px !important;
}

.sidebar-brand > div {
  min-width: 0;
}

.sidebar-brand h1 {
  margin: 0 !important;
  font-size: 17px !important;
  line-height: 1.25 !important;
  font-weight: 900 !important;
  white-space: normal !important;
}

.sidebar-brand small {
  display: block !important;
  margin-top: 4px !important;
  font-size: 14px !important;
  line-height: 1.25 !important;
  color: #b8d7ee !important;
}
/* ===== Force enlarge sidebar logo ===== */
.sidebar-brand {
  display: grid !important;
  grid-template-columns: 120px 1fr !important;
  gap: 14px !important;
  align-items: center !important;
  margin-bottom: 34px !important;
}

.sidebar-brand img,
.sidebar-brand #appLogo,
.sidebar img#appLogo,
img#appLogo {
  width: 120px !important;
  height: 120px !important;
  max-width: 120px !important;
  max-height: 120px !important;
  min-width: 120px !important;
  min-height: 120px !important;
  object-fit: contain !important;
  border-radius: 50% !important;
  background: #fff !important;
  padding: 6px !important;
  display: block !important;
}

.sidebar-brand h1 {
  font-size: 16px !important;
  line-height: 1.25 !important;
  margin: 0 !important;
  white-space: normal !important;
}

.sidebar-brand small {
  font-size: 14px !important;
  line-height: 1.25 !important;
  margin-top: 5px !important;
  display: block !important;
}
/* ===== Sidebar maker logo ===== */
.sidebar-maker-logo {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 3px solid #d30000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-maker-logo img {
  width: 100%;
  max-width: 210px;
  max-height: 120px;
  object-fit: contain;
  display: block;
}
/* ===== Dashboard chart layout: 2 top / 2 bottom ===== */
.chart-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 18px !important;
  align-items: stretch !important;
}

.chart-card {
  min-width: 0 !important;
  width: 100% !important;
}

/* ให้ Pareto และ Severity สูงพอดีในแถวล่าง */
.chart-card .pareto-box,
.chart-card .donut-wrap {
  min-height: 300px;
}

/* มือถือให้เรียง 1 คอลัมน์ */
@media (max-width: 860px) {
  .chart-grid {
    grid-template-columns: 1fr !important;
  }
}
/* ===== Executive Summary Zero Accident ===== */
.executive-summary-new {
  display: grid !important;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr) !important;
  gap: 18px !important;
  align-items: stretch !important;
  padding: 24px !important;
  background:
    linear-gradient(135deg, rgba(34,199,232,.12), rgba(76,134,255,.08)),
    linear-gradient(135deg, #102947, #0d1e34) !important;
}

.zero-slogan {
  margin: 4px 0 14px !important;
  font-size: clamp(26px, 3vw, 44px) !important;
  line-height: 1.15 !important;
  color: #ffffff !important;
  font-weight: 950 !important;
}

.zero-slogan span {
  display: inline-block;
  color: var(--gold);
  white-space: nowrap;
}

.summary-text #summaryHeadline {
  font-size: 18px;
  font-weight: 800;
  color: #d9ecff;
  margin: 0 0 8px;
}

.summary-text #summaryDesc {
  color: #b8d7ee;
  line-height: 1.7;
}

.summary-stat-panel {
  display: grid;
  gap: 12px;
}

.summary-stat-main,
.summary-stat-change {
  border-radius: 22px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(6,16,30,.42);
}

.summary-stat-main span {
  display: block;
  font-size: clamp(44px, 5vw, 72px);
  line-height: 1;
  font-weight: 950;
  color: var(--gold);
}

.summary-stat-main small,
.summary-stat-change small {
  display: block;
  margin-top: 8px;
  color: #d8e8f7;
  font-weight: 800;
}

.summary-stat-change b {
  display: block;
  font-size: 24px;
  color: var(--cyan);
}

.summary-stat-change.up b {
  color: #ff8a00;
}

.summary-stat-change.down b {
  color: #1fd180;
}

.summary-stat-change.same b {
  color: #d8e8f7;
}

@media (max-width: 860px) {
  .executive-summary-new {
    grid-template-columns: 1fr !important;
  }

  .summary-stat-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .summary-stat-panel {
    grid-template-columns: 1fr;
  }
}
/* ===== Accident form section layout ===== */
.form-section-title {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-left: 5px solid var(--cyan);
  border-radius: 12px;
  background: rgba(34, 199, 232, 0.12);
  color: #bff4ff;
  font-weight: 900;
  letter-spacing: .02em;
}

#accidentForm {
  align-items: start;
}

#accidentForm .full {
  grid-column: 1 / -1;
}

#accidentForm textarea {
  min-height: 110px;
  resize: vertical;
}

#useCurrentLocationBtn {
  background: rgba(31, 209, 128, 0.16);
  border-color: rgba(31, 209, 128, 0.35);
  color: #caffdf;
}

#openMapBtn {
  background: rgba(255, 196, 0, 0.14);
  border-color: rgba(255, 196, 0, 0.35);
  color: #ffe9a6;
}

@media (max-width: 1180px) {
  #accidentForm {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 720px) {
  #accidentForm {
    grid-template-columns: 1fr;
  }
}
/* ===== Saved accident table pager ===== */
.saved-table-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px;
  background: rgba(8, 23, 42, 0.75);
  border: 1px solid var(--line);
  border-radius: 14px;
  flex-wrap: wrap;
}

.pager-info {
  color: #c8d6e4;
  font-weight: 800;
}

.pager-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.pager-btn {
  border: 1px solid rgba(34,199,232,.28);
  background: rgba(34,199,232,.10);
  color: #dff8ff;
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 800;
}

.pager-btn.active {
  background: linear-gradient(135deg, var(--cyan), #4c86ff);
  color: #06101e;
}

.pager-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #c8d6e4;
  font-weight: 800;
  margin-left: 8px;
}

.pager-jump input {
  width: 70px;
  background: #08172a;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 7px 8px;
  text-align: center;
}

.danger-btn {
  background: rgba(255,56,100,.15) !important;
  border-color: rgba(255,56,100,.4) !important;
  color: #ffd6df !important;
}

@media (max-width: 720px) {
  .saved-table-pager {
    align-items: stretch;
  }

  .pager-actions {
    justify-content: flex-start;
  }
}
/* ===== Severity donut legend color markers ===== */
.severity-chart-box {
  display: grid;
  place-items: center;
  gap: 16px;
}

.severity-legend {
  width: min(360px, 100%);
  display: grid;
  gap: 8px;
}

.severity-legend-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: #d8e4ef;
  font-weight: 800;
}

.severity-legend-row i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(255,255,255,.75);
  box-shadow: 0 0 0 3px rgba(255,255,255,.08);
}

.severity-legend-row b {
  min-width: 0;
  line-height: 1.25;
}

.severity-legend-row span {
  color: #ffffff;
  font-weight: 900;
}
/* ===== Sidebar maker logo credit ===== */
.sidebar-maker-logo{
  margin: 28px 20px 0;
  padding-top: 28px;
  border-top: 3px solid #ff1838;
  text-align: center;
}

.sidebar-maker-logo img{
  display: block;
  max-width: 230px;
  width: 100%;
  margin: 0 auto 20px;
}

.maker-credit,
.maker-rights{
  color: #ffffff;
  text-align: center;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: .3px;
  text-shadow: 0 2px 6px rgba(0,0,0,.55);
}

.maker-credit{
  font-size: 17px;
  margin-top: 4px;
  margin-bottom: 28px;
}

.maker-rights{
  font-size: 17px;
}

@media (max-height: 760px){
  .sidebar-maker-logo{
    margin-top: 22px;
    padding-top: 22px;
  }

  .sidebar-maker-logo img{
    max-width: 205px;
    margin-bottom: 16px;
  }

  .maker-credit,
  .maker-rights{
    font-size: 15px;
  }

  .maker-credit{
    margin-bottom: 22px;
  }
}
/* ===== Fix maker logo text under logo ===== */
.sidebar-maker-logo{
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0 !important;

  width: auto !important;
  margin: 28px 20px 0 !important;
  padding-top: 28px !important;
  border-top: 3px solid #ff1838 !important;
  text-align: center !important;
}

.sidebar-maker-logo img{
  display: block !important;
  width: 100% !important;
  max-width: 230px !important;
  height: auto !important;
  margin: 0 auto 18px !important;
  flex: 0 0 auto !important;
}

.sidebar-maker-logo .maker-credit,
.sidebar-maker-logo .maker-rights{
  display: block !important;
  width: 100% !important;
  max-width: 240px !important;
  color: #ffffff !important;
  text-align: center !important;
  font-weight: 900 !important;
  line-height: 1.25 !important;
  letter-spacing: .3px !important;
  white-space: normal !important;
  flex: 0 0 auto !important;
  text-shadow: 0 2px 6px rgba(0,0,0,.55) !important;
}

.sidebar-maker-logo .maker-credit{
  font-size: 16px !important;
  margin: 0 0 24px !important;
}

.sidebar-maker-logo .maker-rights{
  font-size: 16px !important;
  margin: 0 !important;
}
/* ===== KPI latest accident card ===== */
.kpi-grid{
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.latest-accident-card b{
  font-size: 32px;
  color: #38d7ff;
  line-height: 1.2;
}

.latest-accident-card small{
  color: #b9d7ff;
}

@media (max-width: 1400px){
  .kpi-grid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px){
  .kpi-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px){
  .kpi-grid{
    grid-template-columns: 1fr;
  }
}
/* ===== KPI grid back to 4 cards ===== */
.kpi-grid{
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.latest-accident-card b{
  font-size: 32px;
  color: #38d7ff;
  line-height: 1.2;
}

@media (max-width: 1200px){
  .kpi-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px){
  .kpi-grid{
    grid-template-columns: 1fr !important;
  }
}
/* ===== Accident media popup larger image ===== */
.media-gallery{
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)) !important;
  gap: 22px !important;
  align-items: start !important;
}

.accident-popup-img{
  width: 100% !important;
  max-width: 720px !important;
  height: 420px !important;
  object-fit: contain !important;
  background: #071523 !important;
  border-radius: 18px !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  padding: 8px !important;
  cursor: zoom-in !important;
  transition: transform .18s ease, box-shadow .18s ease !important;
}

.accident-popup-img:hover{
  transform: scale(1.02) !important;
  box-shadow: 0 18px 45px rgba(0,0,0,.45) !important;
}

.accident-popup-video{
  width: 100% !important;
  max-width: 720px !important;
  height: 420px !important;
  background: #071523 !important;
  border-radius: 18px !important;
}

.image-fullscreen-overlay{
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  background: rgba(0,0,0,.88) !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 28px !important;
}

.image-fullscreen-overlay.show{
  display: flex !important;
}

.image-fullscreen-overlay img{
  max-width: 96vw !important;
  max-height: 92vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  border-radius: 18px !important;
  box-shadow: 0 25px 80px rgba(0,0,0,.65) !important;
  background: #071523 !important;
}

.image-fullscreen-close{
  position: fixed !important;
  top: 18px !important;
  right: 24px !important;
  width: 46px !important;
  height: 46px !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #ff3864 !important;
  color: #fff !important;
  font-size: 34px !important;
  line-height: 42px !important;
  cursor: pointer !important;
  font-weight: 900 !important;
}

@media (max-width: 760px){
  .media-gallery{
    grid-template-columns: 1fr !important;
  }

  .accident-popup-img,
  .accident-popup-video{
    max-width: 100% !important;
    height: 320px !important;
  }
}
/* ===== Equipment insight side-by-side popup ===== */
#insightModal .modal-card.media{
  width: min(96vw, 1500px) !important;
  max-width: 1500px !important;
  max-height: 92vh !important;
  overflow: auto !important;
}

.equipment-insight-layout{
  display: grid !important;
  grid-template-columns: minmax(520px, 1.1fr) minmax(480px, .9fr) !important;
  gap: 22px !important;
  align-items: start !important;
}

.equipment-insight-left,
.equipment-insight-right{
  min-width: 0 !important;
}

.equipment-insight-right{
  background: rgba(7,21,35,.55) !important;
  border: 1px solid rgba(255,255,255,.16) !important;
  border-radius: 18px !important;
  padding: 14px !important;
  position: sticky !important;
  top: 0 !important;
}

.equipment-insight-right h4{
  margin: 0 0 12px !important;
  color: #ffffff !important;
  font-size: 18px !important;
}

.equipment-media-preview{
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 14px !important;
  max-height: 72vh !important;
  overflow: auto !important;
  padding-right: 4px !important;
}

.equipment-media-img,
.equipment-media-video{
  width: 100% !important;
  max-height: 520px !important;
  object-fit: contain !important;
  background: #071523 !important;
  border-radius: 16px !important;
  border: 1px solid rgba(255,255,255,.18) !important;
  padding: 8px !important;
}

.equipment-media-img{
  cursor: zoom-in !important;
}

.equipment-media-img:hover{
  transform: scale(1.01) !important;
}

@media (max-width: 1050px){
  .equipment-insight-layout{
    grid-template-columns: 1fr !important;
  }

  .equipment-insight-right{
    position: static !important;
  }
}
/* ===== Existing accident attachments in edit form ===== */
.existing-attachment-box{
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(34,199,232,.35);
  border-radius: 16px;
  background: rgba(7,21,35,.35);
}

.existing-attachment-box.hidden{
  display: none !important;
}

.existing-attachment-head{
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.existing-attachment-head b{
  color: #ffffff;
  font-size: 16px;
}

.existing-attachment-head small{
  color: #b9d7ff;
}

.existing-attachment-list{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.existing-attachment-item{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  padding: 10px;
}

.existing-attachment-item img{
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  background: #071523;
  cursor: zoom-in;
}

.existing-attachment-item video{
  width: 100%;
  height: 120px;
  border-radius: 10px;
  background: #071523;
}

.existing-attachment-item .file-link{
  display: block;
  color: #38d7ff;
  font-weight: 800;
  word-break: break-word;
  padding: 14px 4px;
}

.delete-attachment-btn{
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #dc2626;
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

.delete-attachment-btn:hover{
  filter: brightness(1.08);
}
/* ===== Desktop fixed sidebar final ===== */
@media (min-width: 901px){
  body.app-body{
    display: block !important;
  }

  .sidebar{
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 290px !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 1000 !important;
  }

  .main{
    margin-left: 290px !important;
    width: calc(100% - 290px) !important;
    min-height: 100vh !important;
    box-sizing: border-box !important;
  }
}