:root {
  --navy: #051327;
  --navy2: #0a2548;
  --navy3: #0e3566;
  --blue: #0a79c9;
  --cyan: #39c9ff;
  --cyan-soft: #96e3ff;
  --gold: #f3c85d;
  --gold-d: #b88a2e;
  --red: #a5142d;
  --red2: #d62541;
  --green: #2fb66d;
  --text: #eef7ff;
  --muted: #9eb7d2;
  --line: #1e4b73;
  --card-bg: linear-gradient(155deg, rgba(12, 43, 79, 0.92), rgba(6, 21, 43, 0.96));
  --shadow: 0 10px 30px rgba(0, 8, 22, 0.45);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Sarabun", "Kanit", "Prompt", "Leelawadee UI", Tahoma, sans-serif;
  background: radial-gradient(ellipse at 78% 22%, #0e3d6b 0%, #06162e 48%, #030b18 100%);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.55;
  min-height: 100vh;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ===== Masthead ===== */
.masthead-wrap {
  position: relative;
  background: #041022;
  border-bottom: 2px solid #2ab8ff;
  box-shadow: 0 4px 24px rgba(0, 170, 255, 0.28);
  overflow: hidden;
}

.masthead {
  display: block;
  width: 100%;
  height: auto;
  max-height: 195px;
  object-fit: cover;
  object-position: center;
}

.masthead-badge {
  position: absolute;
  top: 10px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(5, 19, 39, 0.82);
  border: 1px solid rgba(57, 201, 255, 0.45);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--cyan-soft);
  backdrop-filter: blur(6px);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  display: inline-block;
}

.dot-live.cloud {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

/* ===== Top Navbar ===== */
nav#top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 58px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #06152c 0%, #0b2d56 50%, #06152c 100%);
  border-bottom: 1px solid #216f9e;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.top-nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.top-nav-links::-webkit-scrollbar {
  display: none;
}

.top-nav-links button {
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  color: #e2f1ff;
  font: inherit;
  font-weight: 500;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: 0.18s ease;
}

.top-nav-links button:hover {
  background: rgba(20, 74, 128, 0.55);
  border-color: rgba(57, 201, 255, 0.45);
}

.top-nav-links button.active {
  background: linear-gradient(110deg, #981129, #c41f3b);
  border: 1px solid #f0c257;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(214, 37, 65, 0.45);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid #6ec8f5;
  width: 175px;
}

.search-box input {
  border: 0;
  background: transparent;
  color: #0e2038;
  padding: 4px 6px;
  width: 100%;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.search-box span {
  color: #35547a;
  font-size: 14px;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, #b88a2e, #f3c85d);
  color: #161103;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(243, 200, 93, 0.35);
}

.admin-pill:hover {
  text-decoration: none;
  filter: brightness(1.06);
}

/* ===== Main Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: calc(100vh - 255px);
}

aside#side {
  padding: 16px 12px 24px;
  background: linear-gradient(180deg, #071b36 0%, #051123 100%);
  border-right: 1px solid #1b567e;
  box-shadow: 8px 0 28px rgba(0, 10, 24, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-title {
  font-size: 19px;
  font-weight: 700;
  padding: 6px 12px 14px;
  color: #f6d77d;
  border-bottom: 1px solid #194569;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#side button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(11, 41, 75, 0.65), rgba(8, 27, 51, 0.45));
  border: 1px solid transparent;
  border-bottom: 1px solid #183d5e;
  color: #dcecff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.16s ease;
}

#side button:hover {
  background: linear-gradient(90deg, #114072, #0b294d);
  border-color: #2986bf;
  color: #fff;
}

#side button.active {
  background: linear-gradient(90deg, #9d102b 0%, #50142f 100%);
  border-left: 4px solid #ffd15b;
  border-color: rgba(255, 209, 91, 0.45);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(165, 20, 45, 0.35);
}

#side button .ic {
  width: 22px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.side-footer-card {
  margin-top: auto;
  padding: 12px;
  border-radius: 10px;
  background: rgba(10, 42, 77, 0.65);
  border: 1px solid #215a86;
  font-size: 12.5px;
  color: var(--muted);
}

.side-footer-card strong {
  display: block;
  color: var(--gold);
  margin-bottom: 4px;
}

main.portal-main {
  padding: 20px 24px 36px;
  min-width: 0;
}

/* ===== Hero Banner (Matching Mockup) ===== */
#hero {
  position: relative;
  overflow: hidden;
  padding: 28px 32px;
  border: 1px solid #24a4e2;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 82% 24%, rgba(14, 146, 219, 0.42), transparent 44%),
    radial-gradient(ellipse at 12% 95%, rgba(9, 76, 146, 0.6), transparent 50%),
    linear-gradient(115deg, #061832 0%, #0b2f58 55%, #071e3b 100%);
  box-shadow: 0 0 32px rgba(0, 140, 255, 0.24), inset 0 0 28px rgba(57, 201, 255, 0.14);
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 20px;
  align-items: center;
}

#hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 42px, rgba(139, 223, 255, 0.03) 43px 45px);
}

.hero-left {
  position: relative;
  z-index: 2;
}

.hero-eyebrow {
  color: #69d8ff;
  letter-spacing: 2px;
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
}

#hero h1 {
  font-size: clamp(26px, 3.2vw, 42px);
  line-height: 1.18;
  margin: 8px 0 6px;
  color: #fff;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.7);
}

.hero-sub {
  color: #cbe9ff;
  font-size: clamp(16px, 1.7vw, 21px);
  margin: 0 0 14px;
}

.hero-ribbon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #d4a338 0%, #f7d97e 55%, #d6a437 100%);
  color: #1c1404;
  font-weight: 800;
  font-size: 18px;
  padding: 8px 22px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(243, 200, 93, 0.3);
  margin-bottom: 16px;
}

.hero-ribbon .free-tag {
  background: #b5122b;
  color: #fff;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 16px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-right {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-visual {
  background: rgba(5, 22, 46, 0.7);
  border: 1px solid rgba(57, 201, 255, 0.4);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 0 26px rgba(0, 174, 255, 0.2);
}

.hero-crest {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 18px rgba(243, 200, 93, 0.35);
  margin-bottom: 10px;
}

.hero-visual b {
  display: block;
  font-size: 16px;
  color: #fff;
}

.hero-visual small {
  color: var(--cyan-soft);
  display: block;
  font-size: 12.5px;
}

/* ===== 7 Quick-Access Tiles ===== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 18px;
}

.tile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 116px;
  padding: 14px 10px;
  border-radius: 12px;
  background: linear-gradient(160deg, #104274 0%, #07203d 100%);
  border: 1px solid #25a3e3;
  color: #eef7ff;
  cursor: pointer;
  text-align: center;
  font: inherit;
  box-shadow: inset 0 0 18px rgba(17, 148, 219, 0.2), 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.tile-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(57, 201, 255, 0.38);
}

.tile-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(57, 201, 255, 0.45));
}

.tile-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
}

.tile-count {
  font-size: 11.5px;
  color: var(--cyan-soft);
  background: rgba(5, 19, 39, 0.55);
  padding: 1px 8px;
  border-radius: 999px;
}

/* ===== Dashboard Bottom 2 Columns ===== */
.dash-bottom {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.panel {
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid #24618d;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(57, 201, 255, 0.22);
}

.panel-head h2, .panel h2 {
  margin: 0;
  font-size: 18px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head small {
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi-box {
  background: linear-gradient(155deg, rgba(13, 52, 92, 0.8), rgba(6, 22, 44, 0.9));
  border: 1px solid #247bb0;
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}

.kpi-box .kpi-ic {
  font-size: 22px;
  margin-bottom: 4px;
}

.kpi-box span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

.kpi-box strong {
  display: block;
  font-size: 21px;
  color: var(--gold);
  line-height: 1.25;
  margin-top: 2px;
}

.storage-bar {
  margin-top: 8px;
  height: 8px;
  background: #0a2038;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #255780;
}

.storage-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f3c85d, #39c9ff);
  border-radius: 999px;
}

/* News Feed List */
.news-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-feed li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(39, 98, 138, 0.45);
  cursor: pointer;
}

.news-feed li:last-child {
  border-bottom: 0;
}

.news-feed li:hover {
  background: rgba(57, 201, 255, 0.08);
  border-radius: 6px;
}

.news-feed .n-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  color: #e9f5ff;
}

.news-feed .n-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
}

.news-feed .n-date {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* Charts & Analytics (from original index.html) */
.grid2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 42px;
  gap: 10px;
  align-items: center;
  margin: 9px 0;
  font-size: 14px;
}

.bar-track {
  background: #081c34;
  border: 1px solid #1e4b73;
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1b88d8, #39c9ff);
  border-radius: 6px;
  min-width: 4px;
}

/* ===== Buttons, Inputs, Toolbar, Tables ===== */
.btn, .primary-btn, .outline-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 15px;
  font-size: 14.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.16s ease;
  text-decoration: none;
}

.btn, .primary-btn {
  background: linear-gradient(120deg, #9f142d, #d32541);
  color: #fff;
  border: 1px solid #f0c257;
  box-shadow: 0 3px 12px rgba(165, 20, 45, 0.35);
}

.btn:hover, .primary-btn:hover {
  filter: brightness(1.1);
  text-decoration: none;
}

.btn.blue {
  background: linear-gradient(135deg, #0d4b86, #0a79c9);
  border-color: #4ec8ff;
  box-shadow: 0 3px 12px rgba(10, 121, 201, 0.35);
}

.btn.gold {
  background: linear-gradient(135deg, #c69633, #f3c85d);
  color: #1b1403;
  border-color: #ffe294;
}

.btn.ghost, .outline-btn {
  background: rgba(8, 28, 54, 0.75);
  color: #dbeeff;
  border: 1px solid #3576a8;
}

.btn.ghost:hover, .outline-btn:hover {
  border-color: var(--cyan);
  background: rgba(15, 55, 99, 0.9);
}

.btn.del {
  background: rgba(120, 17, 34, 0.35);
  color: #ffb8c2;
  border: 1px solid #a8384a;
}

.btn.sm {
  padding: 4px 10px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  align-items: center;
}

input, select, textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid #2b6491;
  border-radius: 8px;
  background: #06182f;
  color: #eef7ff;
  width: 100%;
}

input::placeholder, textarea::placeholder {
  color: #7c9bbd;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--cyan);
  border-color: var(--cyan);
}

.toolbar input[type="search"], .toolbar input[type="text"] {
  flex: 1;
  min-width: 210px;
  width: auto;
}

.toolbar select {
  width: auto;
}

.table-wrap, .scroll {
  overflow-x: auto;
  border: 1px solid #20527b;
  border-radius: 10px;
  background: rgba(5, 19, 39, 0.7);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(35, 86, 126, 0.55);
  vertical-align: top;
  font-size: 14.5px;
}

th {
  background: #0b2d54;
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

tr:hover td {
  background: rgba(57, 201, 255, 0.05);
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tag.s0, .tag.investigating { background: rgba(243, 200, 93, 0.18); color: #ffd978; border: 1px solid rgba(243, 200, 93, 0.4); }
.tag.s1 { background: rgba(57, 201, 255, 0.16); color: #82deff; border: 1px solid rgba(57, 201, 255, 0.35); }
.tag.s2, .tag.arrested, .tag.published { background: rgba(47, 182, 109, 0.18); color: #7aeaa9; border: 1px solid rgba(47, 182, 109, 0.4); }
.tag.s3, .tag.other, .tag.draft { background: rgba(158, 183, 210, 0.16); color: #c4d7ec; border: 1px solid rgba(158, 183, 210, 0.35); }
.tag.s4, .tag.denied { background: rgba(214, 37, 65, 0.22); color: #ff9eab; border: 1px solid rgba(214, 37, 65, 0.5); }

.provenance-box {
  background: rgba(6, 28, 56, 0.78);
  border: 1px dashed #2e84b8;
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  color: #bce4ff;
  margin: 10px 0;
}

.dup-alert {
  background: rgba(165, 20, 45, 0.22);
  border: 1px solid #f06e82;
  border-radius: 10px;
  padding: 12px 14px;
  color: #ffdbe0;
  margin: 10px 0;
}

/* Chatbot Assistant */
.chat-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.chat-sidebar {
  background: rgba(5, 21, 44, 0.85);
  border: 1px solid #215b86;
  border-radius: 12px;
  padding: 14px;
}

.chat-chips {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}

.chat-chip {
  text-align: left;
  background: rgba(13, 52, 92, 0.72);
  border: 1px solid #2977ab;
  color: #e2f2ff;
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
}

.chat-chip:hover {
  border-color: var(--gold);
  background: rgba(18, 69, 120, 0.9);
}

.chat-box {
  display: flex;
  flex-direction: column;
  height: 490px;
  background: rgba(4, 16, 34, 0.85);
  border: 1px solid #236898;
  border-radius: 12px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.5;
}

.chat-msg.bot {
  align-self: flex-start;
  background: linear-gradient(155deg, #0d3661, #072242);
  border: 1px solid #287eb5;
  color: #eef7ff;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(120deg, #981129, #c41f3b);
  border: 1px solid #f0c257;
  color: #fff;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #1e4b73;
  background: #061830;
}

.role-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(9, 36, 70, 0.88);
  border: 1px solid #257bb0;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 13.5px;
}

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

.notice {
  color: #f8dfa0;
  background: rgba(65, 48, 18, 0.42);
  border: 1px solid #967231;
  border-radius: 10px;
  padding: 11px 15px;
  font-size: 14px;
  margin-bottom: 15px;
}

.notice b {
  color: var(--gold);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

/* Cards Grid for Media / Docs / Gallery */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.media-card {
  background: rgba(8, 30, 58, 0.85);
  border: 1px solid #246290;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-thumb {
  width: 100%;
  height: 155px;
  object-fit: cover;
  background: #041022;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  font-size: 40px;
}

.media-body {
  padding: 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-body h3 {
  margin: 0;
  font-size: 15.5px;
  color: #fff;
}

.media-body p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

.media-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Dialog */
dialog {
  border: 1px solid #2b89c4;
  border-radius: 14px;
  padding: 0;
  width: min(680px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: #071b36;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.72);
}

dialog::backdrop {
  background: rgba(2, 8, 18, 0.72);
  backdrop-filter: blur(3px);
}

dialog form, .modal-box {
  padding: 22px;
}

dialog h2 {
  margin: 0 0 14px;
  color: var(--gold);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-2 .full {
  grid-column: 1 / -1;
}

.form-grid-2 label {
  display: block;
  font-size: 13.5px;
  color: var(--cyan-soft);
}

.form-grid-2 label input,
.form-grid-2 label select,
.form-grid-2 label textarea {
  margin-top: 4px;
}

.modal-act {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

footer {
  text-align: center;
  padding: 18px 16px;
  color: #93afc9;
  border-top: 1px solid #1b4b72;
  background: #030e1e;
  font-size: 13.5px;
}

/* ===== Admin Portal (admin.html) ===== */
.admin-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 24px;
  background: linear-gradient(90deg, #051429, #0b2f58, #051429);
  border-bottom: 2px solid #259be0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-top .back {
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid #3576a8;
  background: rgba(8, 30, 58, 0.8);
  color: #e4f3ff;
  font-weight: 600;
}

.admin-top .back:hover {
  text-decoration: none;
  border-color: var(--gold);
}

.admin-top b {
  display: block;
  color: var(--gold);
  font-size: 17px;
  letter-spacing: 0.6px;
}

.admin-top small {
  color: var(--muted);
  font-size: 12.5px;
}

.admin-main {
  flex: 1;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 26px 20px 44px;
}

.login-card {
  max-width: 450px;
  margin: 34px auto;
  background: var(--card-bg);
  border: 1px solid #2478ad;
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 18px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
  color: var(--cyan-soft);
}

.crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0b2e59, #061832);
  border: 2px solid var(--gold);
  color: var(--gold);
  font-weight: 800;
  border-radius: 14px;
  box-shadow: 0 0 20px rgba(243, 200, 93, 0.25);
}

.crest.large {
  width: 88px;
  height: 88px;
  font-size: 20px;
  margin: 0 auto 12px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--cyan);
  font-weight: 700;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 14px;
}

.form-message {
  font-size: 14px;
  margin: 4px 0 0;
  color: var(--gold);
}

.form-message.ok {
  color: #6df0a5;
}

.form-message.err {
  color: #ff8e9b;
}

.dash-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.dash-heading h1 {
  margin: 0;
  font-size: 26px;
}

.secure-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(47, 182, 109, 0.14);
  border: 1px solid rgba(47, 182, 109, 0.45);
  color: #7df2b0;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e4b73;
}

.admin-tabs .tab {
  font: inherit;
  cursor: pointer;
  padding: 9px 16px;
  border-radius: 9px;
  background: rgba(9, 34, 65, 0.8);
  color: #cfe6ff;
  border: 1px solid #245b86;
  font-weight: 500;
}

.admin-tabs .tab:hover {
  border-color: var(--cyan);
}

.admin-tabs .tab.active {
  background: linear-gradient(120deg, #9d102b, #d22642);
  border-color: var(--gold);
  color: #fff;
  font-weight: 700;
}

.tab-panel {
  background: var(--card-bg);
  border: 1px solid #225c89;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article {
  background: rgba(8, 32, 62, 0.85);
  border: 1px solid #2578aa;
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 16px;
}

.stats-grid small {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
}

.stats-grid strong {
  display: block;
  font-size: 32px;
  color: #fff;
  margin-top: 4px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  color: var(--gold);
}

.editor {
  background: rgba(4, 17, 36, 0.72);
  border: 1px solid #246899;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.editor h3 {
  margin: 0 0 12px;
  color: var(--cyan-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
  color: var(--cyan-soft);
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.preview-strip img {
  width: 68px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--cyan);
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .masthead-badge {
    display: none;
  }
  .quick-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  aside#side {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid #1b567e;
  }
  .side-title, .side-footer-card {
    display: none;
  }
  #side button {
    width: auto;
    white-space: nowrap;
    flex: 0 0 auto;
  }
  #hero {
    grid-template-columns: 1fr;
  }
  .dash-bottom, .grid2 {
    grid-template-columns: 1fr;
  }
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-grid, .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  nav#top {
    flex-wrap: wrap;
  }
  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
  .search-box {
    flex: 1;
  }
  main.portal-main {
    padding: 14px;
  }
  .masthead-badge {
    display: none;
  }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .masthead-wrap, nav#top, aside#side, .toolbar, .hero-actions, .admin-pill, footer, .no-print {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .panel {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
  th, td {
    color: #000 !important;
    border-color: #ccc !important;
  }
}


/* ===== Image Upload Previews, Galleries, Attachments & Video Embeds ===== */
.upload-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.upload-preview-img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #2b89c4;
  background: #041022;
}

.table-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #2b89c4;
  background: #041022;
  display: inline-block;
  vertical-align: middle;
}

.table-thumb-empty {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px dashed #245a86;
  background: rgba(8, 30, 58, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #7ea8d0;
}

.multi-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.multi-thumb-item {
  position: relative;
  width: 96px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2b89c4;
  background: #041022;
}

.multi-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-rm {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(214, 37, 65, 0.92);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}

.att-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(23, 73, 118, 0.75);
  border: 1px solid #2b89c4;
  color: #e6f2ff;
  font-size: 12.5px;
}

.att-chip button {
  background: none;
  border: none;
  color: #ff9eab;
  cursor: pointer;
  font-weight: bold;
}

.detail-hero-img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #2b89c4;
  margin: 8px 0 12px;
  background: #041022;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.detail-gallery img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #2b89c4;
  background: #041022;
}

.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #2b89c4;
  background: #041022;
  margin-top: 6px;
}

.video-embed iframe,
.video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
