/* =====================================================
   IMPORT FONT
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:        #e01f1f;
  --red-dim:    #c41a1a;
  --red-light:  #fff0f0;
  --red-glow:   rgba(224, 31, 31, 0.14);
  --red-line:   rgba(224, 31, 31, 0.3);

  --bg:         #f0ede8;
  --bg-panel:   #e8e4de;
  --bg-card:    #faf9f7;
  --bg-input:   #ffffff;
  --bg-hover:   #ede9e3;

  --border:     #d8d3cc;
  --border2:    #c8c2b8;

  --text:       #1a1814;
  --text-dim:   #5a5650;
  --text-label: #9a948a;

  --accent:     #e01f1f;
  --green:      #16a34a;
  --blue:       #0369a1;

  --mono:    'DM Mono', monospace;
  --display: 'Syne', sans-serif;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--red); }

/* LOGIN */
#loginScreen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
#loginScreen::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(-55deg, transparent, transparent 60px, rgba(224,31,31,0.025) 60px, rgba(224,31,31,0.025) 61px);
  pointer-events: none;
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  padding: 48px 40px 40px;
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(224,31,31,0.04);
  z-index: 1;
}
.login-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--red) 30%, var(--red-dim) 70%, transparent 100%);
}
.login-box::after {
  content: ''; position: absolute; bottom: 0; right: 0; width: 60px; height: 60px;
  border-top: 2px solid var(--border2); border-left: 2px solid var(--border2); pointer-events: none;
}
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo img { height: 54px; 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(--border);
  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;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.login-field input::placeholder { color: var(--text-label); }
.login-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
.login-btn {
  width: 100%; height: 46px; margin-top: 16px; background: var(--red); color: white;
  border: none; border-radius: 0; font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.25em; text-transform: uppercase; cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(224,31,31,0.3);
}
.login-btn:hover { background: var(--red-dim); box-shadow: 0 4px 16px rgba(224,31,31,0.4); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
#loginError {
  font-family: var(--mono); font-size: 11px; color: var(--red); text-align: center;
  margin-top: 10px; display: none; background: var(--red-light); padding: 6px;
  border-left: 2px solid var(--red);
}

/* 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;
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}
.sidebar-logo {
  padding: 24px 20px 20px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--bg-card);
}
.sidebar-logo img { height: 44px; width: auto; }
.sidebar-logo .build-tag {
  font-family: var(--mono); font-size: 9px; color: var(--red); letter-spacing: 0.18em;
  text-transform: uppercase; background: var(--red-light); padding: 2px 8px; border: 1px solid var(--red-line);
}
.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: 3px 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: 12px; width: 16px; text-align: center; color: var(--text-label); transition: color 0.18s; }
.nav-item:hover i { color: var(--red); }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-card); }
.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; box-shadow: 0 0 6px rgba(22,163,74,0.5); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* CONTENT */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 52px; background: var(--bg-card); 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; box-shadow: var(--shadow-sm);
}
.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); font-weight: 500; }
.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; font-weight: 500;
  background: rgba(22,163,74,0.08); padding: 3px 10px; border: 1px solid rgba(22,163,74,0.2);
}
.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; /* CRITICAL: lets dropdown show outside panel */
  box-shadow: var(--shadow-sm); transition: box-shadow 0.2s;
}
.panel:hover { box-shadow: var(--shadow-md); }
.panel.span-2 { grid-column: span 2; }
.panel::before {
  content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--red) 0%, transparent 100%);
  opacity: 0; transition: opacity 0.3s;
}
.panel:hover::before { opacity: 1; }
.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: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.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(--border); padding: 2px 8px; }
.panel-body { padding: 20px 18px; }

/* 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] {
  width: 100%; height: 40px; background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); 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; box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
input::placeholder { color: var(--text-label); font-size: 12px; }
input[readonly] { background: var(--bg); color: var(--text-dim); cursor: default; }
input:focus { border-color: var(--red) !important; box-shadow: 0 0 0 3px 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-panel); border: 1px solid var(--border);
  border-left: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 13px; opacity: 0.6; transition: opacity 0.2s, background 0.2s; flex-shrink: 0;
}
.input-row .copy-btn:hover { opacity: 1; background: var(--bg-hover); }
.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; }

/* OTP */
#faBox { margin-top: 4px; }
#countdown {
  font-family: var(--mono); font-size: 11px; color: var(--blue); margin-top: 6px;
  background: rgba(3,105,161,0.06); padding: 4px 8px; display: inline-block; border: 1px solid rgba(3,105,161,0.15);
}

/* BUTTON */
.btn {
  width: 100%; height: 42px; background: var(--red); color: #fff; border: none; border-radius: 0;
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
  cursor: pointer; transition: background 0.18s, box-shadow 0.18s, transform 0.12s; margin-top: 8px;
  box-shadow: 0 2px 8px rgba(224,31,31,0.25); position: relative; overflow: hidden;
}
.btn::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 100%); pointer-events: none; }
.btn:hover { background: var(--red-dim); box-shadow: 0 4px 16px rgba(224,31,31,0.35); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 4px rgba(224,31,31,0.2); }

/* CUSTOM SELECT — FIXED OVERFLOW */
.custom-select-wrapper {
  position: relative; width: 100%; cursor: pointer; user-select: none; z-index: 10;
}
.select-trigger {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 12px; height: 40px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-dim); font-size: 12px; font-family: var(--mono);
  transition: border-color 0.2s, box-shadow 0.2s; box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
.select-trigger:hover { border-color: var(--border2); }
.custom-select-wrapper.open .select-trigger { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-glow); }
.icon-arrow { font-size: 9px; color: var(--text-label); pointer-events: none; transition: transform 0.2s; }
.custom-select-wrapper.open .icon-arrow { transform: rotate(180deg); }
.custom-options {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-top: 2px solid var(--red);
  display: none; z-index: 99999; padding: 4px 0; margin: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.custom-select-wrapper.open .custom-options { display: block; }
.custom-select-wrapper.error .select-trigger { border-color: var(--red); }
li.custom-option {
  padding: 10px 12px; font-size: 12px; font-family: var(--mono); color: var(--text-dim);
  list-style: none; cursor: pointer; transition: background 0.15s, color 0.15s, padding-left 0.15s;
  letter-spacing: 0.05em; border-left: 3px solid transparent;
}
li.custom-option:hover { background: var(--red-light); color: var(--red); border-left-color: var(--red); padding-left: 16px; }
#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); 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; position: relative;
}
.video-btn::before { content: '▶'; font-size: 8px; color: var(--text-label); transition: color 0.18s, transform 0.18s; }
.video-btn:hover { background: var(--red-light); border-color: var(--red-line); color: var(--red) !important; transform: translateX(4px); }
.video-btn:hover::before { color: var(--red); transform: scale(1.2); }

/* MOBILE */
.mobile-header {
  display: none; height: 54px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between; padding: 0 16px;
  position: sticky; top: 0; z-index: 999; box-shadow: var(--shadow-sm);
}
.mobile-header img { height: 34px; }
.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; }

@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; }
  .topbar { display: none; }
  .page { grid-template-columns: 1fr; padding: 14px 12px; gap: 12px; }
  .panel.span-2 { grid-column: span 1; }
}