:root {
  --ap: #003b75;
  --ap2: #005ea8;
  --bg: #f1f5f9;
  --gold: #d8b14a;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #2566da;
  --accent: #ef4444;
  --success: #10a33a;
  --warning: #e08300;
  --card: #fff;
  --line: #cbd5e1;
  --shadow: 0 4px 20px rgba(15, 23, 42, .06);
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }

.top {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(360px, 1.55fr) minmax(330px, 1.2fr);
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  color: #fff;
  background: linear-gradient(90deg, var(--ap), var(--ap2));
  box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
}
.header-logos { display: flex; align-items: center; justify-content: flex-start; gap: 14px; min-width: 0; }
.header-logo {
  width: 62px;
  height: 62px;
  padding: 4px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}
.leadership { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 10px; min-width: 0; }
.leader-card { min-width: 0; text-align: center; }
.leader-card img {
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 auto 5px;
  padding: 2px;
  border: 2px solid rgba(255, 255, 255, .75);
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}
.leader-card strong, .leader-card span { display: block; overflow: hidden; line-height: 1.2; text-overflow: ellipsis; }
.leader-card strong { color: #fff; font-size: 10px; white-space: nowrap; }
.leader-card span { margin-top: 2px; color: #d9e8ff; font-size: 8px; }
.title { text-align: center; }
.title h1 { margin: 0; font: 700 clamp(18px, 2vw, 24px) Merriweather, Georgia, serif; letter-spacing: .5px; }
.title h2 { margin: 4px 0 2px; color: #e2e8f0; font-size: clamp(14px, 1.4vw, 16px); font-weight: 500; }
.title p { margin: 0; color: #ffd875; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }

.info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 9px 24px;
  border-bottom: 3px solid var(--gold);
  background: #fff;
  box-shadow: var(--shadow);
}
.info-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.info strong { overflow: hidden; color: var(--ap); font-size: 15px; letter-spacing: .5px; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.user-summary { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sidebar-toggle { display: flex; flex-direction: column; justify-content: space-between; width: 24px; height: 18px; padding: 0; border: 0; background: none; cursor: pointer; }
.sidebar-toggle span { width: 100%; height: 3px; border-radius: 2px; background: var(--ap); }

.wrap { display: flex; width: 100%; flex: 1 1 auto; align-items: stretch; min-height: 0; }
.side { z-index: 90; display: flex; width: var(--sidebar-width); flex: 0 0 var(--sidebar-width); flex-direction: column; gap: 6px; padding: 24px 16px 80px; overflow: hidden auto; border-right: 1px solid #1e293b; background: #0f172a; transition: width .25s ease, flex-basis .25s ease, padding .25s ease, opacity .2s ease; }
.side a, .logout-link {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  color: #94a3b8;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.side a:hover, .logout-link:hover { color: #fff; background: #1e293b; }
.side a.active { color: #fff; background: var(--brand); font-weight: 600; box-shadow: 0 4px 12px rgba(37, 102, 218, .2); }
.nav-section { margin: 14px 12px 2px; color: #64748b; font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-mobile-header { display: none; }
.logout-form { margin: 0; }
.wrap.sidebar-collapsed .side { width: 0; flex-basis: 0; padding-right: 0; padding-left: 0; opacity: 0; pointer-events: none; }

.page { width: auto; min-width: 0; max-width: none; flex: 1 1 auto; margin: 0; padding: 30px; overflow: visible; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h2 { margin: 0; color: var(--ap); font-size: clamp(21px, 3vw, 28px); }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 16px; margin: 20px 0 28px; }
.stat-card, .card { border: 1px solid #e2e8f0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.stat-card { min-width: 0; padding: 22px 18px; text-align: center; transition: transform .2s ease, box-shadow .2s ease; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(37, 102, 218, .08); }
.stat-circle { width: 50px; height: 50px; margin: 0 auto 12px; border-radius: 50%; background: #e8f0ff; }
.stat-card:nth-child(2n) .stat-circle { background: #e9f8ec; }
.stat-card:nth-child(3n) .stat-circle { background: #fff4de; }
.stat-card h3 { margin: 0 0 4px; color: var(--brand); font-size: 29px; }
.stat-card p { margin: 0; color: #627089; font-size: 14px; font-weight: 500; }
.card { min-width: 0; padding: 22px; overflow-wrap: anywhere; }
.card + .card { margin-top: 20px; }
.card h3 { margin-top: 0; color: var(--ap); }

.filter-card { margin-bottom: 20px; padding: 18px; }
.filter-grid, .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-row { display: grid; gap: 7px; min-width: 0; }
.form-row label { color: #334155; font-size: 13px; font-weight: 700; }
.form-control, input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
}
select[multiple] { min-height: 120px; }
textarea { resize: vertical; }
.helptext { color: var(--muted); font-size: 12px; }
.errorlist { margin: 4px 0 0; padding-left: 18px; color: #b91c1c; font-size: 13px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 999px; font-size: 14px; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer; }
.btn-primary { color: #fff; background: linear-gradient(120deg, var(--brand), #0ea5e9); box-shadow: 0 8px 18px rgba(14, 165, 233, .2); }
.btn-secondary { color: #155e75; border-color: rgba(21, 94, 117, .35); background: rgba(21, 94, 117, .07); }
.btn-danger { color: #b91c1c; border-color: #fecaca; background: #fff1f2; }
.btn-small { min-height: 32px; padding: 6px 11px; font-size: 12px; }

.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: top; }
th { color: var(--ap); background: #f8fafc; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
td { color: #334155; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 7px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 20px; color: #475569; background: #f1f5f9; font-size: 11px; font-weight: 700; }
.badge-live, .badge-active { color: #166534; background: #dcfce7; }
.badge-inactive { color: #991b1b; background: #fee2e2; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; animation: pulse-live 1.5s infinite; }

.stream-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; }
.video-card { overflow: hidden; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.video-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; }
.video-card-header h4 { margin: 0; color: #1e293b; }
.video-container { position: relative; width: 100%; padding-top: 56.25%; overflow: hidden; background: #111827; }
.drone-stream { position: absolute; inset: 0; display: none; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stream-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #9ca3af; }
.stream-fallback strong { margin-top: 8px; color: #ef4444; font-size: 12px; letter-spacing: .08em; }
.empty-state { padding: 50px 20px; border: 2px dashed #cbd5e1; border-radius: 12px; color: var(--muted); background: #fff; text-align: center; }

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { padding: 11px 14px; border: 1px solid #bfdbfe; border-radius: 9px; color: #1e3a8a; background: #eff6ff; }
.message.success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.message.error { color: #991b1b; border-color: #fecaca; background: #fff1f2; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.detail-item { min-width: 0; padding: 12px 14px; border: 1px solid #edf2f7; border-radius: 9px; background: #f8fafc; }
.detail-item small { display: block; margin-bottom: 5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.detail-item div { overflow-wrap: anywhere; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.user-avatar { display: inline-grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 2px solid #dbeafe; border-radius: 50%; object-fit: cover; background: #fff; }
.user-avatar-small { width: 34px; height: 34px; flex-basis: 34px; }
.avatar-placeholder { color: #fff; background: linear-gradient(135deg, var(--ap2), var(--brand)); font-weight: 800; }
.profile-photo-panel { display: flex; justify-content: center; margin: 0 0 20px; }
.profile-photo { display: inline-grid; width: 132px; height: 132px; place-items: center; border: 4px solid #fff; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); font-size: 38px; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

footer { position: relative; z-index: 100; padding: 12px 20px; color: rgba(255, 255, 255, .85); background: #02294f; box-shadow: 0 -2px 10px rgba(0, 0, 0, .15); font-size: 13px; text-align: center; }
.sidebar-backdrop { display: none; }
.callout-card { border-left: 5px solid var(--brand); }

.login-page { display: flex; width: min(920px, 100%); flex: 1 0 auto; flex-direction: column; justify-content: center; margin: 0 auto; padding: 42px 20px; }
.login-intro { margin-bottom: 18px; text-align: center; }
.login-card { width: min(720px, 100%); margin: 0 auto; padding: 38px 42px; border: 1px solid rgba(148, 163, 184, .18); border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(15, 23, 42, .12); }
.login-card .form-grid { grid-template-columns: 1fr; gap: 20px; }
.login-card input { min-height: 50px; font-size: 16px; }
.login-card .form-actions { justify-content: flex-end; }
.otp-card { max-width: 650px; }
.otp-input { text-align: center; letter-spacing: .55em; font-size: 26px !important; font-weight: 800; }
.otp-explanation { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.media-log { max-height: 560px; overflow: auto; border: 1px solid #1e293b; border-radius: 10px; background: #020617; color: #d1fae5; }
.media-log > div { padding: 9px 12px; border-bottom: 1px solid #172033; overflow-wrap: anywhere; }
.media-log > div:last-child { border-bottom: 0; }
.media-log code { color: inherit; font: 12px/1.5 Consolas, "Courier New", monospace; white-space: pre-wrap; }
.media-log p { padding: 18px; color: #94a3b8; }
.dialog-backdrop { position: fixed; z-index: 2000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, .45); }
.dialog { width: min(360px, 100%); padding: 24px; border-radius: 20px; background: #fff; box-shadow: 0 20px 60px rgba(15, 23, 42, .2); text-align: center; }
.dialog-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%; color: #dc2626; background: rgba(220, 38, 38, .12); font-size: 26px; font-weight: 700; }

@keyframes pulse-live { 50% { transform: scale(1.35); opacity: .4; } }

@media (max-width: 1100px) {
  .top { grid-template-columns: minmax(195px, .85fr) minmax(310px, 1.4fr) minmax(280px, 1fr); gap: 12px; padding: 12px 16px; }
  .header-logo { width: 50px; height: 50px; }
  .leader-card img { width: 48px; height: 48px; }
  .leader-card strong { font-size: 9px; }
}

@media (max-width: 900px) {
  body.nav-open { overflow: hidden; }
  .top { grid-template-columns: 1fr; gap: 12px; padding: 12px 14px; text-align: center; }
  .header-logos { justify-content: center; }
  .leadership { width: min(440px, 100%); margin: 0 auto; }
  .title { min-width: 0; text-align: center; }
  .title h1, .title h2, .title p { overflow-wrap: anywhere; }
  .info { padding: 9px 14px; }
  .user-summary > span:last-child { display: none; }
  .wrap { display: block; }
  .side { position: fixed; top: var(--mobile-sidebar-top, 0); bottom: 0; left: calc(-1 * var(--sidebar-width)); width: min(var(--sidebar-width), 86vw); padding: 12px 16px 40px; opacity: 1; transition: left .25s ease; }
  .wrap:not(.sidebar-collapsed) .side { left: 0; box-shadow: 8px 0 30px rgba(15, 23, 42, .25); }
  .wrap.sidebar-collapsed .side { width: min(var(--sidebar-width), 86vw); padding-right: 16px; padding-left: 16px; opacity: 1; }
  .sidebar-mobile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; padding: 4px 8px 10px; color: #fff; border-bottom: 1px solid #334155; }
  .sidebar-mobile-header button { display: grid; width: 36px; height: 36px; padding: 0; border: 1px solid #475569; border-radius: 50%; place-items: center; color: #fff; background: #1e293b; font-size: 25px; line-height: 1; cursor: pointer; }
  .sidebar-backdrop { position: fixed; z-index: 80; top: var(--mobile-sidebar-top, 0); right: 0; bottom: 0; left: 0; display: block; border: 0; background: rgba(15, 23, 42, .48); opacity: 1; cursor: pointer; }
  .wrap.sidebar-collapsed .sidebar-backdrop { display: none; }
  .page { padding: 22px 16px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions > * { flex: 1 1 180px; }
  .page-actions form { display: flex; }
  .page-actions form .btn { flex: 1; }
  .stream-grid { grid-template-columns: 1fr; }
  footer { padding: 9px 12px; font-size: 11px; }
}

@media (max-width: 560px) {
  .header-logo { width: 44px; height: 44px; }
  .leader-card img { width: 42px; height: 42px; }
  .leader-card strong { font-size: 8px; }
  .leader-card span { font-size: 7px; }
  .title p { font-size: 10px; }
  .info strong { font-size: 12px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 16px 8px; }
  .stat-card h3 { font-size: 24px; }
  .card, .login-card { padding: 18px; }
  .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .video-card-header { align-items: flex-start; flex-wrap: wrap; }
  .btn { width: 100%; }
  .table-actions .btn { width: auto; }
  table { min-width: 640px; }
  th, td { padding: 10px 11px; }
  .form-actions > * { flex: 1 1 100%; }
  .page-actions > * { flex-basis: 100%; }
}

@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr; }
  .header-logo { width: 39px; height: 39px; }
  .page { padding-right: 12px; padding-left: 12px; }
  .card, .login-card { padding: 15px; border-radius: 12px; }
}
