* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 120%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0b1a2a 0%, #102433 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  position: relative;
}

/* Header cố định */
.fixed-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 2rem;
  background: rgba(12, 25, 35, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1000;
}

.header-buttons {
  display: flex;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.4rem 1.2rem;
  border-radius: 100px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-icon {
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.brand-name {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

/* Nút OTA Manager và nút Edit (bánh răng) */
.ota-btn, .edit-mode-btn {
  background: rgba(20, 40, 55, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 60px;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ota-btn {
  padding: 12px 24px;
  font-size: 1rem;
}

.edit-mode-btn {
  padding: 6px 18px;
  font-size: 1.4rem;
}

.ota-btn:hover, .edit-mode-btn:hover {
  background: #1e3a4d;
  transform: scale(1.02);
  border-color: rgba(255, 255, 255, 0.4);
  color: white;
}

.edit-mode-btn.active {
  background: #22c55e;
  color: white;
  border-color: white;
}

/* Các nút config (Save, Reset, Backup, Restore) */
.config-btn {
  background: #2a4b6e;
  border: none;
  padding: 10px 18px;
  border-radius: 48px;
  font-weight: 600;
  font-size: 0.9rem;
  color: white;
  cursor: pointer;
  transition: 0.2s;
}

.config-btn:hover {
  background: #1e3a5f;
  transform: scale(1.02);
}

/* Container chính */
.app-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  background: rgba(12, 25, 35, 0.65);
  backdrop-filter: blur(16px);
  border-radius: 0 0 48px 48px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 100px 2rem 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* Thanh điều khiển */
.control-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.8rem 1.2rem;
  border-radius: 80px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-buttons {
  display: flex;
  gap: 16px;
}

.nav-btn {
  background: #1e2f3c;
  border: none;
  width: 64px;
  height: 64px;
  border-radius: 40px;
  font-size: 2rem;
  font-weight: 700;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 0 #0f1a22;
}

.nav-btn:hover {
  background: #2a4b6e;
  transform: scale(1.02);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.nav-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0f1a22;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.case-btn, .func-btn, .kb-btn {
  background: #1e2f3c;
  border: none;
  padding: 12px 28px;
  border-radius: 48px;
  font-weight: 600;
  font-size: 1.2rem;
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.case-btn:hover, .func-btn:hover, .kb-btn:hover {
  background: #2a4b6e;
  transform: scale(1.02);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.case-btn:active, .func-btn:active, .kb-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.case-btn {
  background: #2a4b6e;
  min-width: 80px;
  font-weight: bold;
  letter-spacing: 1px;
}

.kb-btn {
  background: #2a4b6e;
  font-size: 1.5rem;
  padding: 12px 20px;
}

/* Keypad grid */
.keypad-area {
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 48px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}

.keypad-grid button {
  background: rgba(25, 45, 60, 0.85);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 32px;
  padding: 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.2);
}

.keypad-grid button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.keypad-grid button span:first-child {
  font-size: 2.6rem;
  font-weight: 800;
  color: #f1f5f9;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.keypad-grid button span.label {
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 40px;
  color: #cbd5e6;
}

/* Database panel */
.database-panel {
  margin-top: 0.5rem;
}

.input-pair {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.db-card {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  border-radius: 80px;
  padding: 4px 4px 4px 24px;
  gap: 8px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05), 0 4px 12px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.db-card input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 16px 0;
  font-size: 1rem;
  font-weight: 500;
  color: #e2e8f0;
  outline: none;
  font-family: 'Inter', monospace;
}

.db-card input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.paste-btn {
  background: #2a4b6e;
  border: none;
  padding: 10px 24px;
  border-radius: 60px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.paste-btn:hover {
  background: #1e3a5f;
  transform: scale(1.02);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.paste-btn:active {
  transform: scale(0.96);
}

/* Modal chỉnh sửa từng phím (đơn giản) */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal-content {
  background: #0f172a;
  margin: 15% auto;
  padding: 2rem;
  border-radius: 2rem;
  width: 90%;
  max-width: 400px;
  color: #e2e8f0;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
  margin-bottom: 1rem;
}

.modal-content label {
  display: block;
  margin: 0.8rem 0 0.3rem;
  font-weight: 500;
}

.modal-content input {
  width: 100%;
  padding: 0.8rem;
  border-radius: 2rem;
  border: none;
  background: #1e293b;
  color: white;
}

.modal-content button {
  margin-top: 1.5rem;
  background: #22c55e;
  border: none;
  padding: 0.8rem;
  width: 100%;
  border-radius: 3rem;
  font-weight: bold;
  cursor: pointer;
}

.close {
  float: right;
  font-size: 2rem;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 780px) {
  .fixed-header {
    padding: 0.75rem 1rem;
  }
  .brand-name {
    font-size: 1.2rem;
  }
  .app-container {
    padding: 80px 1rem 1.5rem;
  }
  .keypad-grid {
    gap: 12px;
  }
  .keypad-grid button span:first-child {
    font-size: 1.8rem;
  }
  .nav-btn {
    width: 54px;
    height: 54px;
    font-size: 1.6rem;
  }
  .case-btn, .func-btn {
    padding: 8px 18px;
    font-size: 1rem;
  }
  .db-card {
    padding-left: 16px;
  }
  .config-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
  .edit-mode-btn {
    font-size: 1.2rem;
    padding: 4px 14px;
  }
}

/* Nút KB toggle */
#kb-toggle {
  transition: 0.2s;
}