/* =====================================================
   IMPORT FONT
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* =====================================================
   VARIABLES & RESET
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:        #ff2d2d;
  --red-dim:    #cc1f1f;
  --red-glow:   rgba(255, 45, 45, 0.18);
  --red-line:   rgba(255, 45, 45, 0.35);

  --bg:         #070709;
  --bg-panel:   #0d0d10;
  --bg-card:    #111116;
  --bg-input:   #0a0a0e;
  --bg-hover:   #16161c;

  --border:     #1c1c24;
  --border2:    #242430;
  --border-hot: #ff2d2d;

  --text:       #e2e2ec;
  --text-dim:   #6b6b80;
  --text-label: white;

  --accent:     #ff2d2d;
  --green:      #22c55e;
  --blue:       #38bdf8;

  --mono:    'IBM Plex Mono', monospace;
  --display: 'Space Grotesk', sans-serif;
}
html { scroll-behavior: smooth; }

body {
  font-family: var(--display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--red-dim); }

/* =====================================================
   LOGIN SCREEN
   ===================================================== */
#loginScreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border2);
  position: relative;
  padding: 48px 40px 40px;
  overflow: hidden;
}

.login-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--red) 40%, var(--red) 60%, transparent 100%);
}

.login-box::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 80px; height: 80px;
  border-top: 1px solid var(--border2);
  border-left: 1px solid var(--border2);
  pointer-events: none;
}

.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo img { height: 120px; width: auto; }

.login-meta { text-align: center; margin-bottom: 32px; }
.login-meta .sys-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-label);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}
.login-meta .sys-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  letter-spacing: 0.1em;
}

.login-field { margin-bottom: 12px; position: relative; }
.login-field-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-label);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  height: 44px;
  background: var(--bg-input);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  border-radius: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-field input::placeholder { color: var(--text-dim); }
.login-field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-glow);
}

.login-btn {
  width: 100%;
  height: 46px;
  margin-top: 16px;
  background: var(--red-dim);
  color: white;
  border: 1px solid var(--red);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  animation: pulse-login 2.8s ease-in-out infinite;
}
.login-btn:hover {
  background: var(--red);
  box-shadow: 0 0 20px var(--red-glow);
  animation: none;
}
@keyframes pulse-login {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,45,45,0.5); }
  50%       { box-shadow: 0 0 0 8px rgba(255,45,45,0); }
}

#loginError {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  text-align: center;
  margin-top: 10px;
  display: none;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sidebar-logo img { height: 130px; width: auto; }
.sidebar-logo .build-tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sidebar-section-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 20px 20px 8px;
}

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-left: 2px solid transparent;
  transition: all 0.18s;
}
.nav-item:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-left-color: var(--red);
}
.nav-item i {
  font-size: 13px;
  width: 16px;
  text-align: center;
  opacity: 0.6;
  transition: opacity 0.18s;
}
.nav-item:hover i { opacity: 1; color: var(--red); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.status-dot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-label);
}
.dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-label);
}
.topbar-left .sep { color: var(--border2); }
.topbar-left .page-name { color: var(--text-dim); }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-label);
}
.topbar-right .live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 10px;
}

.page {
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* =====================================================
   PANEL
   ===================================================== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  overflow: visible;
}

.panel.span-2 { grid-column: span 2; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: white;
}
.panel-title i { color: var(--red); font-size: 11px; }

.panel-badge {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-label);
  letter-spacing: 0.1em;
  background: var(--bg);
  border: 1px solid var(--border2);
  padding: 2px 8px;
}

.panel-body { padding: 20px 18px; overflow: visible; }

/* =====================================================
   FIELDS
   ===================================================== */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }


label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[readonly],
input {
  width: 100%;
  height: 40px;
  background: var(--bg-input) !important;
  border: 1px solid var(--border2) !important;
  color: var(--text) !important;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  border-radius: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder { color: var(--text-dim); font-size: 12px; }
input:focus {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 2px var(--red-glow);
}

.input-row { display: flex; align-items: stretch; gap: 0; }
.input-row input { flex: 1; }
.input-row .copy-btn {
  width: 40px;
  height: 40px;
  background: var(--bg-hover);
  border: 1px solid var(--border2);
  border-left: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
  flex-shrink: 0;
}
.input-row .copy-btn:hover { opacity: 1; background: var(--border2); }

.copy-feedback {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--green);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  height: 13px;
}

#faBox { margin-top: 4px; }
#countdown {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--blue);
  margin-top: 6px;
}

/* =====================================================
   BUTTON
   ===================================================== */
.btn {
  width: 100%;
  height: 42px;
  background: var(--red-dim);
  color: #fff;
  border: 1px solid var(--red-line);
  border-radius: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
  margin-top: 8px;
}
.btn:hover {
  background: var(--red);
  box-shadow: 0 4px 18px var(--red-glow);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* =====================================================
   GET MAIL — 2 BUTTON ROW + STATUS
   ===================================================== */
.mail-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn-half {
  flex: 1;
  margin-top: 0;
}

/* btn-outline: viền đỏ, nền trong */
.btn-outline {
  background: transparent;
  border: 1px solid var(--red-line);
  color: var(--red);
}
.btn-outline:not(:disabled):hover {
  background: var(--red-dim);
  color: #fff;
  box-shadow: 0 4px 18px var(--red-glow);
}
.btn-outline:disabled {
  border-color: var(--border2);
  color: var(--text-dim);
}

.mail-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--blue);
  margin-top: 6px;
  min-height: 16px;
  letter-spacing: 0.05em;
}
.mail-status.error { color: var(--red); }
.mail-status.ok    { color: var(--green); }

/* =====================================================
   CUSTOM SELECT
   ===================================================== */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  cursor: pointer;
  user-select: none;
}
.select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  height: 40px;
  border: 1px solid var(--border2);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  transition: border-color 0.2s;
}
.select-trigger:hover { border-color: #333; }
.icon-arrow { font-size: 9px; color: var(--text-label); pointer-events: none; }
.custom-options {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #111116;
  border: 1px solid var(--border2);
  border-top: none;
  display: none;
  z-index: 9999;
  padding: 4px 0;
  margin: 0;
}
.custom-select-wrapper.open .custom-options { display: block; }
.custom-select-wrapper.open .select-trigger { border-color: var(--red); }
.custom-select-wrapper.error .select-trigger { border-color: var(--red); }
li.custom-option {
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--mono);
  color: white;
  list-style: none;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.05em;
}
li.custom-option:hover { background: var(--red-dim); color: #fff; }
#extra_input { display: none; margin-top: 12px; }

/* =====================================================
   VIDEO LIST
   ===================================================== */
#video-list { display: flex; flex-direction: column; gap: 6px; }

.video-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim) !important;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.18s;
}
.video-btn::before { content: '▶'; font-size: 8px; color: var(--text-label); transition: color 0.18s; }
.video-btn:hover {
  background: var(--bg-hover);
  border-color: var(--red-line);
  color: var(--text) !important;
  transform: translateX(3px);
}
.video-btn:hover::before { color: var(--red); }

/* =====================================================
   MOBILE
   ===================================================== */
.mobile-header {
  display: none;
  height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 999;
}
.mobile-header img { height: 120px; margin: 10px 0px 0px -20px; }
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-dim);
  transition: all 0.3s;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 1000;
    width: 220px;
  }
  .mobile-header { display: flex; height: 80px; }
  .topbar { display: none; }
  .page {
    grid-template-columns: 1fr;
    padding: 14px 12px;
    gap: 12px;
  }
  .panel.span-2 { grid-column: span 1; }
}
.acc-tab-row {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--border2);
}
.acc-tab {
  flex: 1;
  height: 38px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.acc-tab:first-child {
  border-right: 1px solid var(--border2);
}
.acc-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.acc-tab.active {
  background: var(--red-dim);
  color: #fff;
}
.acc-tab i { font-size: 12px; }