* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 110%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0b1a2a 0%, #102433 100%);
  min-height: 100vh;
  padding: 2rem;
}

.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: rgba(12, 25, 35, 0.65);
  backdrop-filter: blur(16px);
  border-radius: 48px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Header trạng thái */
.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2rem;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.6rem 1.5rem;
  border-radius: 100px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}
.status-icon {
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: all 0.2s;
}
.status-info {
  font-size: 0.9rem;
  font-weight: 500;
  color: #cbd5e6;
  background: rgba(0,0,0,0.3);
  padding: 4px 12px;
  border-radius: 40px;
}
.toast-message {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  padding: 6px 12px;
  border-radius: 40px;
  font-size: 0.75rem;
  color: #b9d0f0;
  text-align: center;
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast-message.show {
  opacity: 1;
}

/* Database panel (4 ô) */
.database-panel {
  margin-bottom: 2rem;
}
.input-pair {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.db-card {
  flex: 1;
  min-width: 260px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 80px;
  padding: 4px 4px 4px 12px;
  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);
  position: relative;
}
.db-card input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: #e2e8f0;
  outline: none;
  font-family: 'Inter', monospace;
}
.db-card input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.history-toggle, .send-btn, .clear-ticks-btn {
  background: #2a4b6e;
  border: none;
  padding: 8px 14px;
  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);
}
.history-toggle {
  font-size: 1.2rem;
  padding: 6px 12px;
}
.clear-ticks-btn {
  background: #475569;
}
.history-toggle:hover, .send-btn:hover, .clear-ticks-btn:hover {
  background: #1e3a5f;
  transform: scale(1.02);
}
.clear-ticks-btn:hover {
  background: #334155;
}

/* History dropdown */
.history-panel, .reuse-history-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #0f172a;
  backdrop-filter: blur(16px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 35px -10px black;
  z-index: 1100;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  transform: translateZ(0);
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: background 0.1s;
}
.history-item:hover {
  background: #1e293b;
}
.history-value {
  flex: 1;
  font-size: 0.85rem;
  color: #e2e8f0;
  word-break: break-all;
  padding-right: 8px;
}
.history-del {
  background: #dc2626;
  border: none;
  color: white;
  border-radius: 40px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.1s;
  margin-left: 8px;
}
.history-del:hover {
  background: #b91c1c;
}
.history-empty {
  text-align: center;
  padding: 20px;
  color: #94a3b8;
}
.history-clear-all {
  background: #475569;
  border: none;
  color: white;
  padding: 10px 16px;
  margin: 8px 12px;
  border-radius: 40px;
  cursor: pointer;
  font-weight: 600;
  width: calc(100% - 24px);
  text-align: center;
}

/* Email Reuse panel */
.email-reuse-panel {
  margin-top: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 32px;
  padding: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.reuse-container {
  position: relative;
}
.reuse-card {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 80px;
  padding: 4px 4px 4px 12px;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.reuse-card input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: #e2e8f0;
  outline: none;
}
.reuse-history-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #0f172a;
  backdrop-filter: blur(16px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1100;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

/* Email panel */
.email-panel {
  margin-top: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 32px;
  padding: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.panel-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #cbd5e6;
  border-left: 4px solid #3b82f6;
  padding-left: 12px;
}
.stock-section {
  margin-bottom: 1rem;
}
.stock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  color: #b9d0f0;
  font-weight: 500;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  background: #1e293b;
  padding: 2px 10px;
  border-radius: 40px;
  font-size: 0.8rem;
  color: #94a3b8;
}
.stock-input-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stock-input-group textarea {
  flex: 2;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 24px;
  padding: 10px 14px;
  color: #e2e8f0;
  font-family: monospace;
  font-size: 0.8rem;
  resize: vertical;
}
.btn-glass, .btn-small-glass {
  background: #2a4b6e;
  border: none;
  padding: 8px 16px;
  border-radius: 60px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: 0.2s;
  font-size: 0.8rem;
}
.btn-glass:hover, .btn-small-glass:hover {
  background: #1e3a5f;
  transform: scale(1.02);
}
.btn-glass.success {
  background: #2e7d32;
}
.btn-glass.success:hover {
  background: #1b5e20;
}
.btn-glass.danger, .btn-small-glass.danger {
  background: #7f1a1a;
}
.btn-glass.danger:hover, .btn-small-glass.danger:hover {
  background: #991b1b;
}
.btn-glass.warning, .btn-small-glass.warning {
  background: #b45309;
}
.device-actions-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.table-wrapper {
  overflow-x: auto;
  margin-top: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #cbd5e1;
}
th {
  background: rgba(0,0,0,0.4);
  font-weight: 600;
}
.device-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.message-area {
  margin-top: 12px;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 32px;
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
}
footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.7rem;
  color: #5b7a9a;
}
@media (max-width: 780px) {
  body { padding: 1rem; }
  .app-container { padding: 1.2rem; }
  .db-card { min-width: 100%; }
}