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

:root {
  --bg-primary:    #0c0f12;
  --bg-surface:    #161b22;
  --bg-card:       #1a2026;
  --accent:        #ff8c00;
  --accent-glow:   rgba(255, 140, 0, 0.25);
  --accent-dim:    #c06800;
  --gray-muted:    #4f5b66;
  --gray-text:     #8a95a5;
  --text-white:    #ffffff;
  --text-danger:   #ff4757;
  --radius-sm:     10px;
  --radius-md:     16px;
  --radius-lg:     24px;
  --radius-pill:   50px;
  --transition:    0.25s ease;
  --shadow-accent: 0 0 18px rgba(255,140,0,0.35);
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-white);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.screen.active { display: flex; }

#screen-login {
  justify-content: center;
  align-items: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 20px 24px;
  background: radial-gradient(ellipse at top, #1a2a12 0%, var(--bg-primary) 65%);
}

.login-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid rgba(255,140,0,0.2);
  border-radius: var(--radius-lg);
  padding: 36px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,140,0,0.08);
}

.login-logo {
  font-size: 52px;
  filter: drop-shadow(0 0 12px rgba(255,140,0,0.6));
  line-height: 1;
}

.login-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-align: center;
  color: var(--text-white);
}

.login-subtitle {
  font-size: 14px;
  color: var(--gray-text);
  text-align: center;
  line-height: 1.5;
}

.input-wrapper {
  width: 100%;
  position: relative;
}

.input-code {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 2px solid var(--gray-muted);
  border-radius: var(--radius-pill);
  color: var(--text-white);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-code::placeholder { color: var(--gray-muted); font-weight: 400; letter-spacing: 0; }
.input-code:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dim) 100%);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-white);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 4px 20px rgba(255,140,0,0.4);
}
.btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-box {
  display: none;
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,71,87,0.12);
  border: 1px solid rgba(255,71,87,0.4);
  border-radius: var(--radius-sm);
  color: var(--text-danger);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  animation: fadeSlideIn 0.3s ease;
}
.error-box.visible { display: block; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.demo-hint {
  font-size: 11px;
  color: var(--gray-muted);
  text-align: center;
}

.access-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,140,0,0.06);
  border: 1px solid rgba(255,140,0,0.18);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-text);
  text-align: center;
  line-height: 1.5;
}
.demo-hint span { color: var(--accent); }

#screen-devices {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.fixed-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 12px;
  border-bottom: 1px solid rgba(255,140,0,0.1);
  backdrop-filter: blur(12px);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.app-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-white);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid rgba(255,140,0,0.3);
  border-radius: var(--radius-sm);
  color: var(--text-white);
  font-size: 20px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.btn-icon:active { background: rgba(255,140,0,0.15); box-shadow: var(--shadow-accent); }

.search-bar {
  width: 100%;
  padding: 13px 18px 13px 44px;
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.35);
  border-radius: var(--radius-pill);
  color: var(--text-white);
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  position: relative;
}
.search-bar::placeholder { color: var(--gray-muted); }
.search-bar:focus { border-color: var(--accent); box-shadow: var(--shadow-accent); }

.search-wrapper {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
}

.device-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.device-card:active { transform: scale(0.98); border-color: var(--accent); background: rgba(255,140,0,0.07); }

.device-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-white);
}

.device-arrow {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-text);
  font-size: 15px;
  display: none;
}

#screen-generator {
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.gen-header {
  padding: calc(11px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bg-primary);
  border-bottom: 1px solid rgba(255,140,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.gen-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
  white-space: nowrap;
}

.gen-device-name {
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  color: var(--text-white);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-favorite {
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
  color: var(--accent);
  transition: transform var(--transition), color var(--transition), text-shadow var(--transition);
  flex-shrink: 0;
}
.btn-favorite:active { transform: scale(1.3); }
.btn-favorite.active {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(255,140,0,0.8);
}

.gen-content {
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab-btn {
  padding: 13px 8px;
  border-radius: var(--radius-sm);
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.tab-btn.inactive {
  background: var(--gray-muted);
  color: rgba(255,255,255,0.7);
}

.tab-btn.active-tab {
  background: var(--accent);
  color: var(--text-white);
  box-shadow: 0 4px 16px rgba(255,140,0,0.45);
}

.metrics-container {
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.3);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.metrics-container.mode-alta {
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(255,140,0,0.2);
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-label {
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 700;
  color: var(--text-white);
  flex-shrink: 0;
  width: 115px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-bar-wrap {
  flex: 1;
  height: 9px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  min-width: 0;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  width: 0%;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.metric-value {
  font-size: clamp(15px, 4.2vw, 18px);
  font-weight: 900;
  color: var(--text-white);
  width: 34px;
  flex-shrink: 0;
  text-align: right;
  letter-spacing: -0.5px;
}

.hw-badge {
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.4);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  text-align: center;
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 700;
  color: var(--text-white);
  line-height: 1.6;
}
.hw-badge strong { color: var(--accent); }

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary {
  width: 100%;
  padding: 15px;
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.35);
  border-radius: var(--radius-pill);
  color: var(--text-white);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn-secondary:active {
  transform: scale(0.97);
  border-color: var(--accent);
  box-shadow: var(--shadow-accent);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--bg-surface);
  border-top: 1px solid rgba(255,140,0,0.15);
  z-index: 200;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px 12px;
  background: none;
  border: none;
  color: var(--gray-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  gap: 4px;
  transition: color var(--transition);
  letter-spacing: 0.3px;
}

.nav-btn .nav-icon { font-size: 22px; }
.nav-btn.active-nav { color: var(--accent); }

#screen-favorites {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.fav-header {
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,140,0,0.1);
}

.fav-title {
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-close-fav {
  background: none;
  border: none;
  color: var(--text-danger);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
}

.fav-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fav-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 2px solid rgba(255,140,0,0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.fav-card:active { border-color: var(--accent); background: rgba(255,140,0,0.07); }

.fav-icon { font-size: 28px; }

.fav-info { flex: 1; }
.fav-device-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
}
.fav-sub {
  font-size: 12px;
  color: var(--gray-text);
  margin-top: 2px;
}

.btn-remove-fav {
  background: none;
  border: none;
  color: var(--text-danger);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.fav-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-text);
}
.fav-empty .fav-empty-icon { font-size: 52px; display: block; margin-bottom: 12px; }
.fav-empty p { font-size: 15px; line-height: 1.6; }

.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-surface);
  border: 1px solid rgba(255,140,0,0.3);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-icon { font-size: 26px; flex-shrink: 0; }
.toast-text { flex: 1; }
.toast-title { font-size: 14px; font-weight: 700; color: var(--text-white); }
.toast-sub { font-size: 12px; color: var(--gray-text); margin-top: 2px; }

.kick-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.kick-overlay.show { display: flex; }
.kick-box {
  background: var(--bg-surface);
  border: 2px solid var(--text-danger);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  max-width: 320px;
}
.kick-icon { font-size: 56px; display: block; margin-bottom: 16px; }
.kick-title { font-size: 20px; font-weight: 900; color: var(--text-danger); margin-bottom: 12px; }
.kick-msg { font-size: 14px; color: var(--gray-text); line-height: 1.6; margin-bottom: 24px; }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
.mt-auto { margin-top: auto; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-muted); border-radius: 4px; }
