:root{
  --bg: #12161d;
  --bg-soft: #171c25;
  --panel: #1c222c;
  --panel-border: #2a3140;
  --amber: #f2a93b;
  --amber-dim: #b9822f;
  --teal: #3fa796;
  --red: #e05a5a;
  --text: #edeff2;
  --text-muted: #8a93a3;
  --radius: 14px;
  font-size: 16px;
}

*{box-sizing:border-box; margin:0; padding:0;}

html,body{
  height:100%;
}

body{
  background:var(--bg);
  color:var(--text);
  font-family:'Manrope', system-ui, sans-serif;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  position:relative;
  overflow-x:hidden;
}

.bg-grid{
  position:fixed;
  inset:0;
  z-index:0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(242,169,59,0.07), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(63,167,150,0.08), transparent 45%),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size:auto, auto, 44px 44px, 44px 44px;
  pointer-events:none;
}

/* ---------- TOPBAR ---------- */
.topbar{
  position:relative;
  z-index:2;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:22px 28px;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.brand-mark{
  width:34px;
  height:34px;
  border-radius:9px;
  background:linear-gradient(135deg, var(--amber), var(--amber-dim));
  color:#1a1305;
  font-weight:800;
  font-size:18px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.brand-name{
  font-weight:700;
  font-size:17px;
  letter-spacing:0.2px;
}

.brand-dot{
  color:var(--text-muted);
  font-weight:500;
}

.lang-switch{
  display:flex;
  gap:6px;
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:10px;
  padding:4px;
}

.flag-btn{
  background:transparent;
  border:none;
  border-radius:7px;
  width:36px;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  opacity:0.45;
  transition:opacity 0.15s, background 0.15s;
  font-size:16px;
}

.flag-btn.active{
  opacity:1;
  background:rgba(242,169,59,0.14);
}

.flag-btn:hover{ opacity:0.8; }

/* ---------- STAGE ---------- */
.stage{
  position:relative;
  z-index:1;
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:20px 20px 60px;
  width:100%;
}

.screen{ width:100%; max-width:1040px; }
.hidden{ display:none !important; }

/* ---------- LOGIN ---------- */
#loginScreen{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  max-width:none;
}

.panel{
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:var(--radius);
}

.login-panel{
  width:100%;
  max-width:380px;
  padding:34px 32px 32px;
}

.eyebrow{
  color:var(--amber);
  font-size:12.5px;
  font-weight:700;
  margin-bottom:10px;
}

.login-panel h1{
  font-size:26px;
  font-weight:800;
  line-height:1.2;
}

.subtitle{
  color:var(--text-muted);
  font-size:14px;
  margin-top:6px;
  margin-bottom:26px;
}

.login-form{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:7px;
}

.field-label{
  font-size:13px;
  color:var(--text-muted);
  font-weight:600;
}

.field input{
  background:var(--bg-soft);
  border:1px solid var(--panel-border);
  border-radius:9px;
  padding:12px 13px;
  color:var(--text);
  font-size:15px;
  font-family:inherit;
  outline:none;
  transition:border-color 0.15s;
}

.field input:focus{
  border-color:var(--amber-dim);
}

.error-msg{
  display:none;
  color:var(--red);
  font-size:13px;
  font-weight:600;
  margin-top:-6px;
}

.error-msg.show{ display:block; }

.btn-primary{
  margin-top:6px;
  background:var(--amber);
  color:#1a1305;
  border:none;
  border-radius:9px;
  padding:13px;
  font-size:15px;
  font-weight:800;
  font-family:inherit;
  cursor:pointer;
  transition:background 0.15s, transform 0.1s;
}

.btn-primary:hover{ background:#ffbb52; }
.btn-primary:active{ transform:scale(0.98); }

/* ---------- STATIONS ---------- */
.station-head{
  display:flex;
  align-items:baseline;
  gap:16px;
  flex-wrap:wrap;
  margin-bottom:28px;
  padding-top:8px;
}

.station-head h1{
  font-size:28px;
  font-weight:800;
}

.station-head .eyebrow{
  flex-basis:100%;
}

.btn-logout{
  margin-left:auto;
  background:transparent;
  border:1px solid var(--panel-border);
  color:var(--text-muted);
  border-radius:8px;
  padding:9px 16px;
  font-size:13px;
  font-weight:600;
  font-family:inherit;
  cursor:pointer;
  transition:border-color 0.15s, color 0.15s;
}

.btn-logout:hover{
  border-color:var(--red);
  color:var(--red);
}

.station-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:16px;
}

.station-card{
  background:var(--panel);
  border:1px solid var(--panel-border);
  border-radius:var(--radius);
  padding:26px 22px;
  text-align:left;
  cursor:pointer;
  font-family:inherit;
  color:var(--text);
  transition:border-color 0.15s, transform 0.12s, background 0.15s;
  position:relative;
  overflow:hidden;
}

.station-card:hover{
  border-color:var(--amber-dim);
  background:#212836;
  transform:translateY(-2px);
}

.station-card:active{ transform:translateY(0); }

.station-num{
  font-size:34px;
  font-weight:800;
  color:var(--amber);
  line-height:1;
}

.station-label{
  margin-top:10px;
  font-size:15px;
  font-weight:700;
}

.station-sub{
  margin-top:4px;
  font-size:12.5px;
  color:var(--text-muted);
}

/* ---------- VIEW / IFRAME ---------- */
#viewScreen{ max-width:none; width:100%; display:flex; flex-direction:column; flex:1; }

.view-head{
  display:flex;
  align-items:center;
  gap:14px;
  padding:6px 4px 18px;
  max-width:1040px;
  width:100%;
  margin:0 auto;
}

.btn-back{
  background:var(--panel);
  border:1px solid var(--panel-border);
  color:var(--text);
  border-radius:8px;
  padding:9px 15px 9px 10px;
  font-size:13.5px;
  font-weight:600;
  font-family:inherit;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:4px;
  transition:border-color 0.15s;
}

.btn-back:hover{ border-color:var(--amber-dim); }

.back-arrow{ font-size:18px; line-height:1; }

.view-title{
  font-weight:800;
  font-size:16px;
}

.status-dot{
  width:8px; height:8px; border-radius:50%;
  background:var(--text-muted);
  margin-left:auto;
}

.status-dot.online{ background:var(--teal); }
.status-dot.offline{ background:var(--red); }

.iframe-wrap{
  flex:1;
  max-width:1040px;
  width:100%;
  margin:0 auto;
  background:#0c0f14;
  border:1px solid var(--panel-border);
  border-radius:var(--radius);
  overflow:hidden;
  min-height:520px;
  position:relative;
}

#stationFrame{
  width:100%;
  height:100%;
  min-height:520px;
  border:none;
  display:block;
}

.iframe-empty{
  position:absolute;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  color:var(--text-muted);
  font-size:14px;
  text-align:center;
  padding:20px;
}

.iframe-empty.show{ display:flex; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px){
  .topbar{ padding:16px 16px; }
  .login-panel{ padding:28px 22px 26px; }
  .station-head h1{ font-size:24px; }
  .station-grid{ grid-template-columns:1fr; }
  .iframe-wrap, #stationFrame{ min-height:70vh; }
  .btn-logout{ margin-left:0; flex-basis:100%; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; }
}
